]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.11.3-201310011924.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.11.3-201310011924.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..79768fb 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,9 +75,11 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 +TRACEEVENT-CFLAGS
53 aconf
54 af_names.h
55 aic7*reg.h*
56 @@ -80,6 +88,7 @@ aic7*seq.h*
57 aicasm
58 aicdb.h*
59 altivec*.c
60 +ashldi3.S
61 asm-offsets.h
62 asm_offsets.h
63 autoconf.h*
64 @@ -92,19 +101,24 @@ 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 @@ -115,9 +129,11 @@ devlist.h*
90 dnotify_test
91 docproc
92 dslm
93 +dtc-lexer.lex.c
94 elf2ecoff
95 elfconfig.h*
96 evergreen_reg_safe.h
97 +exception_policy.conf
98 fixdep
99 flask.h
100 fore200e_mkfirm
101 @@ -125,12 +141,15 @@ fore200e_pca_fw.c*
102 gconf
103 gconf.glade.h
104 gen-devlist
105 +gen-kdb_cmds.c
106 gen_crc32table
107 gen_init_cpio
108 generated
109 genheaders
110 genksyms
111 *_gray256.c
112 +hash
113 +hid-example
114 hpet_example
115 hugepage-mmap
116 hugepage-shm
117 @@ -145,14 +164,14 @@ int32.c
118 int4.c
119 int8.c
120 kallsyms
121 -kconfig
122 +kern_constants.h
123 keywords.c
124 ksym.c*
125 ksym.h*
126 kxgettext
127 lex.c
128 lex.*.c
129 -linux
130 +lib1funcs.S
131 logo_*.c
132 logo_*_clut224.c
133 logo_*_mono.c
134 @@ -162,14 +181,15 @@ mach-types.h
135 machtypes.h
136 map
137 map_hugetlb
138 -media
139 mconf
140 +mdp
141 miboot*
142 mk_elfconfig
143 mkboot
144 mkbugboot
145 mkcpustr
146 mkdep
147 +mkpiggy
148 mkprep
149 mkregtable
150 mktables
151 @@ -185,6 +205,8 @@ oui.c*
152 page-types
153 parse.c
154 parse.h
155 +parse-events*
156 +pasyms.h
157 patches*
158 pca200e.bin
159 pca200e_ecd.bin2
160 @@ -194,6 +216,7 @@ perf-archive
161 piggyback
162 piggy.gzip
163 piggy.S
164 +pmu-*
165 pnmtologo
166 ppc_defs.h*
167 pss_boot.h
168 @@ -203,7 +226,10 @@ r200_reg_safe.h
169 r300_reg_safe.h
170 r420_reg_safe.h
171 r600_reg_safe.h
172 +realmode.lds
173 +realmode.relocs
174 recordmcount
175 +regdb.c
176 relocs
177 rlim_names.h
178 rn50_reg_safe.h
179 @@ -213,8 +239,12 @@ series
180 setup
181 setup.bin
182 setup.elf
183 +signing_key*
184 +size_overflow_hash.h
185 sImage
186 +slabinfo
187 sm_tbl*
188 +sortextable
189 split-include
190 syscalltab.h
191 tables.c
192 @@ -224,6 +254,7 @@ tftpboot.img
193 timeconst.h
194 times.h*
195 trix_boot.h
196 +user_constants.h
197 utsrelease.h*
198 vdso-syms.lds
199 vdso.lds
200 @@ -235,13 +266,17 @@ vdso32.lds
201 vdso32.so.dbg
202 vdso64.lds
203 vdso64.so.dbg
204 +vdsox32.lds
205 +vdsox32-syms.lds
206 version.h*
207 vmImage
208 vmlinux
209 vmlinux-*
210 vmlinux.aout
211 vmlinux.bin.all
212 +vmlinux.bin.bz2
213 vmlinux.lds
214 +vmlinux.relocs
215 vmlinuz
216 voffset.h
217 vsyscall.lds
218 @@ -249,9 +284,12 @@ vsyscall_32.lds
219 wanxlfw.inc
220 uImage
221 unifdef
222 +utsrelease.h
223 wakeup.bin
224 wakeup.elf
225 wakeup.lds
226 +x509*
227 zImage*
228 zconf.hash.c
229 +zconf.lex.c
230 zoffset.h
231 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
232 index 7f9d4f5..6d1afd6 100644
233 --- a/Documentation/kernel-parameters.txt
234 +++ b/Documentation/kernel-parameters.txt
235 @@ -976,6 +976,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
236 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
237 Default: 1024
238
239 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
240 + ignore grsecurity's /proc restrictions
241 +
242 +
243 hashdist= [KNL,NUMA] Large hashes allocated during boot
244 are distributed across NUMA nodes. Defaults on
245 for 64-bit NUMA, off otherwise.
246 @@ -1932,6 +1936,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
247 noexec=on: enable non-executable mappings (default)
248 noexec=off: disable non-executable mappings
249
250 + nopcid [X86-64]
251 + Disable PCID (Process-Context IDentifier) even if it
252 + is supported by the processor.
253 +
254 nosmap [X86]
255 Disable SMAP (Supervisor Mode Access Prevention)
256 even if it is supported by processor.
257 @@ -2199,6 +2207,25 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
258 the specified number of seconds. This is to be used if
259 your oopses keep scrolling off the screen.
260
261 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
262 + virtualization environments that don't cope well with the
263 + expand down segment used by UDEREF on X86-32 or the frequent
264 + page table updates on X86-64.
265 +
266 + pax_sanitize_slab=
267 + 0/1 to disable/enable slab object sanitization (enabled by
268 + default).
269 +
270 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
271 +
272 + pax_extra_latent_entropy
273 + Enable a very simple form of latent entropy extraction
274 + from the first 4GB of memory as the bootmem allocator
275 + passes the memory pages to the buddy allocator.
276 +
277 + pax_weakuderef [X86-64] enables the weaker but faster form of UDEREF
278 + when the processor supports PCID.
279 +
280 pcbit= [HW,ISDN]
281
282 pcd. [PARIDE]
283 diff --git a/Makefile b/Makefile
284 index 4f91b99..cb9dcfc 100644
285 --- a/Makefile
286 +++ b/Makefile
287 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
288
289 HOSTCC = gcc
290 HOSTCXX = g++
291 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
292 -HOSTCXXFLAGS = -O2
293 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
294 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
295 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
296
297 # Decide whether to build built-in, modular, or both.
298 # Normally, just do built-in.
299 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
300 # Rules shared between *config targets and build targets
301
302 # Basic helpers built in scripts/
303 -PHONY += scripts_basic
304 -scripts_basic:
305 +PHONY += scripts_basic gcc-plugins
306 +scripts_basic: gcc-plugins
307 $(Q)$(MAKE) $(build)=scripts/basic
308 $(Q)rm -f .tmp_quiet_recordmcount
309
310 @@ -576,6 +577,65 @@ else
311 KBUILD_CFLAGS += -O2
312 endif
313
314 +ifndef DISABLE_PAX_PLUGINS
315 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
316 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
317 +else
318 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
319 +endif
320 +ifneq ($(PLUGINCC),)
321 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
322 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
323 +endif
324 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
325 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
326 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
327 +endif
328 +ifdef CONFIG_KALLOCSTAT_PLUGIN
329 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
330 +endif
331 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
332 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
333 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
334 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
335 +endif
336 +ifdef CONFIG_CHECKER_PLUGIN
337 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
338 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
339 +endif
340 +endif
341 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
342 +ifdef CONFIG_PAX_SIZE_OVERFLOW
343 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
344 +endif
345 +ifdef CONFIG_PAX_LATENT_ENTROPY
346 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
347 +endif
348 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
349 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
350 +endif
351 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
352 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
353 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
354 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
355 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
356 +ifeq ($(KBUILD_EXTMOD),)
357 +gcc-plugins:
358 + $(Q)$(MAKE) $(build)=tools/gcc
359 +else
360 +gcc-plugins: ;
361 +endif
362 +else
363 +gcc-plugins:
364 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
365 + $(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.))
366 +else
367 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
368 +endif
369 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
370 +endif
371 +endif
372 +
373 include $(srctree)/arch/$(SRCARCH)/Makefile
374
375 ifdef CONFIG_READABLE_ASM
376 @@ -733,7 +793,7 @@ export mod_sign_cmd
377
378
379 ifeq ($(KBUILD_EXTMOD),)
380 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
381 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
382
383 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
384 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
385 @@ -782,6 +842,8 @@ endif
386
387 # The actual objects are generated when descending,
388 # make sure no implicit rule kicks in
389 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
390 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
391 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
392
393 # Handle descending into subdirectories listed in $(vmlinux-dirs)
394 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
395 # Error messages still appears in the original language
396
397 PHONY += $(vmlinux-dirs)
398 -$(vmlinux-dirs): prepare scripts
399 +$(vmlinux-dirs): gcc-plugins prepare scripts
400 $(Q)$(MAKE) $(build)=$@
401
402 # Store (new) KERNELRELEASE string in include/config/kernel.release
403 @@ -835,6 +897,7 @@ prepare0: archprepare FORCE
404 $(Q)$(MAKE) $(build)=.
405
406 # All the preparing..
407 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
408 prepare: prepare0
409
410 # Generate some files
411 @@ -942,6 +1005,8 @@ all: modules
412 # using awk while concatenating to the final file.
413
414 PHONY += modules
415 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
416 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
417 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
418 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
419 @$(kecho) ' Building modules, stage 2.';
420 @@ -957,7 +1022,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
421
422 # Target to prepare building external modules
423 PHONY += modules_prepare
424 -modules_prepare: prepare scripts
425 +modules_prepare: gcc-plugins prepare scripts
426
427 # Target to install modules
428 PHONY += modules_install
429 @@ -1023,7 +1088,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
430 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
431 signing_key.priv signing_key.x509 x509.genkey \
432 extra_certificates signing_key.x509.keyid \
433 - signing_key.x509.signer
434 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
435
436 # clean - Delete most, but leave enough to build external modules
437 #
438 @@ -1063,6 +1128,7 @@ distclean: mrproper
439 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
440 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
441 -o -name '.*.rej' \
442 + -o -name '.*.rej' -o -name '*.so' \
443 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
444 -type f -print | xargs rm -f
445
446 @@ -1224,6 +1290,8 @@ PHONY += $(module-dirs) modules
447 $(module-dirs): crmodverdir $(objtree)/Module.symvers
448 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
449
450 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
451 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
452 modules: $(module-dirs)
453 @$(kecho) ' Building modules, stage 2.';
454 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
455 @@ -1363,17 +1431,21 @@ else
456 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
457 endif
458
459 -%.s: %.c prepare scripts FORCE
460 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 +%.s: %.c gcc-plugins prepare scripts FORCE
463 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
464 %.i: %.c prepare scripts FORCE
465 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
466 -%.o: %.c prepare scripts FORCE
467 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
468 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
469 +%.o: %.c gcc-plugins prepare scripts FORCE
470 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
471 %.lst: %.c prepare scripts FORCE
472 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
473 -%.s: %.S prepare scripts FORCE
474 +%.s: %.S gcc-plugins prepare scripts FORCE
475 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
476 -%.o: %.S prepare scripts FORCE
477 +%.o: %.S gcc-plugins prepare scripts FORCE
478 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
479 %.symtypes: %.c prepare scripts FORCE
480 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
481 @@ -1383,11 +1455,15 @@ endif
482 $(cmd_crmodverdir)
483 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
484 $(build)=$(build-dir)
485 -%/: prepare scripts FORCE
486 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
487 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
488 +%/: gcc-plugins prepare scripts FORCE
489 $(cmd_crmodverdir)
490 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
491 $(build)=$(build-dir)
492 -%.ko: prepare scripts FORCE
493 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
494 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
495 +%.ko: gcc-plugins prepare scripts FORCE
496 $(cmd_crmodverdir)
497 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
498 $(build)=$(build-dir) $(@:.ko=.o)
499 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
500 index 78b03ef..da28a51 100644
501 --- a/arch/alpha/include/asm/atomic.h
502 +++ b/arch/alpha/include/asm/atomic.h
503 @@ -292,6 +292,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
504 #define atomic_dec(v) atomic_sub(1,(v))
505 #define atomic64_dec(v) atomic64_sub(1,(v))
506
507 +#define atomic64_read_unchecked(v) atomic64_read(v)
508 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
509 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
510 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
511 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
512 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
513 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
514 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
515 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
516 +
517 #define smp_mb__before_atomic_dec() smp_mb()
518 #define smp_mb__after_atomic_dec() smp_mb()
519 #define smp_mb__before_atomic_inc() smp_mb()
520 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
521 index ad368a9..fbe0f25 100644
522 --- a/arch/alpha/include/asm/cache.h
523 +++ b/arch/alpha/include/asm/cache.h
524 @@ -4,19 +4,19 @@
525 #ifndef __ARCH_ALPHA_CACHE_H
526 #define __ARCH_ALPHA_CACHE_H
527
528 +#include <linux/const.h>
529
530 /* Bytes per L1 (data) cache line. */
531 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
532 -# define L1_CACHE_BYTES 64
533 # define L1_CACHE_SHIFT 6
534 #else
535 /* Both EV4 and EV5 are write-through, read-allocate,
536 direct-mapped, physical.
537 */
538 -# define L1_CACHE_BYTES 32
539 # define L1_CACHE_SHIFT 5
540 #endif
541
542 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
543 #define SMP_CACHE_BYTES L1_CACHE_BYTES
544
545 #endif
546 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
547 index 968d999..d36b2df 100644
548 --- a/arch/alpha/include/asm/elf.h
549 +++ b/arch/alpha/include/asm/elf.h
550 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
551
552 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
553
554 +#ifdef CONFIG_PAX_ASLR
555 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
556 +
557 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
558 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
559 +#endif
560 +
561 /* $0 is set by ld.so to a pointer to a function which might be
562 registered using atexit. This provides a mean for the dynamic
563 linker to call DT_FINI functions for shared libraries that have
564 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
565 index bc2a0da..8ad11ee 100644
566 --- a/arch/alpha/include/asm/pgalloc.h
567 +++ b/arch/alpha/include/asm/pgalloc.h
568 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
569 pgd_set(pgd, pmd);
570 }
571
572 +static inline void
573 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
574 +{
575 + pgd_populate(mm, pgd, pmd);
576 +}
577 +
578 extern pgd_t *pgd_alloc(struct mm_struct *mm);
579
580 static inline void
581 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
582 index d8f9b7e..f6222fa 100644
583 --- a/arch/alpha/include/asm/pgtable.h
584 +++ b/arch/alpha/include/asm/pgtable.h
585 @@ -102,6 +102,17 @@ struct vm_area_struct;
586 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
587 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
588 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
589 +
590 +#ifdef CONFIG_PAX_PAGEEXEC
591 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
592 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
593 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
594 +#else
595 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
596 +# define PAGE_COPY_NOEXEC PAGE_COPY
597 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
598 +#endif
599 +
600 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
601
602 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
603 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
604 index 2fd00b7..cfd5069 100644
605 --- a/arch/alpha/kernel/module.c
606 +++ b/arch/alpha/kernel/module.c
607 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
608
609 /* The small sections were sorted to the end of the segment.
610 The following should definitely cover them. */
611 - gp = (u64)me->module_core + me->core_size - 0x8000;
612 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
613 got = sechdrs[me->arch.gotsecindex].sh_addr;
614
615 for (i = 0; i < n; i++) {
616 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
617 index 1402fcc..0b1abd2 100644
618 --- a/arch/alpha/kernel/osf_sys.c
619 +++ b/arch/alpha/kernel/osf_sys.c
620 @@ -1298,10 +1298,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
621 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
622
623 static unsigned long
624 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
625 - unsigned long limit)
626 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
627 + unsigned long limit, unsigned long flags)
628 {
629 struct vm_unmapped_area_info info;
630 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
631
632 info.flags = 0;
633 info.length = len;
634 @@ -1309,6 +1310,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
635 info.high_limit = limit;
636 info.align_mask = 0;
637 info.align_offset = 0;
638 + info.threadstack_offset = offset;
639 return vm_unmapped_area(&info);
640 }
641
642 @@ -1341,20 +1343,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
643 merely specific addresses, but regions of memory -- perhaps
644 this feature should be incorporated into all ports? */
645
646 +#ifdef CONFIG_PAX_RANDMMAP
647 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
648 +#endif
649 +
650 if (addr) {
651 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
652 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
653 if (addr != (unsigned long) -ENOMEM)
654 return addr;
655 }
656
657 /* Next, try allocating at TASK_UNMAPPED_BASE. */
658 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
659 - len, limit);
660 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
661 +
662 if (addr != (unsigned long) -ENOMEM)
663 return addr;
664
665 /* Finally, try allocating in low memory. */
666 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
667 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
668
669 return addr;
670 }
671 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
672 index 0c4132d..88f0d53 100644
673 --- a/arch/alpha/mm/fault.c
674 +++ b/arch/alpha/mm/fault.c
675 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
676 __reload_thread(pcb);
677 }
678
679 +#ifdef CONFIG_PAX_PAGEEXEC
680 +/*
681 + * PaX: decide what to do with offenders (regs->pc = fault address)
682 + *
683 + * returns 1 when task should be killed
684 + * 2 when patched PLT trampoline was detected
685 + * 3 when unpatched PLT trampoline was detected
686 + */
687 +static int pax_handle_fetch_fault(struct pt_regs *regs)
688 +{
689 +
690 +#ifdef CONFIG_PAX_EMUPLT
691 + int err;
692 +
693 + do { /* PaX: patched PLT emulation #1 */
694 + unsigned int ldah, ldq, jmp;
695 +
696 + err = get_user(ldah, (unsigned int *)regs->pc);
697 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
698 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
699 +
700 + if (err)
701 + break;
702 +
703 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
704 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
705 + jmp == 0x6BFB0000U)
706 + {
707 + unsigned long r27, addr;
708 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
709 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
710 +
711 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
712 + err = get_user(r27, (unsigned long *)addr);
713 + if (err)
714 + break;
715 +
716 + regs->r27 = r27;
717 + regs->pc = r27;
718 + return 2;
719 + }
720 + } while (0);
721 +
722 + do { /* PaX: patched PLT emulation #2 */
723 + unsigned int ldah, lda, br;
724 +
725 + err = get_user(ldah, (unsigned int *)regs->pc);
726 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
727 + err |= get_user(br, (unsigned int *)(regs->pc+8));
728 +
729 + if (err)
730 + break;
731 +
732 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
733 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
734 + (br & 0xFFE00000U) == 0xC3E00000U)
735 + {
736 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
737 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
738 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
739 +
740 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
741 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
742 + return 2;
743 + }
744 + } while (0);
745 +
746 + do { /* PaX: unpatched PLT emulation */
747 + unsigned int br;
748 +
749 + err = get_user(br, (unsigned int *)regs->pc);
750 +
751 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
752 + unsigned int br2, ldq, nop, jmp;
753 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
754 +
755 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
756 + err = get_user(br2, (unsigned int *)addr);
757 + err |= get_user(ldq, (unsigned int *)(addr+4));
758 + err |= get_user(nop, (unsigned int *)(addr+8));
759 + err |= get_user(jmp, (unsigned int *)(addr+12));
760 + err |= get_user(resolver, (unsigned long *)(addr+16));
761 +
762 + if (err)
763 + break;
764 +
765 + if (br2 == 0xC3600000U &&
766 + ldq == 0xA77B000CU &&
767 + nop == 0x47FF041FU &&
768 + jmp == 0x6B7B0000U)
769 + {
770 + regs->r28 = regs->pc+4;
771 + regs->r27 = addr+16;
772 + regs->pc = resolver;
773 + return 3;
774 + }
775 + }
776 + } while (0);
777 +#endif
778 +
779 + return 1;
780 +}
781 +
782 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
783 +{
784 + unsigned long i;
785 +
786 + printk(KERN_ERR "PAX: bytes at PC: ");
787 + for (i = 0; i < 5; i++) {
788 + unsigned int c;
789 + if (get_user(c, (unsigned int *)pc+i))
790 + printk(KERN_CONT "???????? ");
791 + else
792 + printk(KERN_CONT "%08x ", c);
793 + }
794 + printk("\n");
795 +}
796 +#endif
797
798 /*
799 * This routine handles page faults. It determines the address,
800 @@ -133,8 +251,29 @@ retry:
801 good_area:
802 si_code = SEGV_ACCERR;
803 if (cause < 0) {
804 - if (!(vma->vm_flags & VM_EXEC))
805 + if (!(vma->vm_flags & VM_EXEC)) {
806 +
807 +#ifdef CONFIG_PAX_PAGEEXEC
808 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
809 + goto bad_area;
810 +
811 + up_read(&mm->mmap_sem);
812 + switch (pax_handle_fetch_fault(regs)) {
813 +
814 +#ifdef CONFIG_PAX_EMUPLT
815 + case 2:
816 + case 3:
817 + return;
818 +#endif
819 +
820 + }
821 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
822 + do_group_exit(SIGKILL);
823 +#else
824 goto bad_area;
825 +#endif
826 +
827 + }
828 } else if (!cause) {
829 /* Allow reads even for write-only mappings */
830 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
831 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
832 index 43594d5..da71e62 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1791,7 +1791,7 @@ config ALIGNMENT_TRAP
836
837 config UACCESS_WITH_MEMCPY
838 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
839 - depends on MMU
840 + depends on MMU && !PAX_MEMORY_UDEREF
841 default y if CPU_FEROCEON
842 help
843 Implement faster copy_to_user and clear_user methods for CPU
844 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
845 index da1c77d..2ee6056 100644
846 --- a/arch/arm/include/asm/atomic.h
847 +++ b/arch/arm/include/asm/atomic.h
848 @@ -17,17 +17,35 @@
849 #include <asm/barrier.h>
850 #include <asm/cmpxchg.h>
851
852 +#ifdef CONFIG_GENERIC_ATOMIC64
853 +#include <asm-generic/atomic64.h>
854 +#endif
855 +
856 #define ATOMIC_INIT(i) { (i) }
857
858 #ifdef __KERNEL__
859
860 +#define _ASM_EXTABLE(from, to) \
861 +" .pushsection __ex_table,\"a\"\n"\
862 +" .align 3\n" \
863 +" .long " #from ", " #to"\n" \
864 +" .popsection"
865 +
866 /*
867 * On ARM, ordinary assignment (str instruction) doesn't clear the local
868 * strex/ldrex monitor on some implementations. The reason we can use it for
869 * atomic_set() is the clrex or dummy strex done on every exception return.
870 */
871 #define atomic_read(v) (*(volatile int *)&(v)->counter)
872 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
873 +{
874 + return v->counter;
875 +}
876 #define atomic_set(v,i) (((v)->counter) = (i))
877 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
878 +{
879 + v->counter = i;
880 +}
881
882 #if __LINUX_ARM_ARCH__ >= 6
883
884 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
885 int result;
886
887 __asm__ __volatile__("@ atomic_add\n"
888 +"1: ldrex %1, [%3]\n"
889 +" adds %0, %1, %4\n"
890 +
891 +#ifdef CONFIG_PAX_REFCOUNT
892 +" bvc 3f\n"
893 +"2: bkpt 0xf103\n"
894 +"3:\n"
895 +#endif
896 +
897 +" strex %1, %0, [%3]\n"
898 +" teq %1, #0\n"
899 +" bne 1b"
900 +
901 +#ifdef CONFIG_PAX_REFCOUNT
902 +"\n4:\n"
903 + _ASM_EXTABLE(2b, 4b)
904 +#endif
905 +
906 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
907 + : "r" (&v->counter), "Ir" (i)
908 + : "cc");
909 +}
910 +
911 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
912 +{
913 + unsigned long tmp;
914 + int result;
915 +
916 + __asm__ __volatile__("@ atomic_add_unchecked\n"
917 "1: ldrex %0, [%3]\n"
918 " add %0, %0, %4\n"
919 " strex %1, %0, [%3]\n"
920 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
921 smp_mb();
922
923 __asm__ __volatile__("@ atomic_add_return\n"
924 +"1: ldrex %1, [%3]\n"
925 +" adds %0, %1, %4\n"
926 +
927 +#ifdef CONFIG_PAX_REFCOUNT
928 +" bvc 3f\n"
929 +" mov %0, %1\n"
930 +"2: bkpt 0xf103\n"
931 +"3:\n"
932 +#endif
933 +
934 +" strex %1, %0, [%3]\n"
935 +" teq %1, #0\n"
936 +" bne 1b"
937 +
938 +#ifdef CONFIG_PAX_REFCOUNT
939 +"\n4:\n"
940 + _ASM_EXTABLE(2b, 4b)
941 +#endif
942 +
943 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
944 + : "r" (&v->counter), "Ir" (i)
945 + : "cc");
946 +
947 + smp_mb();
948 +
949 + return result;
950 +}
951 +
952 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
953 +{
954 + unsigned long tmp;
955 + int result;
956 +
957 + smp_mb();
958 +
959 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
960 "1: ldrex %0, [%3]\n"
961 " add %0, %0, %4\n"
962 " strex %1, %0, [%3]\n"
963 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
964 int result;
965
966 __asm__ __volatile__("@ atomic_sub\n"
967 +"1: ldrex %1, [%3]\n"
968 +" subs %0, %1, %4\n"
969 +
970 +#ifdef CONFIG_PAX_REFCOUNT
971 +" bvc 3f\n"
972 +"2: bkpt 0xf103\n"
973 +"3:\n"
974 +#endif
975 +
976 +" strex %1, %0, [%3]\n"
977 +" teq %1, #0\n"
978 +" bne 1b"
979 +
980 +#ifdef CONFIG_PAX_REFCOUNT
981 +"\n4:\n"
982 + _ASM_EXTABLE(2b, 4b)
983 +#endif
984 +
985 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
986 + : "r" (&v->counter), "Ir" (i)
987 + : "cc");
988 +}
989 +
990 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
991 +{
992 + unsigned long tmp;
993 + int result;
994 +
995 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
996 "1: ldrex %0, [%3]\n"
997 " sub %0, %0, %4\n"
998 " strex %1, %0, [%3]\n"
999 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1000 smp_mb();
1001
1002 __asm__ __volatile__("@ atomic_sub_return\n"
1003 -"1: ldrex %0, [%3]\n"
1004 -" sub %0, %0, %4\n"
1005 +"1: ldrex %1, [%3]\n"
1006 +" subs %0, %1, %4\n"
1007 +
1008 +#ifdef CONFIG_PAX_REFCOUNT
1009 +" bvc 3f\n"
1010 +" mov %0, %1\n"
1011 +"2: bkpt 0xf103\n"
1012 +"3:\n"
1013 +#endif
1014 +
1015 " strex %1, %0, [%3]\n"
1016 " teq %1, #0\n"
1017 " bne 1b"
1018 +
1019 +#ifdef CONFIG_PAX_REFCOUNT
1020 +"\n4:\n"
1021 + _ASM_EXTABLE(2b, 4b)
1022 +#endif
1023 +
1024 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1025 : "r" (&v->counter), "Ir" (i)
1026 : "cc");
1027 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1028 return oldval;
1029 }
1030
1031 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1032 +{
1033 + unsigned long oldval, res;
1034 +
1035 + smp_mb();
1036 +
1037 + do {
1038 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1039 + "ldrex %1, [%3]\n"
1040 + "mov %0, #0\n"
1041 + "teq %1, %4\n"
1042 + "strexeq %0, %5, [%3]\n"
1043 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1044 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1045 + : "cc");
1046 + } while (res);
1047 +
1048 + smp_mb();
1049 +
1050 + return oldval;
1051 +}
1052 +
1053 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1054 {
1055 unsigned long tmp, tmp2;
1056 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1057
1058 return val;
1059 }
1060 +
1061 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1062 +{
1063 + return atomic_add_return(i, v);
1064 +}
1065 +
1066 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1067 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1068 +{
1069 + (void) atomic_add_return(i, v);
1070 +}
1071
1072 static inline int atomic_sub_return(int i, atomic_t *v)
1073 {
1074 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1075 return val;
1076 }
1077 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1078 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1079 +{
1080 + (void) atomic_sub_return(i, v);
1081 +}
1082
1083 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1084 {
1085 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1086 return ret;
1087 }
1088
1089 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1090 +{
1091 + return atomic_cmpxchg(v, old, new);
1092 +}
1093 +
1094 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1095 {
1096 unsigned long flags;
1097 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1098 #endif /* __LINUX_ARM_ARCH__ */
1099
1100 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1101 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1102 +{
1103 + return xchg(&v->counter, new);
1104 +}
1105
1106 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1107 {
1108 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1109 }
1110
1111 #define atomic_inc(v) atomic_add(1, v)
1112 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1113 +{
1114 + atomic_add_unchecked(1, v);
1115 +}
1116 #define atomic_dec(v) atomic_sub(1, v)
1117 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1118 +{
1119 + atomic_sub_unchecked(1, v);
1120 +}
1121
1122 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1123 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1124 +{
1125 + return atomic_add_return_unchecked(1, v) == 0;
1126 +}
1127 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1128 #define atomic_inc_return(v) (atomic_add_return(1, v))
1129 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1130 +{
1131 + return atomic_add_return_unchecked(1, v);
1132 +}
1133 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1134 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1135
1136 @@ -241,6 +428,14 @@ typedef struct {
1137 u64 __aligned(8) counter;
1138 } atomic64_t;
1139
1140 +#ifdef CONFIG_PAX_REFCOUNT
1141 +typedef struct {
1142 + u64 __aligned(8) counter;
1143 +} atomic64_unchecked_t;
1144 +#else
1145 +typedef atomic64_t atomic64_unchecked_t;
1146 +#endif
1147 +
1148 #define ATOMIC64_INIT(i) { (i) }
1149
1150 #ifdef CONFIG_ARM_LPAE
1151 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1152 return result;
1153 }
1154
1155 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1156 +{
1157 + u64 result;
1158 +
1159 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1160 +" ldrd %0, %H0, [%1]"
1161 + : "=&r" (result)
1162 + : "r" (&v->counter), "Qo" (v->counter)
1163 + );
1164 +
1165 + return result;
1166 +}
1167 +
1168 static inline void atomic64_set(atomic64_t *v, u64 i)
1169 {
1170 __asm__ __volatile__("@ atomic64_set\n"
1171 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1172 : "r" (&v->counter), "r" (i)
1173 );
1174 }
1175 +
1176 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1177 +{
1178 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1179 +" strd %2, %H2, [%1]"
1180 + : "=Qo" (v->counter)
1181 + : "r" (&v->counter), "r" (i)
1182 + );
1183 +}
1184 #else
1185 static inline u64 atomic64_read(const atomic64_t *v)
1186 {
1187 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1188 return result;
1189 }
1190
1191 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1192 +{
1193 + u64 result;
1194 +
1195 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1196 +" ldrexd %0, %H0, [%1]"
1197 + : "=&r" (result)
1198 + : "r" (&v->counter), "Qo" (v->counter)
1199 + );
1200 +
1201 + return result;
1202 +}
1203 +
1204 static inline void atomic64_set(atomic64_t *v, u64 i)
1205 {
1206 u64 tmp;
1207 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1208 : "r" (&v->counter), "r" (i)
1209 : "cc");
1210 }
1211 +
1212 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1213 +{
1214 + u64 tmp;
1215 +
1216 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1217 +"1: ldrexd %0, %H0, [%2]\n"
1218 +" strexd %0, %3, %H3, [%2]\n"
1219 +" teq %0, #0\n"
1220 +" bne 1b"
1221 + : "=&r" (tmp), "=Qo" (v->counter)
1222 + : "r" (&v->counter), "r" (i)
1223 + : "cc");
1224 +}
1225 +
1226 #endif
1227
1228 static inline void atomic64_add(u64 i, atomic64_t *v)
1229 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1230 __asm__ __volatile__("@ atomic64_add\n"
1231 "1: ldrexd %0, %H0, [%3]\n"
1232 " adds %0, %0, %4\n"
1233 +" adcs %H0, %H0, %H4\n"
1234 +
1235 +#ifdef CONFIG_PAX_REFCOUNT
1236 +" bvc 3f\n"
1237 +"2: bkpt 0xf103\n"
1238 +"3:\n"
1239 +#endif
1240 +
1241 +" strexd %1, %0, %H0, [%3]\n"
1242 +" teq %1, #0\n"
1243 +" bne 1b"
1244 +
1245 +#ifdef CONFIG_PAX_REFCOUNT
1246 +"\n4:\n"
1247 + _ASM_EXTABLE(2b, 4b)
1248 +#endif
1249 +
1250 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1251 + : "r" (&v->counter), "r" (i)
1252 + : "cc");
1253 +}
1254 +
1255 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1256 +{
1257 + u64 result;
1258 + unsigned long tmp;
1259 +
1260 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1261 +"1: ldrexd %0, %H0, [%3]\n"
1262 +" adds %0, %0, %4\n"
1263 " adc %H0, %H0, %H4\n"
1264 " strexd %1, %0, %H0, [%3]\n"
1265 " teq %1, #0\n"
1266 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1267
1268 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1269 {
1270 - u64 result;
1271 - unsigned long tmp;
1272 + u64 result, tmp;
1273
1274 smp_mb();
1275
1276 __asm__ __volatile__("@ atomic64_add_return\n"
1277 +"1: ldrexd %1, %H1, [%3]\n"
1278 +" adds %0, %1, %4\n"
1279 +" adcs %H0, %H1, %H4\n"
1280 +
1281 +#ifdef CONFIG_PAX_REFCOUNT
1282 +" bvc 3f\n"
1283 +" mov %0, %1\n"
1284 +" mov %H0, %H1\n"
1285 +"2: bkpt 0xf103\n"
1286 +"3:\n"
1287 +#endif
1288 +
1289 +" strexd %1, %0, %H0, [%3]\n"
1290 +" teq %1, #0\n"
1291 +" bne 1b"
1292 +
1293 +#ifdef CONFIG_PAX_REFCOUNT
1294 +"\n4:\n"
1295 + _ASM_EXTABLE(2b, 4b)
1296 +#endif
1297 +
1298 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1299 + : "r" (&v->counter), "r" (i)
1300 + : "cc");
1301 +
1302 + smp_mb();
1303 +
1304 + return result;
1305 +}
1306 +
1307 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1308 +{
1309 + u64 result;
1310 + unsigned long tmp;
1311 +
1312 + smp_mb();
1313 +
1314 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1315 "1: ldrexd %0, %H0, [%3]\n"
1316 " adds %0, %0, %4\n"
1317 " adc %H0, %H0, %H4\n"
1318 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1319 __asm__ __volatile__("@ atomic64_sub\n"
1320 "1: ldrexd %0, %H0, [%3]\n"
1321 " subs %0, %0, %4\n"
1322 +" sbcs %H0, %H0, %H4\n"
1323 +
1324 +#ifdef CONFIG_PAX_REFCOUNT
1325 +" bvc 3f\n"
1326 +"2: bkpt 0xf103\n"
1327 +"3:\n"
1328 +#endif
1329 +
1330 +" strexd %1, %0, %H0, [%3]\n"
1331 +" teq %1, #0\n"
1332 +" bne 1b"
1333 +
1334 +#ifdef CONFIG_PAX_REFCOUNT
1335 +"\n4:\n"
1336 + _ASM_EXTABLE(2b, 4b)
1337 +#endif
1338 +
1339 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1340 + : "r" (&v->counter), "r" (i)
1341 + : "cc");
1342 +}
1343 +
1344 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1345 +{
1346 + u64 result;
1347 + unsigned long tmp;
1348 +
1349 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1350 +"1: ldrexd %0, %H0, [%3]\n"
1351 +" subs %0, %0, %4\n"
1352 " sbc %H0, %H0, %H4\n"
1353 " strexd %1, %0, %H0, [%3]\n"
1354 " teq %1, #0\n"
1355 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1356
1357 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1358 {
1359 - u64 result;
1360 - unsigned long tmp;
1361 + u64 result, tmp;
1362
1363 smp_mb();
1364
1365 __asm__ __volatile__("@ atomic64_sub_return\n"
1366 -"1: ldrexd %0, %H0, [%3]\n"
1367 -" subs %0, %0, %4\n"
1368 -" sbc %H0, %H0, %H4\n"
1369 +"1: ldrexd %1, %H1, [%3]\n"
1370 +" subs %0, %1, %4\n"
1371 +" sbcs %H0, %H1, %H4\n"
1372 +
1373 +#ifdef CONFIG_PAX_REFCOUNT
1374 +" bvc 3f\n"
1375 +" mov %0, %1\n"
1376 +" mov %H0, %H1\n"
1377 +"2: bkpt 0xf103\n"
1378 +"3:\n"
1379 +#endif
1380 +
1381 " strexd %1, %0, %H0, [%3]\n"
1382 " teq %1, #0\n"
1383 " bne 1b"
1384 +
1385 +#ifdef CONFIG_PAX_REFCOUNT
1386 +"\n4:\n"
1387 + _ASM_EXTABLE(2b, 4b)
1388 +#endif
1389 +
1390 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1391 : "r" (&v->counter), "r" (i)
1392 : "cc");
1393 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1394 return oldval;
1395 }
1396
1397 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1398 +{
1399 + u64 oldval;
1400 + unsigned long res;
1401 +
1402 + smp_mb();
1403 +
1404 + do {
1405 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1406 + "ldrexd %1, %H1, [%3]\n"
1407 + "mov %0, #0\n"
1408 + "teq %1, %4\n"
1409 + "teqeq %H1, %H4\n"
1410 + "strexdeq %0, %5, %H5, [%3]"
1411 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1412 + : "r" (&ptr->counter), "r" (old), "r" (new)
1413 + : "cc");
1414 + } while (res);
1415 +
1416 + smp_mb();
1417 +
1418 + return oldval;
1419 +}
1420 +
1421 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1422 {
1423 u64 result;
1424 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1425
1426 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1427 {
1428 - u64 result;
1429 - unsigned long tmp;
1430 + u64 result, tmp;
1431
1432 smp_mb();
1433
1434 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1435 -"1: ldrexd %0, %H0, [%3]\n"
1436 -" subs %0, %0, #1\n"
1437 -" sbc %H0, %H0, #0\n"
1438 +"1: ldrexd %1, %H1, [%3]\n"
1439 +" subs %0, %1, #1\n"
1440 +" sbcs %H0, %H1, #0\n"
1441 +
1442 +#ifdef CONFIG_PAX_REFCOUNT
1443 +" bvc 3f\n"
1444 +" mov %0, %1\n"
1445 +" mov %H0, %H1\n"
1446 +"2: bkpt 0xf103\n"
1447 +"3:\n"
1448 +#endif
1449 +
1450 " teq %H0, #0\n"
1451 -" bmi 2f\n"
1452 +" bmi 4f\n"
1453 " strexd %1, %0, %H0, [%3]\n"
1454 " teq %1, #0\n"
1455 " bne 1b\n"
1456 -"2:"
1457 +"4:\n"
1458 +
1459 +#ifdef CONFIG_PAX_REFCOUNT
1460 + _ASM_EXTABLE(2b, 4b)
1461 +#endif
1462 +
1463 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1464 : "r" (&v->counter)
1465 : "cc");
1466 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1467 " teq %0, %5\n"
1468 " teqeq %H0, %H5\n"
1469 " moveq %1, #0\n"
1470 -" beq 2f\n"
1471 +" beq 4f\n"
1472 " adds %0, %0, %6\n"
1473 -" adc %H0, %H0, %H6\n"
1474 +" adcs %H0, %H0, %H6\n"
1475 +
1476 +#ifdef CONFIG_PAX_REFCOUNT
1477 +" bvc 3f\n"
1478 +"2: bkpt 0xf103\n"
1479 +"3:\n"
1480 +#endif
1481 +
1482 " strexd %2, %0, %H0, [%4]\n"
1483 " teq %2, #0\n"
1484 " bne 1b\n"
1485 -"2:"
1486 +"4:\n"
1487 +
1488 +#ifdef CONFIG_PAX_REFCOUNT
1489 + _ASM_EXTABLE(2b, 4b)
1490 +#endif
1491 +
1492 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1493 : "r" (&v->counter), "r" (u), "r" (a)
1494 : "cc");
1495 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1496
1497 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1498 #define atomic64_inc(v) atomic64_add(1LL, (v))
1499 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1500 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1501 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1502 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1503 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1504 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1505 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1506 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1507 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1508 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1509 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1510 index 75fe66b..ba3dee4 100644
1511 --- a/arch/arm/include/asm/cache.h
1512 +++ b/arch/arm/include/asm/cache.h
1513 @@ -4,8 +4,10 @@
1514 #ifndef __ASMARM_CACHE_H
1515 #define __ASMARM_CACHE_H
1516
1517 +#include <linux/const.h>
1518 +
1519 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1520 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1521 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1522
1523 /*
1524 * Memory returned by kmalloc() may be used for DMA, so we must make
1525 @@ -24,5 +26,6 @@
1526 #endif
1527
1528 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1529 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1530
1531 #endif
1532 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1533 index 17d0ae8..014e350 100644
1534 --- a/arch/arm/include/asm/cacheflush.h
1535 +++ b/arch/arm/include/asm/cacheflush.h
1536 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1537 void (*dma_unmap_area)(const void *, size_t, int);
1538
1539 void (*dma_flush_range)(const void *, const void *);
1540 -};
1541 +} __no_const;
1542
1543 /*
1544 * Select the calling method
1545 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1546 index 6dcc164..b14d917 100644
1547 --- a/arch/arm/include/asm/checksum.h
1548 +++ b/arch/arm/include/asm/checksum.h
1549 @@ -37,7 +37,19 @@ __wsum
1550 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1551
1552 __wsum
1553 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1554 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1555 +
1556 +static inline __wsum
1557 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1558 +{
1559 + __wsum ret;
1560 + pax_open_userland();
1561 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1562 + pax_close_userland();
1563 + return ret;
1564 +}
1565 +
1566 +
1567
1568 /*
1569 * Fold a partial checksum without adding pseudo headers
1570 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1571 index 4f009c1..466c59b 100644
1572 --- a/arch/arm/include/asm/cmpxchg.h
1573 +++ b/arch/arm/include/asm/cmpxchg.h
1574 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1575
1576 #define xchg(ptr,x) \
1577 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1578 +#define xchg_unchecked(ptr,x) \
1579 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1580
1581 #include <asm-generic/cmpxchg-local.h>
1582
1583 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1584 index 6ddbe44..b5e38b1 100644
1585 --- a/arch/arm/include/asm/domain.h
1586 +++ b/arch/arm/include/asm/domain.h
1587 @@ -48,18 +48,37 @@
1588 * Domain types
1589 */
1590 #define DOMAIN_NOACCESS 0
1591 -#define DOMAIN_CLIENT 1
1592 #ifdef CONFIG_CPU_USE_DOMAINS
1593 +#define DOMAIN_USERCLIENT 1
1594 +#define DOMAIN_KERNELCLIENT 1
1595 #define DOMAIN_MANAGER 3
1596 +#define DOMAIN_VECTORS DOMAIN_USER
1597 #else
1598 +
1599 +#ifdef CONFIG_PAX_KERNEXEC
1600 #define DOMAIN_MANAGER 1
1601 +#define DOMAIN_KERNEXEC 3
1602 +#else
1603 +#define DOMAIN_MANAGER 1
1604 +#endif
1605 +
1606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1607 +#define DOMAIN_USERCLIENT 0
1608 +#define DOMAIN_UDEREF 1
1609 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1610 +#else
1611 +#define DOMAIN_USERCLIENT 1
1612 +#define DOMAIN_VECTORS DOMAIN_USER
1613 +#endif
1614 +#define DOMAIN_KERNELCLIENT 1
1615 +
1616 #endif
1617
1618 #define domain_val(dom,type) ((type) << (2*(dom)))
1619
1620 #ifndef __ASSEMBLY__
1621
1622 -#ifdef CONFIG_CPU_USE_DOMAINS
1623 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1624 static inline void set_domain(unsigned val)
1625 {
1626 asm volatile(
1627 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1628 isb();
1629 }
1630
1631 -#define modify_domain(dom,type) \
1632 - do { \
1633 - struct thread_info *thread = current_thread_info(); \
1634 - unsigned int domain = thread->cpu_domain; \
1635 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1636 - thread->cpu_domain = domain | domain_val(dom, type); \
1637 - set_domain(thread->cpu_domain); \
1638 - } while (0)
1639 -
1640 +extern void modify_domain(unsigned int dom, unsigned int type);
1641 #else
1642 static inline void set_domain(unsigned val) { }
1643 static inline void modify_domain(unsigned dom, unsigned type) { }
1644 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1645 index 56211f2..17e8a25 100644
1646 --- a/arch/arm/include/asm/elf.h
1647 +++ b/arch/arm/include/asm/elf.h
1648 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1649 the loader. We need to make sure that it is out of the way of the program
1650 that it will "exec", and that there is sufficient room for the brk. */
1651
1652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1654 +
1655 +#ifdef CONFIG_PAX_ASLR
1656 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1657 +
1658 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1659 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1660 +#endif
1661
1662 /* When the program starts, a1 contains a pointer to a function to be
1663 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1664 @@ -126,10 +133,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1665 extern void elf_set_personality(const struct elf32_hdr *);
1666 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1667
1668 -struct mm_struct;
1669 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1670 -#define arch_randomize_brk arch_randomize_brk
1671 -
1672 #ifdef CONFIG_MMU
1673 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1674 struct linux_binprm;
1675 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1676 index de53547..52b9a28 100644
1677 --- a/arch/arm/include/asm/fncpy.h
1678 +++ b/arch/arm/include/asm/fncpy.h
1679 @@ -81,7 +81,9 @@
1680 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1681 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1682 \
1683 + pax_open_kernel(); \
1684 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1685 + pax_close_kernel(); \
1686 flush_icache_range((unsigned long)(dest_buf), \
1687 (unsigned long)(dest_buf) + (size)); \
1688 \
1689 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1690 index e42cf59..7b94b8f 100644
1691 --- a/arch/arm/include/asm/futex.h
1692 +++ b/arch/arm/include/asm/futex.h
1693 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1694 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1695 return -EFAULT;
1696
1697 + pax_open_userland();
1698 +
1699 smp_mb();
1700 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1701 "1: ldrex %1, [%4]\n"
1702 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1703 : "cc", "memory");
1704 smp_mb();
1705
1706 + pax_close_userland();
1707 +
1708 *uval = val;
1709 return ret;
1710 }
1711 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1712 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1713 return -EFAULT;
1714
1715 + pax_open_userland();
1716 +
1717 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1718 "1: " TUSER(ldr) " %1, [%4]\n"
1719 " teq %1, %2\n"
1720 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1721 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1722 : "cc", "memory");
1723
1724 + pax_close_userland();
1725 +
1726 *uval = val;
1727 return ret;
1728 }
1729 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1730 return -EFAULT;
1731
1732 pagefault_disable(); /* implies preempt_disable() */
1733 + pax_open_userland();
1734
1735 switch (op) {
1736 case FUTEX_OP_SET:
1737 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1738 ret = -ENOSYS;
1739 }
1740
1741 + pax_close_userland();
1742 pagefault_enable(); /* subsumes preempt_enable() */
1743
1744 if (!ret) {
1745 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1746 index 83eb2f7..ed77159 100644
1747 --- a/arch/arm/include/asm/kmap_types.h
1748 +++ b/arch/arm/include/asm/kmap_types.h
1749 @@ -4,6 +4,6 @@
1750 /*
1751 * This is the "bare minimum". AIO seems to require this.
1752 */
1753 -#define KM_TYPE_NR 16
1754 +#define KM_TYPE_NR 17
1755
1756 #endif
1757 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1758 index 9e614a1..3302cca 100644
1759 --- a/arch/arm/include/asm/mach/dma.h
1760 +++ b/arch/arm/include/asm/mach/dma.h
1761 @@ -22,7 +22,7 @@ struct dma_ops {
1762 int (*residue)(unsigned int, dma_t *); /* optional */
1763 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1764 const char *type;
1765 -};
1766 +} __do_const;
1767
1768 struct dma_struct {
1769 void *addr; /* single DMA address */
1770 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1771 index 2fe141f..192dc01 100644
1772 --- a/arch/arm/include/asm/mach/map.h
1773 +++ b/arch/arm/include/asm/mach/map.h
1774 @@ -27,13 +27,16 @@ struct map_desc {
1775 #define MT_MINICLEAN 6
1776 #define MT_LOW_VECTORS 7
1777 #define MT_HIGH_VECTORS 8
1778 -#define MT_MEMORY 9
1779 +#define MT_MEMORY_RWX 9
1780 #define MT_ROM 10
1781 -#define MT_MEMORY_NONCACHED 11
1782 +#define MT_MEMORY_NONCACHED_RX 11
1783 #define MT_MEMORY_DTCM 12
1784 #define MT_MEMORY_ITCM 13
1785 #define MT_MEMORY_SO 14
1786 #define MT_MEMORY_DMA_READY 15
1787 +#define MT_MEMORY_RW 16
1788 +#define MT_MEMORY_RX 17
1789 +#define MT_MEMORY_NONCACHED_RW 18
1790
1791 #ifdef CONFIG_MMU
1792 extern void iotable_init(struct map_desc *, int);
1793 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1794 index 12f71a1..04e063c 100644
1795 --- a/arch/arm/include/asm/outercache.h
1796 +++ b/arch/arm/include/asm/outercache.h
1797 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1798 #endif
1799 void (*set_debug)(unsigned long);
1800 void (*resume)(void);
1801 -};
1802 +} __no_const;
1803
1804 #ifdef CONFIG_OUTER_CACHE
1805
1806 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1807 index 4355f0e..c229913 100644
1808 --- a/arch/arm/include/asm/page.h
1809 +++ b/arch/arm/include/asm/page.h
1810 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1811 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1812 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1813 unsigned long vaddr, struct vm_area_struct *vma);
1814 -};
1815 +} __no_const;
1816
1817 #ifdef MULTI_USER
1818 extern struct cpu_user_fns cpu_user;
1819 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1820 index 943504f..c37a730 100644
1821 --- a/arch/arm/include/asm/pgalloc.h
1822 +++ b/arch/arm/include/asm/pgalloc.h
1823 @@ -17,6 +17,7 @@
1824 #include <asm/processor.h>
1825 #include <asm/cacheflush.h>
1826 #include <asm/tlbflush.h>
1827 +#include <asm/system_info.h>
1828
1829 #define check_pgt_cache() do { } while (0)
1830
1831 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1832 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1833 }
1834
1835 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1836 +{
1837 + pud_populate(mm, pud, pmd);
1838 +}
1839 +
1840 #else /* !CONFIG_ARM_LPAE */
1841
1842 /*
1843 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1845 #define pmd_free(mm, pmd) do { } while (0)
1846 #define pud_populate(mm,pmd,pte) BUG()
1847 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1848
1849 #endif /* CONFIG_ARM_LPAE */
1850
1851 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1852 __free_page(pte);
1853 }
1854
1855 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1856 +{
1857 +#ifdef CONFIG_ARM_LPAE
1858 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1859 +#else
1860 + if (addr & SECTION_SIZE)
1861 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1862 + else
1863 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1864 +#endif
1865 + flush_pmd_entry(pmdp);
1866 +}
1867 +
1868 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1869 pmdval_t prot)
1870 {
1871 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1872 static inline void
1873 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1874 {
1875 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1876 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1877 }
1878 #define pmd_pgtable(pmd) pmd_page(pmd)
1879
1880 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1881 index 5cfba15..f415e1a 100644
1882 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1883 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1884 @@ -20,12 +20,15 @@
1885 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1886 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1887 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1888 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1889 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1890 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1891 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1892 +
1893 /*
1894 * - section
1895 */
1896 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1897 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1898 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1899 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1900 @@ -37,6 +40,7 @@
1901 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1902 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1903 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1904 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1905
1906 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1907 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1908 @@ -66,6 +70,7 @@
1909 * - extended small page/tiny page
1910 */
1911 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1912 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1913 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1914 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1915 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1916 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1917 index f97ee02..cc9fe9e 100644
1918 --- a/arch/arm/include/asm/pgtable-2level.h
1919 +++ b/arch/arm/include/asm/pgtable-2level.h
1920 @@ -126,6 +126,9 @@
1921 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1922 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1923
1924 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1925 +#define L_PTE_PXN (_AT(pteval_t, 0))
1926 +
1927 /*
1928 * These are the memory types, defined to be compatible with
1929 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1930 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1931 index 626989f..9d67a33 100644
1932 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1933 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 @@ -75,6 +75,7 @@
1935 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1936 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1937 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1938 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1939 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1940
1941 /*
1942 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1943 index 5689c18..eea12f9 100644
1944 --- a/arch/arm/include/asm/pgtable-3level.h
1945 +++ b/arch/arm/include/asm/pgtable-3level.h
1946 @@ -82,6 +82,7 @@
1947 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1948 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1949 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1950 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1951 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1952 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1953 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1954 @@ -95,6 +96,7 @@
1955 /*
1956 * To be used in assembly code with the upper page attributes.
1957 */
1958 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1959 #define L_PTE_XN_HIGH (1 << (54 - 32))
1960 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1961
1962 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1963 index 04aeb02..73b70dd 100644
1964 --- a/arch/arm/include/asm/pgtable.h
1965 +++ b/arch/arm/include/asm/pgtable.h
1966 @@ -33,6 +33,9 @@
1967 #include <asm/pgtable-2level.h>
1968 #endif
1969
1970 +#define ktla_ktva(addr) (addr)
1971 +#define ktva_ktla(addr) (addr)
1972 +
1973 /*
1974 * Just any arbitrary offset to the start of the vmalloc VM area: the
1975 * current 8MB value just means that there will be a 8MB "hole" after the
1976 @@ -48,6 +51,9 @@
1977 #define LIBRARY_TEXT_START 0x0c000000
1978
1979 #ifndef __ASSEMBLY__
1980 +extern pteval_t __supported_pte_mask;
1981 +extern pmdval_t __supported_pmd_mask;
1982 +
1983 extern void __pte_error(const char *file, int line, pte_t);
1984 extern void __pmd_error(const char *file, int line, pmd_t);
1985 extern void __pgd_error(const char *file, int line, pgd_t);
1986 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1987 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1988 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1989
1990 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1991 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1992 +
1993 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1994 +#include <asm/domain.h>
1995 +#include <linux/thread_info.h>
1996 +#include <linux/preempt.h>
1997 +
1998 +static inline int test_domain(int domain, int domaintype)
1999 +{
2000 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2001 +}
2002 +#endif
2003 +
2004 +#ifdef CONFIG_PAX_KERNEXEC
2005 +static inline unsigned long pax_open_kernel(void) {
2006 +#ifdef CONFIG_ARM_LPAE
2007 + /* TODO */
2008 +#else
2009 + preempt_disable();
2010 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2011 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2012 +#endif
2013 + return 0;
2014 +}
2015 +
2016 +static inline unsigned long pax_close_kernel(void) {
2017 +#ifdef CONFIG_ARM_LPAE
2018 + /* TODO */
2019 +#else
2020 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2021 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2022 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2023 + preempt_enable_no_resched();
2024 +#endif
2025 + return 0;
2026 +}
2027 +#else
2028 +static inline unsigned long pax_open_kernel(void) { return 0; }
2029 +static inline unsigned long pax_close_kernel(void) { return 0; }
2030 +#endif
2031 +
2032 /*
2033 * This is the lowest virtual address we can permit any user space
2034 * mapping to be mapped at. This is particularly important for
2035 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2036 /*
2037 * The pgprot_* and protection_map entries will be fixed up in runtime
2038 * to include the cachable and bufferable bits based on memory policy,
2039 - * as well as any architecture dependent bits like global/ASID and SMP
2040 - * shared mapping bits.
2041 + * as well as any architecture dependent bits like global/ASID, PXN,
2042 + * and SMP shared mapping bits.
2043 */
2044 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2045
2046 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2047 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2048 {
2049 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2050 - L_PTE_NONE | L_PTE_VALID;
2051 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2052 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2053 return pte;
2054 }
2055 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2056 index 5324c11..bcae5f0 100644
2057 --- a/arch/arm/include/asm/proc-fns.h
2058 +++ b/arch/arm/include/asm/proc-fns.h
2059 @@ -75,7 +75,7 @@ extern struct processor {
2060 unsigned int suspend_size;
2061 void (*do_suspend)(void *);
2062 void (*do_resume)(void *);
2063 -} processor;
2064 +} __do_const processor;
2065
2066 #ifndef MULTI_CPU
2067 extern void cpu_proc_init(void);
2068 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2069 index c4ae171..ea0c0c2 100644
2070 --- a/arch/arm/include/asm/psci.h
2071 +++ b/arch/arm/include/asm/psci.h
2072 @@ -29,7 +29,7 @@ struct psci_operations {
2073 int (*cpu_off)(struct psci_power_state state);
2074 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2075 int (*migrate)(unsigned long cpuid);
2076 -};
2077 +} __no_const;
2078
2079 extern struct psci_operations psci_ops;
2080 extern struct smp_operations psci_smp_ops;
2081 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2082 index a8cae71c..65dd797 100644
2083 --- a/arch/arm/include/asm/smp.h
2084 +++ b/arch/arm/include/asm/smp.h
2085 @@ -110,7 +110,7 @@ struct smp_operations {
2086 int (*cpu_disable)(unsigned int cpu);
2087 #endif
2088 #endif
2089 -};
2090 +} __no_const;
2091
2092 /*
2093 * set platform specific SMP operations
2094 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2095 index 2b8114f..8fe9bcf 100644
2096 --- a/arch/arm/include/asm/thread_info.h
2097 +++ b/arch/arm/include/asm/thread_info.h
2098 @@ -77,9 +77,9 @@ struct thread_info {
2099 .flags = 0, \
2100 .preempt_count = INIT_PREEMPT_COUNT, \
2101 .addr_limit = KERNEL_DS, \
2102 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2103 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2104 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2105 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2106 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2107 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2108 .restart_block = { \
2109 .fn = do_no_restart_syscall, \
2110 }, \
2111 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2112 #define TIF_SYSCALL_AUDIT 9
2113 #define TIF_SYSCALL_TRACEPOINT 10
2114 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2115 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2116 +/* within 8 bits of TIF_SYSCALL_TRACE
2117 + * to meet flexible second operand requirements
2118 + */
2119 +#define TIF_GRSEC_SETXID 12
2120 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2121 #define TIF_USING_IWMMXT 17
2122 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2123 #define TIF_RESTORE_SIGMASK 20
2124 @@ -165,10 +169,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2125 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2126 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2127 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2128 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2129
2130 /* Checks for any syscall work in entry-common.S */
2131 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2132 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2133 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2134
2135 /*
2136 * Change these and you break ASM code in entry-common.S
2137 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2138 index 7e1f760..de33b13 100644
2139 --- a/arch/arm/include/asm/uaccess.h
2140 +++ b/arch/arm/include/asm/uaccess.h
2141 @@ -18,6 +18,7 @@
2142 #include <asm/domain.h>
2143 #include <asm/unified.h>
2144 #include <asm/compiler.h>
2145 +#include <asm/pgtable.h>
2146
2147 #define VERIFY_READ 0
2148 #define VERIFY_WRITE 1
2149 @@ -63,11 +64,38 @@ extern int __put_user_bad(void);
2150 static inline void set_fs(mm_segment_t fs)
2151 {
2152 current_thread_info()->addr_limit = fs;
2153 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2154 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2155 }
2156
2157 #define segment_eq(a,b) ((a) == (b))
2158
2159 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2160 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2161 +
2162 +static inline void pax_open_userland(void)
2163 +{
2164 +
2165 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2166 + if (segment_eq(get_fs(), USER_DS)) {
2167 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2168 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2169 + }
2170 +#endif
2171 +
2172 +}
2173 +
2174 +static inline void pax_close_userland(void)
2175 +{
2176 +
2177 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2178 + if (segment_eq(get_fs(), USER_DS)) {
2179 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2180 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2181 + }
2182 +#endif
2183 +
2184 +}
2185 +
2186 #define __addr_ok(addr) ({ \
2187 unsigned long flag; \
2188 __asm__("cmp %2, %0; movlo %0, #0" \
2189 @@ -143,8 +171,12 @@ extern int __get_user_4(void *);
2190
2191 #define get_user(x,p) \
2192 ({ \
2193 + int __e; \
2194 might_fault(); \
2195 - __get_user_check(x,p); \
2196 + pax_open_userland(); \
2197 + __e = __get_user_check(x,p); \
2198 + pax_close_userland(); \
2199 + __e; \
2200 })
2201
2202 extern int __put_user_1(void *, unsigned int);
2203 @@ -188,8 +220,12 @@ extern int __put_user_8(void *, unsigned long long);
2204
2205 #define put_user(x,p) \
2206 ({ \
2207 + int __e; \
2208 might_fault(); \
2209 - __put_user_check(x,p); \
2210 + pax_open_userland(); \
2211 + __e = __put_user_check(x,p); \
2212 + pax_close_userland(); \
2213 + __e; \
2214 })
2215
2216 #else /* CONFIG_MMU */
2217 @@ -230,13 +266,17 @@ static inline void set_fs(mm_segment_t fs)
2218 #define __get_user(x,ptr) \
2219 ({ \
2220 long __gu_err = 0; \
2221 + pax_open_userland(); \
2222 __get_user_err((x),(ptr),__gu_err); \
2223 + pax_close_userland(); \
2224 __gu_err; \
2225 })
2226
2227 #define __get_user_error(x,ptr,err) \
2228 ({ \
2229 + pax_open_userland(); \
2230 __get_user_err((x),(ptr),err); \
2231 + pax_close_userland(); \
2232 (void) 0; \
2233 })
2234
2235 @@ -312,13 +352,17 @@ do { \
2236 #define __put_user(x,ptr) \
2237 ({ \
2238 long __pu_err = 0; \
2239 + pax_open_userland(); \
2240 __put_user_err((x),(ptr),__pu_err); \
2241 + pax_close_userland(); \
2242 __pu_err; \
2243 })
2244
2245 #define __put_user_error(x,ptr,err) \
2246 ({ \
2247 + pax_open_userland(); \
2248 __put_user_err((x),(ptr),err); \
2249 + pax_close_userland(); \
2250 (void) 0; \
2251 })
2252
2253 @@ -418,11 +462,44 @@ do { \
2254
2255
2256 #ifdef CONFIG_MMU
2257 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2258 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2259 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2260 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2261 +
2262 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2263 +{
2264 + unsigned long ret;
2265 +
2266 + check_object_size(to, n, false);
2267 + pax_open_userland();
2268 + ret = ___copy_from_user(to, from, n);
2269 + pax_close_userland();
2270 + return ret;
2271 +}
2272 +
2273 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2274 +{
2275 + unsigned long ret;
2276 +
2277 + check_object_size(from, n, true);
2278 + pax_open_userland();
2279 + ret = ___copy_to_user(to, from, n);
2280 + pax_close_userland();
2281 + return ret;
2282 +}
2283 +
2284 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2285 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2286 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2287 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2288 +
2289 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2290 +{
2291 + unsigned long ret;
2292 + pax_open_userland();
2293 + ret = ___clear_user(addr, n);
2294 + pax_close_userland();
2295 + return ret;
2296 +}
2297 +
2298 #else
2299 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2300 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2301 @@ -431,6 +508,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2302
2303 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2304 {
2305 + if ((long)n < 0)
2306 + return n;
2307 +
2308 if (access_ok(VERIFY_READ, from, n))
2309 n = __copy_from_user(to, from, n);
2310 else /* security hole - plug it */
2311 @@ -440,6 +520,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2312
2313 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2314 {
2315 + if ((long)n < 0)
2316 + return n;
2317 +
2318 if (access_ok(VERIFY_WRITE, to, n))
2319 n = __copy_to_user(to, from, n);
2320 return n;
2321 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2322 index 5af0ed1..cea83883 100644
2323 --- a/arch/arm/include/uapi/asm/ptrace.h
2324 +++ b/arch/arm/include/uapi/asm/ptrace.h
2325 @@ -92,7 +92,7 @@
2326 * ARMv7 groups of PSR bits
2327 */
2328 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2329 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2330 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2331 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2332 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2333
2334 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2335 index 60d3b73..e5a0f22 100644
2336 --- a/arch/arm/kernel/armksyms.c
2337 +++ b/arch/arm/kernel/armksyms.c
2338 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2339
2340 /* networking */
2341 EXPORT_SYMBOL(csum_partial);
2342 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2343 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2344 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2345 EXPORT_SYMBOL(__csum_ipv6_magic);
2346
2347 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2348 #ifdef CONFIG_MMU
2349 EXPORT_SYMBOL(copy_page);
2350
2351 -EXPORT_SYMBOL(__copy_from_user);
2352 -EXPORT_SYMBOL(__copy_to_user);
2353 -EXPORT_SYMBOL(__clear_user);
2354 +EXPORT_SYMBOL(___copy_from_user);
2355 +EXPORT_SYMBOL(___copy_to_user);
2356 +EXPORT_SYMBOL(___clear_user);
2357
2358 EXPORT_SYMBOL(__get_user_1);
2359 EXPORT_SYMBOL(__get_user_2);
2360 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2361 index 9cbe70c..a7b5e34 100644
2362 --- a/arch/arm/kernel/entry-armv.S
2363 +++ b/arch/arm/kernel/entry-armv.S
2364 @@ -47,6 +47,87 @@
2365 9997:
2366 .endm
2367
2368 + .macro pax_enter_kernel
2369 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2370 + @ make aligned space for saved DACR
2371 + sub sp, sp, #8
2372 + @ save regs
2373 + stmdb sp!, {r1, r2}
2374 + @ read DACR from cpu_domain into r1
2375 + mov r2, sp
2376 + @ assume 8K pages, since we have to split the immediate in two
2377 + bic r2, r2, #(0x1fc0)
2378 + bic r2, r2, #(0x3f)
2379 + ldr r1, [r2, #TI_CPU_DOMAIN]
2380 + @ store old DACR on stack
2381 + str r1, [sp, #8]
2382 +#ifdef CONFIG_PAX_KERNEXEC
2383 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2384 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2385 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2386 +#endif
2387 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2388 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2389 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2390 +#endif
2391 + @ write r1 to current_thread_info()->cpu_domain
2392 + str r1, [r2, #TI_CPU_DOMAIN]
2393 + @ write r1 to DACR
2394 + mcr p15, 0, r1, c3, c0, 0
2395 + @ instruction sync
2396 + instr_sync
2397 + @ restore regs
2398 + ldmia sp!, {r1, r2}
2399 +#endif
2400 + .endm
2401 +
2402 + .macro pax_open_userland
2403 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2404 + @ save regs
2405 + stmdb sp!, {r0, r1}
2406 + @ read DACR from cpu_domain into r1
2407 + mov r0, sp
2408 + @ assume 8K pages, since we have to split the immediate in two
2409 + bic r0, r0, #(0x1fc0)
2410 + bic r0, r0, #(0x3f)
2411 + ldr r1, [r0, #TI_CPU_DOMAIN]
2412 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2413 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2414 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2415 + @ write r1 to current_thread_info()->cpu_domain
2416 + str r1, [r0, #TI_CPU_DOMAIN]
2417 + @ write r1 to DACR
2418 + mcr p15, 0, r1, c3, c0, 0
2419 + @ instruction sync
2420 + instr_sync
2421 + @ restore regs
2422 + ldmia sp!, {r0, r1}
2423 +#endif
2424 + .endm
2425 +
2426 + .macro pax_close_userland
2427 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2428 + @ save regs
2429 + stmdb sp!, {r0, r1}
2430 + @ read DACR from cpu_domain into r1
2431 + mov r0, sp
2432 + @ assume 8K pages, since we have to split the immediate in two
2433 + bic r0, r0, #(0x1fc0)
2434 + bic r0, r0, #(0x3f)
2435 + ldr r1, [r0, #TI_CPU_DOMAIN]
2436 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2437 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2438 + @ write r1 to current_thread_info()->cpu_domain
2439 + str r1, [r0, #TI_CPU_DOMAIN]
2440 + @ write r1 to DACR
2441 + mcr p15, 0, r1, c3, c0, 0
2442 + @ instruction sync
2443 + instr_sync
2444 + @ restore regs
2445 + ldmia sp!, {r0, r1}
2446 +#endif
2447 + .endm
2448 +
2449 .macro pabt_helper
2450 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2451 #ifdef MULTI_PABORT
2452 @@ -89,11 +170,15 @@
2453 * Invalid mode handlers
2454 */
2455 .macro inv_entry, reason
2456 +
2457 + pax_enter_kernel
2458 +
2459 sub sp, sp, #S_FRAME_SIZE
2460 ARM( stmib sp, {r1 - lr} )
2461 THUMB( stmia sp, {r0 - r12} )
2462 THUMB( str sp, [sp, #S_SP] )
2463 THUMB( str lr, [sp, #S_LR] )
2464 +
2465 mov r1, #\reason
2466 .endm
2467
2468 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2469 .macro svc_entry, stack_hole=0
2470 UNWIND(.fnstart )
2471 UNWIND(.save {r0 - pc} )
2472 +
2473 + pax_enter_kernel
2474 +
2475 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2476 +
2477 #ifdef CONFIG_THUMB2_KERNEL
2478 SPFIX( str r0, [sp] ) @ temporarily saved
2479 SPFIX( mov r0, sp )
2480 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2481 ldmia r0, {r3 - r5}
2482 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2483 mov r6, #-1 @ "" "" "" ""
2484 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2485 + @ offset sp by 8 as done in pax_enter_kernel
2486 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2487 +#else
2488 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2489 +#endif
2490 SPFIX( addeq r2, r2, #4 )
2491 str r3, [sp, #-4]! @ save the "real" r0 copied
2492 @ from the exception stack
2493 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2494 .macro usr_entry
2495 UNWIND(.fnstart )
2496 UNWIND(.cantunwind ) @ don't unwind the user space
2497 +
2498 + pax_enter_kernel_user
2499 +
2500 sub sp, sp, #S_FRAME_SIZE
2501 ARM( stmib sp, {r1 - r12} )
2502 THUMB( stmia sp, {r0 - r12} )
2503 @@ -415,7 +512,9 @@ __und_usr:
2504 tst r3, #PSR_T_BIT @ Thumb mode?
2505 bne __und_usr_thumb
2506 sub r4, r2, #4 @ ARM instr at LR - 4
2507 + pax_open_userland
2508 1: ldrt r0, [r4]
2509 + pax_close_userland
2510 #ifdef CONFIG_CPU_ENDIAN_BE8
2511 rev r0, r0 @ little endian instruction
2512 #endif
2513 @@ -450,10 +549,14 @@ __und_usr_thumb:
2514 */
2515 .arch armv6t2
2516 #endif
2517 + pax_open_userland
2518 2: ldrht r5, [r4]
2519 + pax_close_userland
2520 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2521 blo __und_usr_fault_16 @ 16bit undefined instruction
2522 + pax_open_userland
2523 3: ldrht r0, [r2]
2524 + pax_close_userland
2525 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2526 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2527 orr r0, r0, r5, lsl #16
2528 @@ -482,7 +585,8 @@ ENDPROC(__und_usr)
2529 */
2530 .pushsection .fixup, "ax"
2531 .align 2
2532 -4: mov pc, r9
2533 +4: pax_close_userland
2534 + mov pc, r9
2535 .popsection
2536 .pushsection __ex_table,"a"
2537 .long 1b, 4b
2538 @@ -692,7 +796,7 @@ ENTRY(__switch_to)
2539 THUMB( str lr, [ip], #4 )
2540 ldr r4, [r2, #TI_TP_VALUE]
2541 ldr r5, [r2, #TI_TP_VALUE + 4]
2542 -#ifdef CONFIG_CPU_USE_DOMAINS
2543 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2544 ldr r6, [r2, #TI_CPU_DOMAIN]
2545 #endif
2546 switch_tls r1, r4, r5, r3, r7
2547 @@ -701,7 +805,7 @@ ENTRY(__switch_to)
2548 ldr r8, =__stack_chk_guard
2549 ldr r7, [r7, #TSK_STACK_CANARY]
2550 #endif
2551 -#ifdef CONFIG_CPU_USE_DOMAINS
2552 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2553 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2554 #endif
2555 mov r5, r0
2556 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2557 index 94104bf..e425391 100644
2558 --- a/arch/arm/kernel/entry-common.S
2559 +++ b/arch/arm/kernel/entry-common.S
2560 @@ -10,18 +10,46 @@
2561
2562 #include <asm/unistd.h>
2563 #include <asm/ftrace.h>
2564 +#include <asm/domain.h>
2565 #include <asm/unwind.h>
2566
2567 +#include "entry-header.S"
2568 +
2569 #ifdef CONFIG_NEED_RET_TO_USER
2570 #include <mach/entry-macro.S>
2571 #else
2572 .macro arch_ret_to_user, tmp1, tmp2
2573 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2574 + @ save regs
2575 + stmdb sp!, {r1, r2}
2576 + @ read DACR from cpu_domain into r1
2577 + mov r2, sp
2578 + @ assume 8K pages, since we have to split the immediate in two
2579 + bic r2, r2, #(0x1fc0)
2580 + bic r2, r2, #(0x3f)
2581 + ldr r1, [r2, #TI_CPU_DOMAIN]
2582 +#ifdef CONFIG_PAX_KERNEXEC
2583 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2584 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2585 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2586 +#endif
2587 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2588 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2589 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2590 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2591 +#endif
2592 + @ write r1 to current_thread_info()->cpu_domain
2593 + str r1, [r2, #TI_CPU_DOMAIN]
2594 + @ write r1 to DACR
2595 + mcr p15, 0, r1, c3, c0, 0
2596 + @ instruction sync
2597 + instr_sync
2598 + @ restore regs
2599 + ldmia sp!, {r1, r2}
2600 +#endif
2601 .endm
2602 #endif
2603
2604 -#include "entry-header.S"
2605 -
2606 -
2607 .align 5
2608 /*
2609 * This is the fast syscall return path. We do as little as
2610 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2611 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2612 #endif
2613
2614 + /*
2615 + * do this here to avoid a performance hit of wrapping the code above
2616 + * that directly dereferences userland to parse the SWI instruction
2617 + */
2618 + pax_enter_kernel_user
2619 +
2620 adr tbl, sys_call_table @ load syscall table pointer
2621
2622 #if defined(CONFIG_OABI_COMPAT)
2623 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2624 index de23a9b..94c37c4 100644
2625 --- a/arch/arm/kernel/entry-header.S
2626 +++ b/arch/arm/kernel/entry-header.S
2627 @@ -184,6 +184,60 @@
2628 msr cpsr_c, \rtemp @ switch back to the SVC mode
2629 .endm
2630
2631 + .macro pax_enter_kernel_user
2632 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2633 + @ save regs
2634 + stmdb sp!, {r0, r1}
2635 + @ read DACR from cpu_domain into r1
2636 + mov r0, sp
2637 + @ assume 8K pages, since we have to split the immediate in two
2638 + bic r0, r0, #(0x1fc0)
2639 + bic r0, r0, #(0x3f)
2640 + ldr r1, [r0, #TI_CPU_DOMAIN]
2641 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2642 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2643 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2644 +#endif
2645 +#ifdef CONFIG_PAX_KERNEXEC
2646 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2647 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2648 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2649 +#endif
2650 + @ write r1 to current_thread_info()->cpu_domain
2651 + str r1, [r0, #TI_CPU_DOMAIN]
2652 + @ write r1 to DACR
2653 + mcr p15, 0, r1, c3, c0, 0
2654 + @ instruction sync
2655 + instr_sync
2656 + @ restore regs
2657 + ldmia sp!, {r0, r1}
2658 +#endif
2659 + .endm
2660 +
2661 + .macro pax_exit_kernel
2662 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2663 + @ save regs
2664 + stmdb sp!, {r0, r1}
2665 + @ read old DACR from stack into r1
2666 + ldr r1, [sp, #(8 + S_SP)]
2667 + sub r1, r1, #8
2668 + ldr r1, [r1]
2669 +
2670 + @ write r1 to current_thread_info()->cpu_domain
2671 + mov r0, sp
2672 + @ assume 8K pages, since we have to split the immediate in two
2673 + bic r0, r0, #(0x1fc0)
2674 + bic r0, r0, #(0x3f)
2675 + str r1, [r0, #TI_CPU_DOMAIN]
2676 + @ write r1 to DACR
2677 + mcr p15, 0, r1, c3, c0, 0
2678 + @ instruction sync
2679 + instr_sync
2680 + @ restore regs
2681 + ldmia sp!, {r0, r1}
2682 +#endif
2683 + .endm
2684 +
2685 #ifndef CONFIG_THUMB2_KERNEL
2686 .macro svc_exit, rpsr, irq = 0
2687 .if \irq != 0
2688 @@ -203,6 +257,9 @@
2689 blne trace_hardirqs_off
2690 #endif
2691 .endif
2692 +
2693 + pax_exit_kernel
2694 +
2695 msr spsr_cxsf, \rpsr
2696 #if defined(CONFIG_CPU_V6)
2697 ldr r0, [sp]
2698 @@ -266,6 +323,9 @@
2699 blne trace_hardirqs_off
2700 #endif
2701 .endif
2702 +
2703 + pax_exit_kernel
2704 +
2705 ldr lr, [sp, #S_SP] @ top of the stack
2706 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2707 clrex @ clear the exclusive monitor
2708 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2709 index 918875d..cd5fa27 100644
2710 --- a/arch/arm/kernel/fiq.c
2711 +++ b/arch/arm/kernel/fiq.c
2712 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2713 void *base = vectors_page;
2714 unsigned offset = FIQ_OFFSET;
2715
2716 + pax_open_kernel();
2717 memcpy(base + offset, start, length);
2718 + pax_close_kernel();
2719 +
2720 if (!cache_is_vipt_nonaliasing())
2721 flush_icache_range((unsigned long)base + offset, offset +
2722 length);
2723 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2724 index 2c7cc1e..ab2e911 100644
2725 --- a/arch/arm/kernel/head.S
2726 +++ b/arch/arm/kernel/head.S
2727 @@ -52,7 +52,9 @@
2728 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2729
2730 .macro pgtbl, rd, phys
2731 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2732 + mov \rd, #TEXT_OFFSET
2733 + sub \rd, #PG_DIR_SIZE
2734 + add \rd, \rd, \phys
2735 .endm
2736
2737 /*
2738 @@ -432,7 +434,7 @@ __enable_mmu:
2739 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2740 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2741 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2742 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2743 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2744 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2745 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2746 #endif
2747 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2748 index 85c3fb6..054c2dc 100644
2749 --- a/arch/arm/kernel/module.c
2750 +++ b/arch/arm/kernel/module.c
2751 @@ -37,12 +37,39 @@
2752 #endif
2753
2754 #ifdef CONFIG_MMU
2755 -void *module_alloc(unsigned long size)
2756 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2757 {
2758 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2759 + return NULL;
2760 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2761 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2762 + GFP_KERNEL, prot, -1,
2763 __builtin_return_address(0));
2764 }
2765 +
2766 +void *module_alloc(unsigned long size)
2767 +{
2768 +
2769 +#ifdef CONFIG_PAX_KERNEXEC
2770 + return __module_alloc(size, PAGE_KERNEL);
2771 +#else
2772 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2773 +#endif
2774 +
2775 +}
2776 +
2777 +#ifdef CONFIG_PAX_KERNEXEC
2778 +void module_free_exec(struct module *mod, void *module_region)
2779 +{
2780 + module_free(mod, module_region);
2781 +}
2782 +EXPORT_SYMBOL(module_free_exec);
2783 +
2784 +void *module_alloc_exec(unsigned long size)
2785 +{
2786 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2787 +}
2788 +EXPORT_SYMBOL(module_alloc_exec);
2789 +#endif
2790 #endif
2791
2792 int
2793 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2794 index 07314af..c46655c 100644
2795 --- a/arch/arm/kernel/patch.c
2796 +++ b/arch/arm/kernel/patch.c
2797 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2798 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2799 int size;
2800
2801 + pax_open_kernel();
2802 if (thumb2 && __opcode_is_thumb16(insn)) {
2803 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2804 size = sizeof(u16);
2805 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2806 *(u32 *)addr = insn;
2807 size = sizeof(u32);
2808 }
2809 + pax_close_kernel();
2810
2811 flush_icache_range((uintptr_t)(addr),
2812 (uintptr_t)(addr) + size);
2813 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2814 index 94f6b05..efd7312 100644
2815 --- a/arch/arm/kernel/process.c
2816 +++ b/arch/arm/kernel/process.c
2817 @@ -217,6 +217,7 @@ void machine_power_off(void)
2818
2819 if (pm_power_off)
2820 pm_power_off();
2821 + BUG();
2822 }
2823
2824 /*
2825 @@ -230,7 +231,7 @@ void machine_power_off(void)
2826 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2827 * to use. Implementing such co-ordination would be essentially impossible.
2828 */
2829 -void machine_restart(char *cmd)
2830 +__noreturn void machine_restart(char *cmd)
2831 {
2832 local_irq_disable();
2833 smp_send_stop();
2834 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2835
2836 show_regs_print_info(KERN_DEFAULT);
2837
2838 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2839 - print_symbol("LR is at %s\n", regs->ARM_lr);
2840 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2841 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2842 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2843 "sp : %08lx ip : %08lx fp : %08lx\n",
2844 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2845 @@ -422,12 +423,6 @@ unsigned long get_wchan(struct task_struct *p)
2846 return 0;
2847 }
2848
2849 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2850 -{
2851 - unsigned long range_end = mm->brk + 0x02000000;
2852 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2853 -}
2854 -
2855 #ifdef CONFIG_MMU
2856 #ifdef CONFIG_KUSER_HELPERS
2857 /*
2858 @@ -443,7 +438,7 @@ static struct vm_area_struct gate_vma = {
2859
2860 static int __init gate_vma_init(void)
2861 {
2862 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2863 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2864 return 0;
2865 }
2866 arch_initcall(gate_vma_init);
2867 @@ -469,41 +464,16 @@ int in_gate_area_no_mm(unsigned long addr)
2868
2869 const char *arch_vma_name(struct vm_area_struct *vma)
2870 {
2871 - return is_gate_vma(vma) ? "[vectors]" :
2872 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2873 - "[sigpage]" : NULL;
2874 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2875 }
2876
2877 -static struct page *signal_page;
2878 -extern struct page *get_signal_page(void);
2879 -
2880 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2881 {
2882 struct mm_struct *mm = current->mm;
2883 - unsigned long addr;
2884 - int ret;
2885 -
2886 - if (!signal_page)
2887 - signal_page = get_signal_page();
2888 - if (!signal_page)
2889 - return -ENOMEM;
2890
2891 down_write(&mm->mmap_sem);
2892 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2893 - if (IS_ERR_VALUE(addr)) {
2894 - ret = addr;
2895 - goto up_fail;
2896 - }
2897 -
2898 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2899 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2900 - &signal_page);
2901 -
2902 - if (ret == 0)
2903 - mm->context.sigpage = addr;
2904 -
2905 - up_fail:
2906 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2907 up_write(&mm->mmap_sem);
2908 - return ret;
2909 + return 0;
2910 }
2911 #endif
2912 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2913 index 4693188..4596c5e 100644
2914 --- a/arch/arm/kernel/psci.c
2915 +++ b/arch/arm/kernel/psci.c
2916 @@ -24,7 +24,7 @@
2917 #include <asm/opcodes-virt.h>
2918 #include <asm/psci.h>
2919
2920 -struct psci_operations psci_ops;
2921 +struct psci_operations psci_ops __read_only;
2922
2923 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2924
2925 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2926 index 0dd3b79..e018f64 100644
2927 --- a/arch/arm/kernel/ptrace.c
2928 +++ b/arch/arm/kernel/ptrace.c
2929 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2930 return current_thread_info()->syscall;
2931 }
2932
2933 +#ifdef CONFIG_GRKERNSEC_SETXID
2934 +extern void gr_delayed_cred_worker(void);
2935 +#endif
2936 +
2937 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2938 {
2939 current_thread_info()->syscall = scno;
2940
2941 +#ifdef CONFIG_GRKERNSEC_SETXID
2942 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2943 + gr_delayed_cred_worker();
2944 +#endif
2945 +
2946 /* Do the secure computing check first; failures should be fast. */
2947 if (secure_computing(scno) == -1)
2948 return -1;
2949 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2950 index afc2489..6372bc8 100644
2951 --- a/arch/arm/kernel/setup.c
2952 +++ b/arch/arm/kernel/setup.c
2953 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2954 unsigned int elf_hwcap __read_mostly;
2955 EXPORT_SYMBOL(elf_hwcap);
2956
2957 +pteval_t __supported_pte_mask __read_only;
2958 +pmdval_t __supported_pmd_mask __read_only;
2959
2960 #ifdef MULTI_CPU
2961 -struct processor processor __read_mostly;
2962 +struct processor processor;
2963 #endif
2964 #ifdef MULTI_TLB
2965 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2966 +struct cpu_tlb_fns cpu_tlb __read_only;
2967 #endif
2968 #ifdef MULTI_USER
2969 -struct cpu_user_fns cpu_user __read_mostly;
2970 +struct cpu_user_fns cpu_user __read_only;
2971 #endif
2972 #ifdef MULTI_CACHE
2973 -struct cpu_cache_fns cpu_cache __read_mostly;
2974 +struct cpu_cache_fns cpu_cache __read_only;
2975 #endif
2976 #ifdef CONFIG_OUTER_CACHE
2977 -struct outer_cache_fns outer_cache __read_mostly;
2978 +struct outer_cache_fns outer_cache __read_only;
2979 EXPORT_SYMBOL(outer_cache);
2980 #endif
2981
2982 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
2983 asm("mrc p15, 0, %0, c0, c1, 4"
2984 : "=r" (mmfr0));
2985 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2986 - (mmfr0 & 0x000000f0) >= 0x00000030)
2987 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2988 cpu_arch = CPU_ARCH_ARMv7;
2989 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2990 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2991 + __supported_pte_mask |= L_PTE_PXN;
2992 + __supported_pmd_mask |= PMD_PXNTABLE;
2993 + }
2994 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2995 (mmfr0 & 0x000000f0) == 0x00000020)
2996 cpu_arch = CPU_ARCH_ARMv6;
2997 else
2998 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
2999 __cpu_architecture = __get_cpu_architecture();
3000
3001 #ifdef MULTI_CPU
3002 - processor = *list->proc;
3003 + memcpy((void *)&processor, list->proc, sizeof processor);
3004 #endif
3005 #ifdef MULTI_TLB
3006 cpu_tlb = *list->tlb;
3007 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3008 index ab33042..11248a8 100644
3009 --- a/arch/arm/kernel/signal.c
3010 +++ b/arch/arm/kernel/signal.c
3011 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3012 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3013 };
3014
3015 -static unsigned long signal_return_offset;
3016 -
3017 #ifdef CONFIG_CRUNCH
3018 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3019 {
3020 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3021 * except when the MPU has protected the vectors
3022 * page from PL0
3023 */
3024 - retcode = mm->context.sigpage + signal_return_offset +
3025 - (idx << 2) + thumb;
3026 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3027 } else
3028 #endif
3029 {
3030 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3031 } while (thread_flags & _TIF_WORK_MASK);
3032 return 0;
3033 }
3034 -
3035 -struct page *get_signal_page(void)
3036 -{
3037 - unsigned long ptr;
3038 - unsigned offset;
3039 - struct page *page;
3040 - void *addr;
3041 -
3042 - page = alloc_pages(GFP_KERNEL, 0);
3043 -
3044 - if (!page)
3045 - return NULL;
3046 -
3047 - addr = page_address(page);
3048 -
3049 - /* Give the signal return code some randomness */
3050 - offset = 0x200 + (get_random_int() & 0x7fc);
3051 - signal_return_offset = offset;
3052 -
3053 - /*
3054 - * Copy signal return handlers into the vector page, and
3055 - * set sigreturn to be a pointer to these.
3056 - */
3057 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3058 -
3059 - ptr = (unsigned long)addr + offset;
3060 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3061 -
3062 - return page;
3063 -}
3064 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3065 index 2dc1934..ecf0e21 100644
3066 --- a/arch/arm/kernel/smp.c
3067 +++ b/arch/arm/kernel/smp.c
3068 @@ -71,7 +71,7 @@ enum ipi_msg_type {
3069
3070 static DECLARE_COMPLETION(cpu_running);
3071
3072 -static struct smp_operations smp_ops;
3073 +static struct smp_operations smp_ops __read_only;
3074
3075 void __init smp_set_ops(struct smp_operations *ops)
3076 {
3077 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3078 index ab517fc..9adf2fa 100644
3079 --- a/arch/arm/kernel/traps.c
3080 +++ b/arch/arm/kernel/traps.c
3081 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3082 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3083 {
3084 #ifdef CONFIG_KALLSYMS
3085 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3086 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3087 #else
3088 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3089 #endif
3090 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3091 static int die_owner = -1;
3092 static unsigned int die_nest_count;
3093
3094 +extern void gr_handle_kernel_exploit(void);
3095 +
3096 static unsigned long oops_begin(void)
3097 {
3098 int cpu;
3099 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3100 panic("Fatal exception in interrupt");
3101 if (panic_on_oops)
3102 panic("Fatal exception");
3103 +
3104 + gr_handle_kernel_exploit();
3105 +
3106 if (signr)
3107 do_exit(signr);
3108 }
3109 @@ -592,7 +597,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3110 * The user helper at 0xffff0fe0 must be used instead.
3111 * (see entry-armv.S for details)
3112 */
3113 + pax_open_kernel();
3114 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3115 + pax_close_kernel();
3116 }
3117 return 0;
3118
3119 @@ -849,7 +856,11 @@ void __init early_trap_init(void *vectors_base)
3120 kuser_init(vectors_base);
3121
3122 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3123 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3124 +
3125 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3126 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3127 +#endif
3128 +
3129 #else /* ifndef CONFIG_CPU_V7M */
3130 /*
3131 * on V7-M there is no need to copy the vector table to a dedicated
3132 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3133 index 7bcee5c..e2f3249 100644
3134 --- a/arch/arm/kernel/vmlinux.lds.S
3135 +++ b/arch/arm/kernel/vmlinux.lds.S
3136 @@ -8,7 +8,11 @@
3137 #include <asm/thread_info.h>
3138 #include <asm/memory.h>
3139 #include <asm/page.h>
3140 -
3141 +
3142 +#ifdef CONFIG_PAX_KERNEXEC
3143 +#include <asm/pgtable.h>
3144 +#endif
3145 +
3146 #define PROC_INFO \
3147 . = ALIGN(4); \
3148 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3149 @@ -34,7 +38,7 @@
3150 #endif
3151
3152 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3153 - defined(CONFIG_GENERIC_BUG)
3154 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3155 #define ARM_EXIT_KEEP(x) x
3156 #define ARM_EXIT_DISCARD(x)
3157 #else
3158 @@ -90,6 +94,11 @@ SECTIONS
3159 _text = .;
3160 HEAD_TEXT
3161 }
3162 +
3163 +#ifdef CONFIG_PAX_KERNEXEC
3164 + . = ALIGN(1<<SECTION_SHIFT);
3165 +#endif
3166 +
3167 .text : { /* Real text segment */
3168 _stext = .; /* Text and read-only data */
3169 __exception_text_start = .;
3170 @@ -112,6 +121,8 @@ SECTIONS
3171 ARM_CPU_KEEP(PROC_INFO)
3172 }
3173
3174 + _etext = .; /* End of text section */
3175 +
3176 RO_DATA(PAGE_SIZE)
3177
3178 . = ALIGN(4);
3179 @@ -142,7 +153,9 @@ SECTIONS
3180
3181 NOTES
3182
3183 - _etext = .; /* End of text and rodata section */
3184 +#ifdef CONFIG_PAX_KERNEXEC
3185 + . = ALIGN(1<<SECTION_SHIFT);
3186 +#endif
3187
3188 #ifndef CONFIG_XIP_KERNEL
3189 . = ALIGN(PAGE_SIZE);
3190 @@ -220,6 +233,11 @@ SECTIONS
3191 . = PAGE_OFFSET + TEXT_OFFSET;
3192 #else
3193 __init_end = .;
3194 +
3195 +#ifdef CONFIG_PAX_KERNEXEC
3196 + . = ALIGN(1<<SECTION_SHIFT);
3197 +#endif
3198 +
3199 . = ALIGN(THREAD_SIZE);
3200 __data_loc = .;
3201 #endif
3202 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3203 index 741f66a..8a5615c 100644
3204 --- a/arch/arm/kvm/arm.c
3205 +++ b/arch/arm/kvm/arm.c
3206 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3207 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3208
3209 /* The VMID used in the VTTBR */
3210 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3211 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3212 static u8 kvm_next_vmid;
3213 static DEFINE_SPINLOCK(kvm_vmid_lock);
3214
3215 @@ -392,7 +392,7 @@ void force_vm_exit(const cpumask_t *mask)
3216 */
3217 static bool need_new_vmid_gen(struct kvm *kvm)
3218 {
3219 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3220 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3221 }
3222
3223 /**
3224 @@ -425,7 +425,7 @@ static void update_vttbr(struct kvm *kvm)
3225
3226 /* First user of a new VMID generation? */
3227 if (unlikely(kvm_next_vmid == 0)) {
3228 - atomic64_inc(&kvm_vmid_gen);
3229 + atomic64_inc_unchecked(&kvm_vmid_gen);
3230 kvm_next_vmid = 1;
3231
3232 /*
3233 @@ -442,7 +442,7 @@ static void update_vttbr(struct kvm *kvm)
3234 kvm_call_hyp(__kvm_flush_vm_context);
3235 }
3236
3237 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3238 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3239 kvm->arch.vmid = kvm_next_vmid;
3240 kvm_next_vmid++;
3241
3242 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3243 index 14a0d98..7771a7d 100644
3244 --- a/arch/arm/lib/clear_user.S
3245 +++ b/arch/arm/lib/clear_user.S
3246 @@ -12,14 +12,14 @@
3247
3248 .text
3249
3250 -/* Prototype: int __clear_user(void *addr, size_t sz)
3251 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3252 * Purpose : clear some user memory
3253 * Params : addr - user memory address to clear
3254 * : sz - number of bytes to clear
3255 * Returns : number of bytes NOT cleared
3256 */
3257 ENTRY(__clear_user_std)
3258 -WEAK(__clear_user)
3259 +WEAK(___clear_user)
3260 stmfd sp!, {r1, lr}
3261 mov r2, #0
3262 cmp r1, #4
3263 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3264 USER( strnebt r2, [r0])
3265 mov r0, #0
3266 ldmfd sp!, {r1, pc}
3267 -ENDPROC(__clear_user)
3268 +ENDPROC(___clear_user)
3269 ENDPROC(__clear_user_std)
3270
3271 .pushsection .fixup,"ax"
3272 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3273 index 66a477a..bee61d3 100644
3274 --- a/arch/arm/lib/copy_from_user.S
3275 +++ b/arch/arm/lib/copy_from_user.S
3276 @@ -16,7 +16,7 @@
3277 /*
3278 * Prototype:
3279 *
3280 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3281 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3282 *
3283 * Purpose:
3284 *
3285 @@ -84,11 +84,11 @@
3286
3287 .text
3288
3289 -ENTRY(__copy_from_user)
3290 +ENTRY(___copy_from_user)
3291
3292 #include "copy_template.S"
3293
3294 -ENDPROC(__copy_from_user)
3295 +ENDPROC(___copy_from_user)
3296
3297 .pushsection .fixup,"ax"
3298 .align 0
3299 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3300 index 6ee2f67..d1cce76 100644
3301 --- a/arch/arm/lib/copy_page.S
3302 +++ b/arch/arm/lib/copy_page.S
3303 @@ -10,6 +10,7 @@
3304 * ASM optimised string functions
3305 */
3306 #include <linux/linkage.h>
3307 +#include <linux/const.h>
3308 #include <asm/assembler.h>
3309 #include <asm/asm-offsets.h>
3310 #include <asm/cache.h>
3311 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3312 index d066df6..df28194 100644
3313 --- a/arch/arm/lib/copy_to_user.S
3314 +++ b/arch/arm/lib/copy_to_user.S
3315 @@ -16,7 +16,7 @@
3316 /*
3317 * Prototype:
3318 *
3319 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3320 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3321 *
3322 * Purpose:
3323 *
3324 @@ -88,11 +88,11 @@
3325 .text
3326
3327 ENTRY(__copy_to_user_std)
3328 -WEAK(__copy_to_user)
3329 +WEAK(___copy_to_user)
3330
3331 #include "copy_template.S"
3332
3333 -ENDPROC(__copy_to_user)
3334 +ENDPROC(___copy_to_user)
3335 ENDPROC(__copy_to_user_std)
3336
3337 .pushsection .fixup,"ax"
3338 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3339 index 7d08b43..f7ca7ea 100644
3340 --- a/arch/arm/lib/csumpartialcopyuser.S
3341 +++ b/arch/arm/lib/csumpartialcopyuser.S
3342 @@ -57,8 +57,8 @@
3343 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3344 */
3345
3346 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3347 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3348 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3349 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3350
3351 #include "csumpartialcopygeneric.S"
3352
3353 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3354 index 5306de3..aed6d03 100644
3355 --- a/arch/arm/lib/delay.c
3356 +++ b/arch/arm/lib/delay.c
3357 @@ -28,7 +28,7 @@
3358 /*
3359 * Default to the loop-based delay implementation.
3360 */
3361 -struct arm_delay_ops arm_delay_ops = {
3362 +struct arm_delay_ops arm_delay_ops __read_only = {
3363 .delay = __loop_delay,
3364 .const_udelay = __loop_const_udelay,
3365 .udelay = __loop_udelay,
3366 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3367 index 025f742..a9e5b3b 100644
3368 --- a/arch/arm/lib/uaccess_with_memcpy.c
3369 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3370 @@ -104,7 +104,7 @@ out:
3371 }
3372
3373 unsigned long
3374 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3375 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3376 {
3377 /*
3378 * This test is stubbed out of the main function above to keep
3379 @@ -155,7 +155,7 @@ out:
3380 return n;
3381 }
3382
3383 -unsigned long __clear_user(void __user *addr, unsigned long n)
3384 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3385 {
3386 /* See rational for this in __copy_to_user() above. */
3387 if (n < 64)
3388 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3389 index e9238b5..6ed904a 100644
3390 --- a/arch/arm/mach-kirkwood/common.c
3391 +++ b/arch/arm/mach-kirkwood/common.c
3392 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3393 clk_gate_ops.disable(hw);
3394 }
3395
3396 -static struct clk_ops clk_gate_fn_ops;
3397 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3398 +{
3399 + return clk_gate_ops.is_enabled(hw);
3400 +}
3401 +
3402 +static struct clk_ops clk_gate_fn_ops = {
3403 + .enable = clk_gate_fn_enable,
3404 + .disable = clk_gate_fn_disable,
3405 + .is_enabled = clk_gate_fn_is_enabled,
3406 +};
3407
3408 static struct clk __init *clk_register_gate_fn(struct device *dev,
3409 const char *name,
3410 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3411 gate_fn->fn_en = fn_en;
3412 gate_fn->fn_dis = fn_dis;
3413
3414 - /* ops is the gate ops, but with our enable/disable functions */
3415 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3416 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3417 - clk_gate_fn_ops = clk_gate_ops;
3418 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3419 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3420 - }
3421 -
3422 clk = clk_register(dev, &gate_fn->gate.hw);
3423
3424 if (IS_ERR(clk))
3425 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3426 index 827d1500..2885dc6 100644
3427 --- a/arch/arm/mach-omap2/board-n8x0.c
3428 +++ b/arch/arm/mach-omap2/board-n8x0.c
3429 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3430 }
3431 #endif
3432
3433 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3434 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3435 .late_init = n8x0_menelaus_late_init,
3436 };
3437
3438 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3439 index f3fdd6a..3564800 100644
3440 --- a/arch/arm/mach-omap2/gpmc.c
3441 +++ b/arch/arm/mach-omap2/gpmc.c
3442 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3443 };
3444
3445 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3446 -static struct irq_chip gpmc_irq_chip;
3447 static unsigned gpmc_irq_start;
3448
3449 static struct resource gpmc_mem_root;
3450 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3451
3452 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3453
3454 +static struct irq_chip gpmc_irq_chip = {
3455 + .name = "gpmc",
3456 + .irq_startup = gpmc_irq_noop_ret,
3457 + .irq_enable = gpmc_irq_enable,
3458 + .irq_disable = gpmc_irq_disable,
3459 + .irq_shutdown = gpmc_irq_noop,
3460 + .irq_ack = gpmc_irq_noop,
3461 + .irq_mask = gpmc_irq_noop,
3462 + .irq_unmask = gpmc_irq_noop,
3463 +
3464 +};
3465 +
3466 static int gpmc_setup_irq(void)
3467 {
3468 int i;
3469 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3470 return gpmc_irq_start;
3471 }
3472
3473 - gpmc_irq_chip.name = "gpmc";
3474 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3475 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3476 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3477 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3478 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3479 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3480 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3481 -
3482 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3483 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3484
3485 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3486 index f991016..145ebeb 100644
3487 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3488 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3489 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3490 int (*finish_suspend)(unsigned long cpu_state);
3491 void (*resume)(void);
3492 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3493 -};
3494 +} __no_const;
3495
3496 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3497 static struct powerdomain *mpuss_pd;
3498 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3499 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3500 {}
3501
3502 -struct cpu_pm_ops omap_pm_ops = {
3503 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3504 .finish_suspend = default_finish_suspend,
3505 .resume = dummy_cpu_resume,
3506 .scu_prepare = dummy_scu_prepare,
3507 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3508 index 813c615..ce467c6 100644
3509 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3510 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3511 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3512 return NOTIFY_OK;
3513 }
3514
3515 -static struct notifier_block __refdata irq_hotplug_notifier = {
3516 +static struct notifier_block irq_hotplug_notifier = {
3517 .notifier_call = irq_cpu_hotplug_notify,
3518 };
3519
3520 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3521 index f99f68e..e573e20 100644
3522 --- a/arch/arm/mach-omap2/omap_device.c
3523 +++ b/arch/arm/mach-omap2/omap_device.c
3524 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3525 struct platform_device __init *omap_device_build(const char *pdev_name,
3526 int pdev_id,
3527 struct omap_hwmod *oh,
3528 - void *pdata, int pdata_len)
3529 + const void *pdata, int pdata_len)
3530 {
3531 struct omap_hwmod *ohs[] = { oh };
3532
3533 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3534 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3535 int pdev_id,
3536 struct omap_hwmod **ohs,
3537 - int oh_cnt, void *pdata,
3538 + int oh_cnt, const void *pdata,
3539 int pdata_len)
3540 {
3541 int ret = -ENOMEM;
3542 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3543 index 17ca1ae..beba869 100644
3544 --- a/arch/arm/mach-omap2/omap_device.h
3545 +++ b/arch/arm/mach-omap2/omap_device.h
3546 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3547 /* Core code interface */
3548
3549 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3550 - struct omap_hwmod *oh, void *pdata,
3551 + struct omap_hwmod *oh, const void *pdata,
3552 int pdata_len);
3553
3554 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3555 struct omap_hwmod **oh, int oh_cnt,
3556 - void *pdata, int pdata_len);
3557 + const void *pdata, int pdata_len);
3558
3559 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3560 struct omap_hwmod **ohs, int oh_cnt);
3561 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3562 index 7f4db12..0243012 100644
3563 --- a/arch/arm/mach-omap2/omap_hwmod.c
3564 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3565 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3566 int (*init_clkdm)(struct omap_hwmod *oh);
3567 void (*update_context_lost)(struct omap_hwmod *oh);
3568 int (*get_context_lost)(struct omap_hwmod *oh);
3569 -};
3570 +} __no_const;
3571
3572 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3573 -static struct omap_hwmod_soc_ops soc_ops;
3574 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3575
3576 /* omap_hwmod_list contains all registered struct omap_hwmods */
3577 static LIST_HEAD(omap_hwmod_list);
3578 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3579 index d15c7bb..b2d1f0c 100644
3580 --- a/arch/arm/mach-omap2/wd_timer.c
3581 +++ b/arch/arm/mach-omap2/wd_timer.c
3582 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3583 struct omap_hwmod *oh;
3584 char *oh_name = "wd_timer2";
3585 char *dev_name = "omap_wdt";
3586 - struct omap_wd_timer_platform_data pdata;
3587 + static struct omap_wd_timer_platform_data pdata = {
3588 + .read_reset_sources = prm_read_reset_sources
3589 + };
3590
3591 if (!cpu_class_is_omap2() || of_have_populated_dt())
3592 return 0;
3593 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3594 return -EINVAL;
3595 }
3596
3597 - pdata.read_reset_sources = prm_read_reset_sources;
3598 -
3599 pdev = omap_device_build(dev_name, id, oh, &pdata,
3600 sizeof(struct omap_wd_timer_platform_data));
3601 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3602 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3603 index 706aa42..f85e9131 100644
3604 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3605 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3606 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3607 bool entered_lp2 = false;
3608
3609 if (tegra_pending_sgi())
3610 - ACCESS_ONCE(abort_flag) = true;
3611 + ACCESS_ONCE_RW(abort_flag) = true;
3612
3613 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3614
3615 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3616 index cad3ca86..1d79e0f 100644
3617 --- a/arch/arm/mach-ux500/setup.h
3618 +++ b/arch/arm/mach-ux500/setup.h
3619 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3620 .type = MT_DEVICE, \
3621 }
3622
3623 -#define __MEM_DEV_DESC(x, sz) { \
3624 - .virtual = IO_ADDRESS(x), \
3625 - .pfn = __phys_to_pfn(x), \
3626 - .length = sz, \
3627 - .type = MT_MEMORY, \
3628 -}
3629 -
3630 extern struct smp_operations ux500_smp_ops;
3631 extern void ux500_cpu_die(unsigned int cpu);
3632
3633 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3634 index cd2c88e..7430282 100644
3635 --- a/arch/arm/mm/Kconfig
3636 +++ b/arch/arm/mm/Kconfig
3637 @@ -446,7 +446,7 @@ config CPU_32v5
3638
3639 config CPU_32v6
3640 bool
3641 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3642 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3643 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3644
3645 config CPU_32v6K
3646 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3647
3648 config CPU_USE_DOMAINS
3649 bool
3650 + depends on !ARM_LPAE && !PAX_KERNEXEC
3651 help
3652 This option enables or disables the use of domain switching
3653 via the set_fs() function.
3654 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3655 config KUSER_HELPERS
3656 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3657 default y
3658 + depends on !(CPU_V6 || CPU_V6K || CPU_V7)
3659 help
3660 Warning: disabling this option may break user programs.
3661
3662 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3663 See Documentation/arm/kernel_user_helpers.txt for details.
3664
3665 However, the fixed address nature of these helpers can be used
3666 - by ROP (return orientated programming) authors when creating
3667 + by ROP (Return Oriented Programming) authors when creating
3668 exploits.
3669
3670 If all of the binaries and libraries which run on your platform
3671 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3672 index 6f4585b..7b6f52b 100644
3673 --- a/arch/arm/mm/alignment.c
3674 +++ b/arch/arm/mm/alignment.c
3675 @@ -211,10 +211,12 @@ union offset_union {
3676 #define __get16_unaligned_check(ins,val,addr) \
3677 do { \
3678 unsigned int err = 0, v, a = addr; \
3679 + pax_open_userland(); \
3680 __get8_unaligned_check(ins,v,a,err); \
3681 val = v << ((BE) ? 8 : 0); \
3682 __get8_unaligned_check(ins,v,a,err); \
3683 val |= v << ((BE) ? 0 : 8); \
3684 + pax_close_userland(); \
3685 if (err) \
3686 goto fault; \
3687 } while (0)
3688 @@ -228,6 +230,7 @@ union offset_union {
3689 #define __get32_unaligned_check(ins,val,addr) \
3690 do { \
3691 unsigned int err = 0, v, a = addr; \
3692 + pax_open_userland(); \
3693 __get8_unaligned_check(ins,v,a,err); \
3694 val = v << ((BE) ? 24 : 0); \
3695 __get8_unaligned_check(ins,v,a,err); \
3696 @@ -236,6 +239,7 @@ union offset_union {
3697 val |= v << ((BE) ? 8 : 16); \
3698 __get8_unaligned_check(ins,v,a,err); \
3699 val |= v << ((BE) ? 0 : 24); \
3700 + pax_close_userland(); \
3701 if (err) \
3702 goto fault; \
3703 } while (0)
3704 @@ -249,6 +253,7 @@ union offset_union {
3705 #define __put16_unaligned_check(ins,val,addr) \
3706 do { \
3707 unsigned int err = 0, v = val, a = addr; \
3708 + pax_open_userland(); \
3709 __asm__( FIRST_BYTE_16 \
3710 ARM( "1: "ins" %1, [%2], #1\n" ) \
3711 THUMB( "1: "ins" %1, [%2]\n" ) \
3712 @@ -268,6 +273,7 @@ union offset_union {
3713 " .popsection\n" \
3714 : "=r" (err), "=&r" (v), "=&r" (a) \
3715 : "0" (err), "1" (v), "2" (a)); \
3716 + pax_close_userland(); \
3717 if (err) \
3718 goto fault; \
3719 } while (0)
3720 @@ -281,6 +287,7 @@ union offset_union {
3721 #define __put32_unaligned_check(ins,val,addr) \
3722 do { \
3723 unsigned int err = 0, v = val, a = addr; \
3724 + pax_open_userland(); \
3725 __asm__( FIRST_BYTE_32 \
3726 ARM( "1: "ins" %1, [%2], #1\n" ) \
3727 THUMB( "1: "ins" %1, [%2]\n" ) \
3728 @@ -310,6 +317,7 @@ union offset_union {
3729 " .popsection\n" \
3730 : "=r" (err), "=&r" (v), "=&r" (a) \
3731 : "0" (err), "1" (v), "2" (a)); \
3732 + pax_close_userland(); \
3733 if (err) \
3734 goto fault; \
3735 } while (0)
3736 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3737 index 4a05444..d21968c 100644
3738 --- a/arch/arm/mm/context.c
3739 +++ b/arch/arm/mm/context.c
3740 @@ -43,7 +43,7 @@
3741 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3742
3743 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3744 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3745 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3746 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3747
3748 static DEFINE_PER_CPU(atomic64_t, active_asids);
3749 @@ -183,7 +183,7 @@ static int is_reserved_asid(u64 asid)
3750 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3751 {
3752 u64 asid = atomic64_read(&mm->context.id);
3753 - u64 generation = atomic64_read(&asid_generation);
3754 + u64 generation = atomic64_read_unchecked(&asid_generation);
3755
3756 if (asid != 0 && is_reserved_asid(asid)) {
3757 /*
3758 @@ -201,7 +201,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3759 */
3760 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3761 if (asid == NUM_USER_ASIDS) {
3762 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3763 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3764 &asid_generation);
3765 flush_context(cpu);
3766 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3767 @@ -230,14 +230,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3768 cpu_set_reserved_ttbr0();
3769
3770 asid = atomic64_read(&mm->context.id);
3771 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3772 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3773 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3774 goto switch_mm_fastpath;
3775
3776 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3777 /* Check that our ASID belongs to the current generation. */
3778 asid = atomic64_read(&mm->context.id);
3779 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3780 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3781 asid = new_context(mm, cpu);
3782 atomic64_set(&mm->context.id, asid);
3783 }
3784 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3785 index c97f794..6461880 100644
3786 --- a/arch/arm/mm/fault.c
3787 +++ b/arch/arm/mm/fault.c
3788 @@ -25,6 +25,7 @@
3789 #include <asm/system_misc.h>
3790 #include <asm/system_info.h>
3791 #include <asm/tlbflush.h>
3792 +#include <asm/sections.h>
3793
3794 #include "fault.h"
3795
3796 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3797 if (fixup_exception(regs))
3798 return;
3799
3800 +#ifdef CONFIG_PAX_KERNEXEC
3801 + if ((fsr & FSR_WRITE) &&
3802 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3803 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3804 + {
3805 + if (current->signal->curr_ip)
3806 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3807 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3808 + else
3809 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3810 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3811 + }
3812 +#endif
3813 +
3814 /*
3815 * No handler, we'll have to terminate things with extreme prejudice.
3816 */
3817 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3818 }
3819 #endif
3820
3821 +#ifdef CONFIG_PAX_PAGEEXEC
3822 + if (fsr & FSR_LNX_PF) {
3823 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3824 + do_group_exit(SIGKILL);
3825 + }
3826 +#endif
3827 +
3828 tsk->thread.address = addr;
3829 tsk->thread.error_code = fsr;
3830 tsk->thread.trap_no = 14;
3831 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3832 }
3833 #endif /* CONFIG_MMU */
3834
3835 +#ifdef CONFIG_PAX_PAGEEXEC
3836 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3837 +{
3838 + long i;
3839 +
3840 + printk(KERN_ERR "PAX: bytes at PC: ");
3841 + for (i = 0; i < 20; i++) {
3842 + unsigned char c;
3843 + if (get_user(c, (__force unsigned char __user *)pc+i))
3844 + printk(KERN_CONT "?? ");
3845 + else
3846 + printk(KERN_CONT "%02x ", c);
3847 + }
3848 + printk("\n");
3849 +
3850 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3851 + for (i = -1; i < 20; i++) {
3852 + unsigned long c;
3853 + if (get_user(c, (__force unsigned long __user *)sp+i))
3854 + printk(KERN_CONT "???????? ");
3855 + else
3856 + printk(KERN_CONT "%08lx ", c);
3857 + }
3858 + printk("\n");
3859 +}
3860 +#endif
3861 +
3862 /*
3863 * First Level Translation Fault Handler
3864 *
3865 @@ -545,9 +594,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3866 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3867 struct siginfo info;
3868
3869 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3870 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3871 + if (current->signal->curr_ip)
3872 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3873 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3874 + else
3875 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3876 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3877 + goto die;
3878 + }
3879 +#endif
3880 +
3881 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3882 return;
3883
3884 +die:
3885 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3886 inf->name, fsr, addr);
3887
3888 @@ -571,15 +633,92 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3889 ifsr_info[nr].name = name;
3890 }
3891
3892 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3893 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3894 +
3895 asmlinkage void __exception
3896 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3897 {
3898 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3899 struct siginfo info;
3900 + unsigned long pc = instruction_pointer(regs);
3901 +
3902 + if (user_mode(regs)) {
3903 + unsigned long sigpage = current->mm->context.sigpage;
3904 +
3905 + if (sigpage <= pc && pc < sigpage + 7*4) {
3906 + if (pc < sigpage + 3*4)
3907 + sys_sigreturn(regs);
3908 + else
3909 + sys_rt_sigreturn(regs);
3910 + return;
3911 + }
3912 + if (pc == 0xffff0f60UL) {
3913 + /*
3914 + * PaX: __kuser_cmpxchg64 emulation
3915 + */
3916 + // TODO
3917 + //regs->ARM_pc = regs->ARM_lr;
3918 + //return;
3919 + }
3920 + if (pc == 0xffff0fa0UL) {
3921 + /*
3922 + * PaX: __kuser_memory_barrier emulation
3923 + */
3924 + // dmb(); implied by the exception
3925 + regs->ARM_pc = regs->ARM_lr;
3926 + return;
3927 + }
3928 + if (pc == 0xffff0fc0UL) {
3929 + /*
3930 + * PaX: __kuser_cmpxchg emulation
3931 + */
3932 + // TODO
3933 + //regs->ARM_pc = regs->ARM_lr;
3934 + //return;
3935 + }
3936 + if (pc == 0xffff0fe0UL) {
3937 + /*
3938 + * PaX: __kuser_get_tls emulation
3939 + */
3940 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3941 + regs->ARM_pc = regs->ARM_lr;
3942 + return;
3943 + }
3944 + }
3945 +
3946 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3947 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3948 + if (current->signal->curr_ip)
3949 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3950 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3951 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3952 + else
3953 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3954 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3955 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3956 + goto die;
3957 + }
3958 +#endif
3959 +
3960 +#ifdef CONFIG_PAX_REFCOUNT
3961 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3962 + unsigned int bkpt;
3963 +
3964 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3965 + current->thread.error_code = ifsr;
3966 + current->thread.trap_no = 0;
3967 + pax_report_refcount_overflow(regs);
3968 + fixup_exception(regs);
3969 + return;
3970 + }
3971 + }
3972 +#endif
3973
3974 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3975 return;
3976
3977 +die:
3978 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3979 inf->name, ifsr, addr);
3980
3981 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3982 index cf08bdf..772656c 100644
3983 --- a/arch/arm/mm/fault.h
3984 +++ b/arch/arm/mm/fault.h
3985 @@ -3,6 +3,7 @@
3986
3987 /*
3988 * Fault status register encodings. We steal bit 31 for our own purposes.
3989 + * Set when the FSR value is from an instruction fault.
3990 */
3991 #define FSR_LNX_PF (1 << 31)
3992 #define FSR_WRITE (1 << 11)
3993 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3994 }
3995 #endif
3996
3997 +/* valid for LPAE and !LPAE */
3998 +static inline int is_xn_fault(unsigned int fsr)
3999 +{
4000 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4001 +}
4002 +
4003 +static inline int is_domain_fault(unsigned int fsr)
4004 +{
4005 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4006 +}
4007 +
4008 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4009 unsigned long search_exception_table(unsigned long addr);
4010
4011 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4012 index 15225d8..25e2e3c 100644
4013 --- a/arch/arm/mm/init.c
4014 +++ b/arch/arm/mm/init.c
4015 @@ -30,6 +30,8 @@
4016 #include <asm/setup.h>
4017 #include <asm/tlb.h>
4018 #include <asm/fixmap.h>
4019 +#include <asm/system_info.h>
4020 +#include <asm/cp15.h>
4021
4022 #include <asm/mach/arch.h>
4023 #include <asm/mach/map.h>
4024 @@ -683,7 +685,46 @@ void free_initmem(void)
4025 {
4026 #ifdef CONFIG_HAVE_TCM
4027 extern char __tcm_start, __tcm_end;
4028 +#endif
4029
4030 +#ifdef CONFIG_PAX_KERNEXEC
4031 + unsigned long addr;
4032 + pgd_t *pgd;
4033 + pud_t *pud;
4034 + pmd_t *pmd;
4035 + int cpu_arch = cpu_architecture();
4036 + unsigned int cr = get_cr();
4037 +
4038 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4039 + /* make pages tables, etc before .text NX */
4040 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4041 + pgd = pgd_offset_k(addr);
4042 + pud = pud_offset(pgd, addr);
4043 + pmd = pmd_offset(pud, addr);
4044 + __section_update(pmd, addr, PMD_SECT_XN);
4045 + }
4046 + /* make init NX */
4047 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4048 + pgd = pgd_offset_k(addr);
4049 + pud = pud_offset(pgd, addr);
4050 + pmd = pmd_offset(pud, addr);
4051 + __section_update(pmd, addr, PMD_SECT_XN);
4052 + }
4053 + /* make kernel code/rodata RX */
4054 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4055 + pgd = pgd_offset_k(addr);
4056 + pud = pud_offset(pgd, addr);
4057 + pmd = pmd_offset(pud, addr);
4058 +#ifdef CONFIG_ARM_LPAE
4059 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4060 +#else
4061 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4062 +#endif
4063 + }
4064 + }
4065 +#endif
4066 +
4067 +#ifdef CONFIG_HAVE_TCM
4068 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4069 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4070 #endif
4071 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4072 index f123d6e..04bf569 100644
4073 --- a/arch/arm/mm/ioremap.c
4074 +++ b/arch/arm/mm/ioremap.c
4075 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4076 unsigned int mtype;
4077
4078 if (cached)
4079 - mtype = MT_MEMORY;
4080 + mtype = MT_MEMORY_RX;
4081 else
4082 - mtype = MT_MEMORY_NONCACHED;
4083 + mtype = MT_MEMORY_NONCACHED_RX;
4084
4085 return __arm_ioremap_caller(phys_addr, size, mtype,
4086 __builtin_return_address(0));
4087 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4088 index 0c63562..7128a90 100644
4089 --- a/arch/arm/mm/mmap.c
4090 +++ b/arch/arm/mm/mmap.c
4091 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4092 struct vm_area_struct *vma;
4093 int do_align = 0;
4094 int aliasing = cache_is_vipt_aliasing();
4095 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4096 struct vm_unmapped_area_info info;
4097
4098 /*
4099 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4100 if (len > TASK_SIZE)
4101 return -ENOMEM;
4102
4103 +#ifdef CONFIG_PAX_RANDMMAP
4104 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4105 +#endif
4106 +
4107 if (addr) {
4108 if (do_align)
4109 addr = COLOUR_ALIGN(addr, pgoff);
4110 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4111 addr = PAGE_ALIGN(addr);
4112
4113 vma = find_vma(mm, addr);
4114 - if (TASK_SIZE - len >= addr &&
4115 - (!vma || addr + len <= vma->vm_start))
4116 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4117 return addr;
4118 }
4119
4120 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4121 info.high_limit = TASK_SIZE;
4122 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4123 info.align_offset = pgoff << PAGE_SHIFT;
4124 + info.threadstack_offset = offset;
4125 return vm_unmapped_area(&info);
4126 }
4127
4128 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4129 unsigned long addr = addr0;
4130 int do_align = 0;
4131 int aliasing = cache_is_vipt_aliasing();
4132 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4133 struct vm_unmapped_area_info info;
4134
4135 /*
4136 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4137 return addr;
4138 }
4139
4140 +#ifdef CONFIG_PAX_RANDMMAP
4141 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4142 +#endif
4143 +
4144 /* requesting a specific address */
4145 if (addr) {
4146 if (do_align)
4147 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4148 else
4149 addr = PAGE_ALIGN(addr);
4150 vma = find_vma(mm, addr);
4151 - if (TASK_SIZE - len >= addr &&
4152 - (!vma || addr + len <= vma->vm_start))
4153 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4154 return addr;
4155 }
4156
4157 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4158 info.high_limit = mm->mmap_base;
4159 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4160 info.align_offset = pgoff << PAGE_SHIFT;
4161 + info.threadstack_offset = offset;
4162 addr = vm_unmapped_area(&info);
4163
4164 /*
4165 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4166 {
4167 unsigned long random_factor = 0UL;
4168
4169 +#ifdef CONFIG_PAX_RANDMMAP
4170 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4171 +#endif
4172 +
4173 /* 8 bits of randomness in 20 address space bits */
4174 if ((current->flags & PF_RANDOMIZE) &&
4175 !(current->personality & ADDR_NO_RANDOMIZE))
4176 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4177
4178 if (mmap_is_legacy()) {
4179 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4180 +
4181 +#ifdef CONFIG_PAX_RANDMMAP
4182 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4183 + mm->mmap_base += mm->delta_mmap;
4184 +#endif
4185 +
4186 mm->get_unmapped_area = arch_get_unmapped_area;
4187 } else {
4188 mm->mmap_base = mmap_base(random_factor);
4189 +
4190 +#ifdef CONFIG_PAX_RANDMMAP
4191 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4192 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4193 +#endif
4194 +
4195 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4196 }
4197 }
4198 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4199 index 53cdbd3..670f177 100644
4200 --- a/arch/arm/mm/mmu.c
4201 +++ b/arch/arm/mm/mmu.c
4202 @@ -36,6 +36,22 @@
4203 #include "mm.h"
4204 #include "tcm.h"
4205
4206 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4207 +void modify_domain(unsigned int dom, unsigned int type)
4208 +{
4209 + struct thread_info *thread = current_thread_info();
4210 + unsigned int domain = thread->cpu_domain;
4211 + /*
4212 + * DOMAIN_MANAGER might be defined to some other value,
4213 + * use the arch-defined constant
4214 + */
4215 + domain &= ~domain_val(dom, 3);
4216 + thread->cpu_domain = domain | domain_val(dom, type);
4217 + set_domain(thread->cpu_domain);
4218 +}
4219 +EXPORT_SYMBOL(modify_domain);
4220 +#endif
4221 +
4222 /*
4223 * empty_zero_page is a special page that is used for
4224 * zero-initialized data and COW.
4225 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4226
4227 #endif /* ifdef CONFIG_CPU_CP15 / else */
4228
4229 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4230 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4231 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4232
4233 -static struct mem_type mem_types[] = {
4234 +#ifdef CONFIG_PAX_KERNEXEC
4235 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4236 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4237 +#else
4238 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4239 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4240 +#endif
4241 +
4242 +static struct mem_type mem_types[] __read_only = {
4243 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4244 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4245 L_PTE_SHARED,
4246 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4247 [MT_UNCACHED] = {
4248 .prot_pte = PROT_PTE_DEVICE,
4249 .prot_l1 = PMD_TYPE_TABLE,
4250 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4251 + .prot_sect = PROT_SECT_DEVICE,
4252 .domain = DOMAIN_IO,
4253 },
4254 [MT_CACHECLEAN] = {
4255 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4256 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4257 .domain = DOMAIN_KERNEL,
4258 },
4259 #ifndef CONFIG_ARM_LPAE
4260 [MT_MINICLEAN] = {
4261 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4262 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4263 .domain = DOMAIN_KERNEL,
4264 },
4265 #endif
4266 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4267 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4268 L_PTE_RDONLY,
4269 .prot_l1 = PMD_TYPE_TABLE,
4270 - .domain = DOMAIN_USER,
4271 + .domain = DOMAIN_VECTORS,
4272 },
4273 [MT_HIGH_VECTORS] = {
4274 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4275 L_PTE_USER | L_PTE_RDONLY,
4276 .prot_l1 = PMD_TYPE_TABLE,
4277 - .domain = DOMAIN_USER,
4278 + .domain = DOMAIN_VECTORS,
4279 },
4280 - [MT_MEMORY] = {
4281 + [MT_MEMORY_RWX] = {
4282 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4283 .prot_l1 = PMD_TYPE_TABLE,
4284 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4285 .domain = DOMAIN_KERNEL,
4286 },
4287 + [MT_MEMORY_RW] = {
4288 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4289 + .prot_l1 = PMD_TYPE_TABLE,
4290 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4291 + .domain = DOMAIN_KERNEL,
4292 + },
4293 + [MT_MEMORY_RX] = {
4294 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4295 + .prot_l1 = PMD_TYPE_TABLE,
4296 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4297 + .domain = DOMAIN_KERNEL,
4298 + },
4299 [MT_ROM] = {
4300 - .prot_sect = PMD_TYPE_SECT,
4301 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4302 .domain = DOMAIN_KERNEL,
4303 },
4304 - [MT_MEMORY_NONCACHED] = {
4305 + [MT_MEMORY_NONCACHED_RW] = {
4306 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4307 L_PTE_MT_BUFFERABLE,
4308 .prot_l1 = PMD_TYPE_TABLE,
4309 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4310 .domain = DOMAIN_KERNEL,
4311 },
4312 + [MT_MEMORY_NONCACHED_RX] = {
4313 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4314 + L_PTE_MT_BUFFERABLE,
4315 + .prot_l1 = PMD_TYPE_TABLE,
4316 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4317 + .domain = DOMAIN_KERNEL,
4318 + },
4319 [MT_MEMORY_DTCM] = {
4320 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4321 - L_PTE_XN,
4322 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4323 .prot_l1 = PMD_TYPE_TABLE,
4324 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4325 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4326 .domain = DOMAIN_KERNEL,
4327 },
4328 [MT_MEMORY_ITCM] = {
4329 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4330 },
4331 [MT_MEMORY_SO] = {
4332 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4333 - L_PTE_MT_UNCACHED | L_PTE_XN,
4334 + L_PTE_MT_UNCACHED,
4335 .prot_l1 = PMD_TYPE_TABLE,
4336 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4337 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4338 + PMD_SECT_UNCACHED,
4339 .domain = DOMAIN_KERNEL,
4340 },
4341 [MT_MEMORY_DMA_READY] = {
4342 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4343 * to prevent speculative instruction fetches.
4344 */
4345 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4346 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4347 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4348 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4349 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4350 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4351 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4352 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4353 +
4354 + /* Mark other regions on ARMv6+ as execute-never */
4355 +
4356 +#ifdef CONFIG_PAX_KERNEXEC
4357 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4358 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4359 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4360 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4361 +#ifndef CONFIG_ARM_LPAE
4362 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4363 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4364 +#endif
4365 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4366 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4367 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4368 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4369 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4370 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4371 +#endif
4372 +
4373 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4374 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4375 }
4376 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4377 /*
4378 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4379 * from SVC mode and no access from userspace.
4380 */
4381 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4382 +#ifdef CONFIG_PAX_KERNEXEC
4383 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4384 +#endif
4385 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4386 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4387 #endif
4388 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4389 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4390 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4391 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4392 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4393 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4394 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4395 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4396 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4397 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4398 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4399 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4400 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4401 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4402 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4403 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4404 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4405 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4406 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4407 }
4408 }
4409
4410 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4411 if (cpu_arch >= CPU_ARCH_ARMv6) {
4412 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4413 /* Non-cacheable Normal is XCB = 001 */
4414 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4415 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4416 + PMD_SECT_BUFFERED;
4417 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4418 PMD_SECT_BUFFERED;
4419 } else {
4420 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4421 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4422 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4423 + PMD_SECT_TEX(1);
4424 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4425 PMD_SECT_TEX(1);
4426 }
4427 } else {
4428 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4429 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4430 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4431 }
4432
4433 #ifdef CONFIG_ARM_LPAE
4434 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4435 vecs_pgprot |= PTE_EXT_AF;
4436 #endif
4437
4438 + user_pgprot |= __supported_pte_mask;
4439 +
4440 for (i = 0; i < 16; i++) {
4441 pteval_t v = pgprot_val(protection_map[i]);
4442 protection_map[i] = __pgprot(v | user_pgprot);
4443 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4444
4445 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4446 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4447 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4448 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4449 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4450 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4451 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4452 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4453 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4454 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4455 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4456 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4457 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4458 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4459 mem_types[MT_ROM].prot_sect |= cp->pmd;
4460
4461 switch (cp->pmd) {
4462 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4463 * called function. This means you can't use any function or debugging
4464 * method which may touch any device, otherwise the kernel _will_ crash.
4465 */
4466 +
4467 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4468 +
4469 static void __init devicemaps_init(struct machine_desc *mdesc)
4470 {
4471 struct map_desc map;
4472 unsigned long addr;
4473 - void *vectors;
4474
4475 - /*
4476 - * Allocate the vector page early.
4477 - */
4478 - vectors = early_alloc(PAGE_SIZE * 2);
4479 -
4480 - early_trap_init(vectors);
4481 + early_trap_init(&vectors);
4482
4483 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4484 pmd_clear(pmd_off_k(addr));
4485 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4486 * location (0xffff0000). If we aren't using high-vectors, also
4487 * create a mapping at the low-vectors virtual address.
4488 */
4489 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4490 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4491 map.virtual = 0xffff0000;
4492 map.length = PAGE_SIZE;
4493 #ifdef CONFIG_KUSER_HELPERS
4494 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4495 map.pfn = __phys_to_pfn(start);
4496 map.virtual = __phys_to_virt(start);
4497 map.length = end - start;
4498 - map.type = MT_MEMORY;
4499
4500 +#ifdef CONFIG_PAX_KERNEXEC
4501 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4502 + struct map_desc kernel;
4503 + struct map_desc initmap;
4504 +
4505 + /* when freeing initmem we will make this RW */
4506 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4507 + initmap.virtual = (unsigned long)__init_begin;
4508 + initmap.length = _sdata - __init_begin;
4509 + initmap.type = MT_MEMORY_RWX;
4510 + create_mapping(&initmap);
4511 +
4512 + /* when freeing initmem we will make this RX */
4513 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4514 + kernel.virtual = (unsigned long)_stext;
4515 + kernel.length = __init_begin - _stext;
4516 + kernel.type = MT_MEMORY_RWX;
4517 + create_mapping(&kernel);
4518 +
4519 + if (map.virtual < (unsigned long)_stext) {
4520 + map.length = (unsigned long)_stext - map.virtual;
4521 + map.type = MT_MEMORY_RWX;
4522 + create_mapping(&map);
4523 + }
4524 +
4525 + map.pfn = __phys_to_pfn(__pa(_sdata));
4526 + map.virtual = (unsigned long)_sdata;
4527 + map.length = end - __pa(_sdata);
4528 + }
4529 +#endif
4530 +
4531 + map.type = MT_MEMORY_RW;
4532 create_mapping(&map);
4533 }
4534 }
4535 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4536 index a5bc92d..0bb4730 100644
4537 --- a/arch/arm/plat-omap/sram.c
4538 +++ b/arch/arm/plat-omap/sram.c
4539 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4540 * Looks like we need to preserve some bootloader code at the
4541 * beginning of SRAM for jumping to flash for reboot to work...
4542 */
4543 + pax_open_kernel();
4544 memset_io(omap_sram_base + omap_sram_skip, 0,
4545 omap_sram_size - omap_sram_skip);
4546 + pax_close_kernel();
4547 }
4548 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4549 index ce6d763..cfea917 100644
4550 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4551 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4552 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4553 int (*started)(unsigned ch);
4554 int (*flush)(unsigned ch);
4555 int (*stop)(unsigned ch);
4556 -};
4557 +} __no_const;
4558
4559 extern void *samsung_dmadev_get_ops(void);
4560 extern void *s3c_dma_get_ops(void);
4561 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4562 index c3a58a1..78fbf54 100644
4563 --- a/arch/avr32/include/asm/cache.h
4564 +++ b/arch/avr32/include/asm/cache.h
4565 @@ -1,8 +1,10 @@
4566 #ifndef __ASM_AVR32_CACHE_H
4567 #define __ASM_AVR32_CACHE_H
4568
4569 +#include <linux/const.h>
4570 +
4571 #define L1_CACHE_SHIFT 5
4572 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4573 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4574
4575 /*
4576 * Memory returned by kmalloc() may be used for DMA, so we must make
4577 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4578 index d232888..87c8df1 100644
4579 --- a/arch/avr32/include/asm/elf.h
4580 +++ b/arch/avr32/include/asm/elf.h
4581 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4582 the loader. We need to make sure that it is out of the way of the program
4583 that it will "exec", and that there is sufficient room for the brk. */
4584
4585 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4586 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4587
4588 +#ifdef CONFIG_PAX_ASLR
4589 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4590 +
4591 +#define PAX_DELTA_MMAP_LEN 15
4592 +#define PAX_DELTA_STACK_LEN 15
4593 +#endif
4594
4595 /* This yields a mask that user programs can use to figure out what
4596 instruction set this CPU supports. This could be done in user space,
4597 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4598 index 479330b..53717a8 100644
4599 --- a/arch/avr32/include/asm/kmap_types.h
4600 +++ b/arch/avr32/include/asm/kmap_types.h
4601 @@ -2,9 +2,9 @@
4602 #define __ASM_AVR32_KMAP_TYPES_H
4603
4604 #ifdef CONFIG_DEBUG_HIGHMEM
4605 -# define KM_TYPE_NR 29
4606 +# define KM_TYPE_NR 30
4607 #else
4608 -# define KM_TYPE_NR 14
4609 +# define KM_TYPE_NR 15
4610 #endif
4611
4612 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4613 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4614 index b2f2d2d..d1c85cb 100644
4615 --- a/arch/avr32/mm/fault.c
4616 +++ b/arch/avr32/mm/fault.c
4617 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4618
4619 int exception_trace = 1;
4620
4621 +#ifdef CONFIG_PAX_PAGEEXEC
4622 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4623 +{
4624 + unsigned long i;
4625 +
4626 + printk(KERN_ERR "PAX: bytes at PC: ");
4627 + for (i = 0; i < 20; i++) {
4628 + unsigned char c;
4629 + if (get_user(c, (unsigned char *)pc+i))
4630 + printk(KERN_CONT "???????? ");
4631 + else
4632 + printk(KERN_CONT "%02x ", c);
4633 + }
4634 + printk("\n");
4635 +}
4636 +#endif
4637 +
4638 /*
4639 * This routine handles page faults. It determines the address and the
4640 * problem, and then passes it off to one of the appropriate routines.
4641 @@ -174,6 +191,16 @@ bad_area:
4642 up_read(&mm->mmap_sem);
4643
4644 if (user_mode(regs)) {
4645 +
4646 +#ifdef CONFIG_PAX_PAGEEXEC
4647 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4648 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4649 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4650 + do_group_exit(SIGKILL);
4651 + }
4652 + }
4653 +#endif
4654 +
4655 if (exception_trace && printk_ratelimit())
4656 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4657 "sp %08lx ecr %lu\n",
4658 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4659 index 568885a..f8008df 100644
4660 --- a/arch/blackfin/include/asm/cache.h
4661 +++ b/arch/blackfin/include/asm/cache.h
4662 @@ -7,6 +7,7 @@
4663 #ifndef __ARCH_BLACKFIN_CACHE_H
4664 #define __ARCH_BLACKFIN_CACHE_H
4665
4666 +#include <linux/const.h>
4667 #include <linux/linkage.h> /* for asmlinkage */
4668
4669 /*
4670 @@ -14,7 +15,7 @@
4671 * Blackfin loads 32 bytes for cache
4672 */
4673 #define L1_CACHE_SHIFT 5
4674 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4675 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4676 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4677
4678 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4679 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4680 index aea2718..3639a60 100644
4681 --- a/arch/cris/include/arch-v10/arch/cache.h
4682 +++ b/arch/cris/include/arch-v10/arch/cache.h
4683 @@ -1,8 +1,9 @@
4684 #ifndef _ASM_ARCH_CACHE_H
4685 #define _ASM_ARCH_CACHE_H
4686
4687 +#include <linux/const.h>
4688 /* Etrax 100LX have 32-byte cache-lines. */
4689 -#define L1_CACHE_BYTES 32
4690 #define L1_CACHE_SHIFT 5
4691 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4692
4693 #endif /* _ASM_ARCH_CACHE_H */
4694 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4695 index 7caf25d..ee65ac5 100644
4696 --- a/arch/cris/include/arch-v32/arch/cache.h
4697 +++ b/arch/cris/include/arch-v32/arch/cache.h
4698 @@ -1,11 +1,12 @@
4699 #ifndef _ASM_CRIS_ARCH_CACHE_H
4700 #define _ASM_CRIS_ARCH_CACHE_H
4701
4702 +#include <linux/const.h>
4703 #include <arch/hwregs/dma.h>
4704
4705 /* A cache-line is 32 bytes. */
4706 -#define L1_CACHE_BYTES 32
4707 #define L1_CACHE_SHIFT 5
4708 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4709
4710 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4711
4712 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4713 index b86329d..6709906 100644
4714 --- a/arch/frv/include/asm/atomic.h
4715 +++ b/arch/frv/include/asm/atomic.h
4716 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4717 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4718 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4719
4720 +#define atomic64_read_unchecked(v) atomic64_read(v)
4721 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4722 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4723 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4724 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4725 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4726 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4727 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4728 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4729 +
4730 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4731 {
4732 int c, old;
4733 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4734 index 2797163..c2a401d 100644
4735 --- a/arch/frv/include/asm/cache.h
4736 +++ b/arch/frv/include/asm/cache.h
4737 @@ -12,10 +12,11 @@
4738 #ifndef __ASM_CACHE_H
4739 #define __ASM_CACHE_H
4740
4741 +#include <linux/const.h>
4742
4743 /* bytes per L1 cache line */
4744 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4745 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4746 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4747
4748 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4749 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4750 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4751 index 43901f2..0d8b865 100644
4752 --- a/arch/frv/include/asm/kmap_types.h
4753 +++ b/arch/frv/include/asm/kmap_types.h
4754 @@ -2,6 +2,6 @@
4755 #ifndef _ASM_KMAP_TYPES_H
4756 #define _ASM_KMAP_TYPES_H
4757
4758 -#define KM_TYPE_NR 17
4759 +#define KM_TYPE_NR 18
4760
4761 #endif
4762 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4763 index 836f147..4cf23f5 100644
4764 --- a/arch/frv/mm/elf-fdpic.c
4765 +++ b/arch/frv/mm/elf-fdpic.c
4766 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4767 {
4768 struct vm_area_struct *vma;
4769 struct vm_unmapped_area_info info;
4770 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4771
4772 if (len > TASK_SIZE)
4773 return -ENOMEM;
4774 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4775 if (addr) {
4776 addr = PAGE_ALIGN(addr);
4777 vma = find_vma(current->mm, addr);
4778 - if (TASK_SIZE - len >= addr &&
4779 - (!vma || addr + len <= vma->vm_start))
4780 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4781 goto success;
4782 }
4783
4784 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4785 info.high_limit = (current->mm->start_stack - 0x00200000);
4786 info.align_mask = 0;
4787 info.align_offset = 0;
4788 + info.threadstack_offset = offset;
4789 addr = vm_unmapped_area(&info);
4790 if (!(addr & ~PAGE_MASK))
4791 goto success;
4792 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4793 index f4ca594..adc72fd6 100644
4794 --- a/arch/hexagon/include/asm/cache.h
4795 +++ b/arch/hexagon/include/asm/cache.h
4796 @@ -21,9 +21,11 @@
4797 #ifndef __ASM_CACHE_H
4798 #define __ASM_CACHE_H
4799
4800 +#include <linux/const.h>
4801 +
4802 /* Bytes per L1 cache line */
4803 -#define L1_CACHE_SHIFT (5)
4804 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4805 +#define L1_CACHE_SHIFT 5
4806 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4807
4808 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4809 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4810 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4811 index 6e6fe18..a6ae668 100644
4812 --- a/arch/ia64/include/asm/atomic.h
4813 +++ b/arch/ia64/include/asm/atomic.h
4814 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4815 #define atomic64_inc(v) atomic64_add(1, (v))
4816 #define atomic64_dec(v) atomic64_sub(1, (v))
4817
4818 +#define atomic64_read_unchecked(v) atomic64_read(v)
4819 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4820 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4821 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4822 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4823 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4824 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4825 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4826 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4827 +
4828 /* Atomic operations are already serializing */
4829 #define smp_mb__before_atomic_dec() barrier()
4830 #define smp_mb__after_atomic_dec() barrier()
4831 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4832 index 988254a..e1ee885 100644
4833 --- a/arch/ia64/include/asm/cache.h
4834 +++ b/arch/ia64/include/asm/cache.h
4835 @@ -1,6 +1,7 @@
4836 #ifndef _ASM_IA64_CACHE_H
4837 #define _ASM_IA64_CACHE_H
4838
4839 +#include <linux/const.h>
4840
4841 /*
4842 * Copyright (C) 1998-2000 Hewlett-Packard Co
4843 @@ -9,7 +10,7 @@
4844
4845 /* Bytes per L1 (data) cache line. */
4846 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4847 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4848 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4849
4850 #ifdef CONFIG_SMP
4851 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4852 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4853 index 5a83c5c..4d7f553 100644
4854 --- a/arch/ia64/include/asm/elf.h
4855 +++ b/arch/ia64/include/asm/elf.h
4856 @@ -42,6 +42,13 @@
4857 */
4858 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4859
4860 +#ifdef CONFIG_PAX_ASLR
4861 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4862 +
4863 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4864 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4865 +#endif
4866 +
4867 #define PT_IA_64_UNWIND 0x70000001
4868
4869 /* IA-64 relocations: */
4870 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4871 index 96a8d92..617a1cf 100644
4872 --- a/arch/ia64/include/asm/pgalloc.h
4873 +++ b/arch/ia64/include/asm/pgalloc.h
4874 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4875 pgd_val(*pgd_entry) = __pa(pud);
4876 }
4877
4878 +static inline void
4879 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4880 +{
4881 + pgd_populate(mm, pgd_entry, pud);
4882 +}
4883 +
4884 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4885 {
4886 return quicklist_alloc(0, GFP_KERNEL, NULL);
4887 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4888 pud_val(*pud_entry) = __pa(pmd);
4889 }
4890
4891 +static inline void
4892 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4893 +{
4894 + pud_populate(mm, pud_entry, pmd);
4895 +}
4896 +
4897 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4898 {
4899 return quicklist_alloc(0, GFP_KERNEL, NULL);
4900 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4901 index 7935115..c0eca6a 100644
4902 --- a/arch/ia64/include/asm/pgtable.h
4903 +++ b/arch/ia64/include/asm/pgtable.h
4904 @@ -12,7 +12,7 @@
4905 * David Mosberger-Tang <davidm@hpl.hp.com>
4906 */
4907
4908 -
4909 +#include <linux/const.h>
4910 #include <asm/mman.h>
4911 #include <asm/page.h>
4912 #include <asm/processor.h>
4913 @@ -142,6 +142,17 @@
4914 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4915 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4916 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4917 +
4918 +#ifdef CONFIG_PAX_PAGEEXEC
4919 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4920 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4921 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4922 +#else
4923 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4924 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4925 +# define PAGE_COPY_NOEXEC PAGE_COPY
4926 +#endif
4927 +
4928 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4929 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4930 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4931 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4932 index 54ff557..70c88b7 100644
4933 --- a/arch/ia64/include/asm/spinlock.h
4934 +++ b/arch/ia64/include/asm/spinlock.h
4935 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4936 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4937
4938 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4939 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4940 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4941 }
4942
4943 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4944 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4945 index 449c8c0..18965fb 100644
4946 --- a/arch/ia64/include/asm/uaccess.h
4947 +++ b/arch/ia64/include/asm/uaccess.h
4948 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4949 static inline unsigned long
4950 __copy_to_user (void __user *to, const void *from, unsigned long count)
4951 {
4952 + if (count > INT_MAX)
4953 + return count;
4954 +
4955 + if (!__builtin_constant_p(count))
4956 + check_object_size(from, count, true);
4957 +
4958 return __copy_user(to, (__force void __user *) from, count);
4959 }
4960
4961 static inline unsigned long
4962 __copy_from_user (void *to, const void __user *from, unsigned long count)
4963 {
4964 + if (count > INT_MAX)
4965 + return count;
4966 +
4967 + if (!__builtin_constant_p(count))
4968 + check_object_size(to, count, false);
4969 +
4970 return __copy_user((__force void __user *) to, from, count);
4971 }
4972
4973 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4974 ({ \
4975 void __user *__cu_to = (to); \
4976 const void *__cu_from = (from); \
4977 - long __cu_len = (n); \
4978 + unsigned long __cu_len = (n); \
4979 \
4980 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4981 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4982 + if (!__builtin_constant_p(n)) \
4983 + check_object_size(__cu_from, __cu_len, true); \
4984 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4985 + } \
4986 __cu_len; \
4987 })
4988
4989 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4990 ({ \
4991 void *__cu_to = (to); \
4992 const void __user *__cu_from = (from); \
4993 - long __cu_len = (n); \
4994 + unsigned long __cu_len = (n); \
4995 \
4996 __chk_user_ptr(__cu_from); \
4997 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4998 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4999 + if (!__builtin_constant_p(n)) \
5000 + check_object_size(__cu_to, __cu_len, false); \
5001 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5002 + } \
5003 __cu_len; \
5004 })
5005
5006 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5007 index 24603be..948052d 100644
5008 --- a/arch/ia64/kernel/module.c
5009 +++ b/arch/ia64/kernel/module.c
5010 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5011 void
5012 module_free (struct module *mod, void *module_region)
5013 {
5014 - if (mod && mod->arch.init_unw_table &&
5015 - module_region == mod->module_init) {
5016 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5017 unw_remove_unwind_table(mod->arch.init_unw_table);
5018 mod->arch.init_unw_table = NULL;
5019 }
5020 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5021 }
5022
5023 static inline int
5024 +in_init_rx (const struct module *mod, uint64_t addr)
5025 +{
5026 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5027 +}
5028 +
5029 +static inline int
5030 +in_init_rw (const struct module *mod, uint64_t addr)
5031 +{
5032 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5033 +}
5034 +
5035 +static inline int
5036 in_init (const struct module *mod, uint64_t addr)
5037 {
5038 - return addr - (uint64_t) mod->module_init < mod->init_size;
5039 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5040 +}
5041 +
5042 +static inline int
5043 +in_core_rx (const struct module *mod, uint64_t addr)
5044 +{
5045 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5046 +}
5047 +
5048 +static inline int
5049 +in_core_rw (const struct module *mod, uint64_t addr)
5050 +{
5051 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5052 }
5053
5054 static inline int
5055 in_core (const struct module *mod, uint64_t addr)
5056 {
5057 - return addr - (uint64_t) mod->module_core < mod->core_size;
5058 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5059 }
5060
5061 static inline int
5062 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5063 break;
5064
5065 case RV_BDREL:
5066 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5067 + if (in_init_rx(mod, val))
5068 + val -= (uint64_t) mod->module_init_rx;
5069 + else if (in_init_rw(mod, val))
5070 + val -= (uint64_t) mod->module_init_rw;
5071 + else if (in_core_rx(mod, val))
5072 + val -= (uint64_t) mod->module_core_rx;
5073 + else if (in_core_rw(mod, val))
5074 + val -= (uint64_t) mod->module_core_rw;
5075 break;
5076
5077 case RV_LTV:
5078 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5079 * addresses have been selected...
5080 */
5081 uint64_t gp;
5082 - if (mod->core_size > MAX_LTOFF)
5083 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5084 /*
5085 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5086 * at the end of the module.
5087 */
5088 - gp = mod->core_size - MAX_LTOFF / 2;
5089 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5090 else
5091 - gp = mod->core_size / 2;
5092 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5093 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5094 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5095 mod->arch.gp = gp;
5096 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5097 }
5098 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5099 index ab33328..f39506c 100644
5100 --- a/arch/ia64/kernel/palinfo.c
5101 +++ b/arch/ia64/kernel/palinfo.c
5102 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5103 return NOTIFY_OK;
5104 }
5105
5106 -static struct notifier_block __refdata palinfo_cpu_notifier =
5107 +static struct notifier_block palinfo_cpu_notifier =
5108 {
5109 .notifier_call = palinfo_cpu_callback,
5110 .priority = 0,
5111 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5112 index 41e33f8..65180b2 100644
5113 --- a/arch/ia64/kernel/sys_ia64.c
5114 +++ b/arch/ia64/kernel/sys_ia64.c
5115 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5116 unsigned long align_mask = 0;
5117 struct mm_struct *mm = current->mm;
5118 struct vm_unmapped_area_info info;
5119 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5120
5121 if (len > RGN_MAP_LIMIT)
5122 return -ENOMEM;
5123 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5124 if (REGION_NUMBER(addr) == RGN_HPAGE)
5125 addr = 0;
5126 #endif
5127 +
5128 +#ifdef CONFIG_PAX_RANDMMAP
5129 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5130 + addr = mm->free_area_cache;
5131 + else
5132 +#endif
5133 +
5134 if (!addr)
5135 addr = TASK_UNMAPPED_BASE;
5136
5137 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5138 info.high_limit = TASK_SIZE;
5139 info.align_mask = align_mask;
5140 info.align_offset = 0;
5141 + info.threadstack_offset = offset;
5142 return vm_unmapped_area(&info);
5143 }
5144
5145 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5146 index 0ccb28f..8992469 100644
5147 --- a/arch/ia64/kernel/vmlinux.lds.S
5148 +++ b/arch/ia64/kernel/vmlinux.lds.S
5149 @@ -198,7 +198,7 @@ SECTIONS {
5150 /* Per-cpu data: */
5151 . = ALIGN(PERCPU_PAGE_SIZE);
5152 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5153 - __phys_per_cpu_start = __per_cpu_load;
5154 + __phys_per_cpu_start = per_cpu_load;
5155 /*
5156 * ensure percpu data fits
5157 * into percpu page size
5158 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5159 index 6cf0341..d352594 100644
5160 --- a/arch/ia64/mm/fault.c
5161 +++ b/arch/ia64/mm/fault.c
5162 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5163 return pte_present(pte);
5164 }
5165
5166 +#ifdef CONFIG_PAX_PAGEEXEC
5167 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5168 +{
5169 + unsigned long i;
5170 +
5171 + printk(KERN_ERR "PAX: bytes at PC: ");
5172 + for (i = 0; i < 8; i++) {
5173 + unsigned int c;
5174 + if (get_user(c, (unsigned int *)pc+i))
5175 + printk(KERN_CONT "???????? ");
5176 + else
5177 + printk(KERN_CONT "%08x ", c);
5178 + }
5179 + printk("\n");
5180 +}
5181 +#endif
5182 +
5183 # define VM_READ_BIT 0
5184 # define VM_WRITE_BIT 1
5185 # define VM_EXEC_BIT 2
5186 @@ -149,8 +166,21 @@ retry:
5187 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5188 goto bad_area;
5189
5190 - if ((vma->vm_flags & mask) != mask)
5191 + if ((vma->vm_flags & mask) != mask) {
5192 +
5193 +#ifdef CONFIG_PAX_PAGEEXEC
5194 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5195 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5196 + goto bad_area;
5197 +
5198 + up_read(&mm->mmap_sem);
5199 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5200 + do_group_exit(SIGKILL);
5201 + }
5202 +#endif
5203 +
5204 goto bad_area;
5205 + }
5206
5207 /*
5208 * If for any reason at all we couldn't handle the fault, make
5209 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5210 index 76069c1..c2aa816 100644
5211 --- a/arch/ia64/mm/hugetlbpage.c
5212 +++ b/arch/ia64/mm/hugetlbpage.c
5213 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5214 unsigned long pgoff, unsigned long flags)
5215 {
5216 struct vm_unmapped_area_info info;
5217 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5218
5219 if (len > RGN_MAP_LIMIT)
5220 return -ENOMEM;
5221 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5222 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5223 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5224 info.align_offset = 0;
5225 + info.threadstack_offset = offset;
5226 return vm_unmapped_area(&info);
5227 }
5228
5229 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5230 index b6f7f43..c04320d 100644
5231 --- a/arch/ia64/mm/init.c
5232 +++ b/arch/ia64/mm/init.c
5233 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5234 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5235 vma->vm_end = vma->vm_start + PAGE_SIZE;
5236 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5237 +
5238 +#ifdef CONFIG_PAX_PAGEEXEC
5239 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5240 + vma->vm_flags &= ~VM_EXEC;
5241 +
5242 +#ifdef CONFIG_PAX_MPROTECT
5243 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5244 + vma->vm_flags &= ~VM_MAYEXEC;
5245 +#endif
5246 +
5247 + }
5248 +#endif
5249 +
5250 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5251 down_write(&current->mm->mmap_sem);
5252 if (insert_vm_struct(current->mm, vma)) {
5253 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5254 index 40b3ee9..8c2c112 100644
5255 --- a/arch/m32r/include/asm/cache.h
5256 +++ b/arch/m32r/include/asm/cache.h
5257 @@ -1,8 +1,10 @@
5258 #ifndef _ASM_M32R_CACHE_H
5259 #define _ASM_M32R_CACHE_H
5260
5261 +#include <linux/const.h>
5262 +
5263 /* L1 cache line size */
5264 #define L1_CACHE_SHIFT 4
5265 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5266 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5267
5268 #endif /* _ASM_M32R_CACHE_H */
5269 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5270 index 82abd15..d95ae5d 100644
5271 --- a/arch/m32r/lib/usercopy.c
5272 +++ b/arch/m32r/lib/usercopy.c
5273 @@ -14,6 +14,9 @@
5274 unsigned long
5275 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5276 {
5277 + if ((long)n < 0)
5278 + return n;
5279 +
5280 prefetch(from);
5281 if (access_ok(VERIFY_WRITE, to, n))
5282 __copy_user(to,from,n);
5283 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5284 unsigned long
5285 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5286 {
5287 + if ((long)n < 0)
5288 + return n;
5289 +
5290 prefetchw(to);
5291 if (access_ok(VERIFY_READ, from, n))
5292 __copy_user_zeroing(to,from,n);
5293 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5294 index 0395c51..5f26031 100644
5295 --- a/arch/m68k/include/asm/cache.h
5296 +++ b/arch/m68k/include/asm/cache.h
5297 @@ -4,9 +4,11 @@
5298 #ifndef __ARCH_M68K_CACHE_H
5299 #define __ARCH_M68K_CACHE_H
5300
5301 +#include <linux/const.h>
5302 +
5303 /* bytes per L1 cache line */
5304 #define L1_CACHE_SHIFT 4
5305 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5306 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5307
5308 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5309
5310 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5311 index 3c52fa6..11b2ad8 100644
5312 --- a/arch/metag/mm/hugetlbpage.c
5313 +++ b/arch/metag/mm/hugetlbpage.c
5314 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5315 info.high_limit = TASK_SIZE;
5316 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5317 info.align_offset = 0;
5318 + info.threadstack_offset = 0;
5319 return vm_unmapped_area(&info);
5320 }
5321
5322 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5323 index 4efe96a..60e8699 100644
5324 --- a/arch/microblaze/include/asm/cache.h
5325 +++ b/arch/microblaze/include/asm/cache.h
5326 @@ -13,11 +13,12 @@
5327 #ifndef _ASM_MICROBLAZE_CACHE_H
5328 #define _ASM_MICROBLAZE_CACHE_H
5329
5330 +#include <linux/const.h>
5331 #include <asm/registers.h>
5332
5333 #define L1_CACHE_SHIFT 5
5334 /* word-granular cache in microblaze */
5335 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5336 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5337
5338 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5339
5340 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5341 index 08b6079..8b554d2 100644
5342 --- a/arch/mips/include/asm/atomic.h
5343 +++ b/arch/mips/include/asm/atomic.h
5344 @@ -21,15 +21,39 @@
5345 #include <asm/cmpxchg.h>
5346 #include <asm/war.h>
5347
5348 +#ifdef CONFIG_GENERIC_ATOMIC64
5349 +#include <asm-generic/atomic64.h>
5350 +#endif
5351 +
5352 #define ATOMIC_INIT(i) { (i) }
5353
5354 +#ifdef CONFIG_64BIT
5355 +#define _ASM_EXTABLE(from, to) \
5356 +" .section __ex_table,\"a\"\n" \
5357 +" .dword " #from ", " #to"\n" \
5358 +" .previous\n"
5359 +#else
5360 +#define _ASM_EXTABLE(from, to) \
5361 +" .section __ex_table,\"a\"\n" \
5362 +" .word " #from ", " #to"\n" \
5363 +" .previous\n"
5364 +#endif
5365 +
5366 /*
5367 * atomic_read - read atomic variable
5368 * @v: pointer of type atomic_t
5369 *
5370 * Atomically reads the value of @v.
5371 */
5372 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5373 +static inline int atomic_read(const atomic_t *v)
5374 +{
5375 + return (*(volatile const int *) &v->counter);
5376 +}
5377 +
5378 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5379 +{
5380 + return (*(volatile const int *) &v->counter);
5381 +}
5382
5383 /*
5384 * atomic_set - set atomic variable
5385 @@ -38,7 +62,15 @@
5386 *
5387 * Atomically sets the value of @v to @i.
5388 */
5389 -#define atomic_set(v, i) ((v)->counter = (i))
5390 +static inline void atomic_set(atomic_t *v, int i)
5391 +{
5392 + v->counter = i;
5393 +}
5394 +
5395 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5396 +{
5397 + v->counter = i;
5398 +}
5399
5400 /*
5401 * atomic_add - add integer to atomic variable
5402 @@ -47,7 +79,67 @@
5403 *
5404 * Atomically adds @i to @v.
5405 */
5406 -static __inline__ void atomic_add(int i, atomic_t * v)
5407 +static __inline__ void atomic_add(int i, atomic_t *v)
5408 +{
5409 + int temp;
5410 +
5411 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5412 + __asm__ __volatile__(
5413 + " .set mips3 \n"
5414 + "1: ll %0, %1 # atomic_add \n"
5415 +#ifdef CONFIG_PAX_REFCOUNT
5416 + /* Exception on overflow. */
5417 + "2: add %0, %2 \n"
5418 +#else
5419 + " addu %0, %2 \n"
5420 +#endif
5421 + " sc %0, %1 \n"
5422 + " beqzl %0, 1b \n"
5423 +#ifdef CONFIG_PAX_REFCOUNT
5424 + "3: \n"
5425 + _ASM_EXTABLE(2b, 3b)
5426 +#endif
5427 + " .set mips0 \n"
5428 + : "=&r" (temp), "+m" (v->counter)
5429 + : "Ir" (i));
5430 + } else if (kernel_uses_llsc) {
5431 + __asm__ __volatile__(
5432 + " .set mips3 \n"
5433 + "1: ll %0, %1 # atomic_add \n"
5434 +#ifdef CONFIG_PAX_REFCOUNT
5435 + /* Exception on overflow. */
5436 + "2: add %0, %2 \n"
5437 +#else
5438 + " addu %0, %2 \n"
5439 +#endif
5440 + " sc %0, %1 \n"
5441 + " beqz %0, 1b \n"
5442 +#ifdef CONFIG_PAX_REFCOUNT
5443 + "3: \n"
5444 + _ASM_EXTABLE(2b, 3b)
5445 +#endif
5446 + " .set mips0 \n"
5447 + : "=&r" (temp), "+m" (v->counter)
5448 + : "Ir" (i));
5449 + } else {
5450 + unsigned long flags;
5451 +
5452 + raw_local_irq_save(flags);
5453 + __asm__ __volatile__(
5454 +#ifdef CONFIG_PAX_REFCOUNT
5455 + /* Exception on overflow. */
5456 + "1: add %0, %1 \n"
5457 + "2: \n"
5458 + _ASM_EXTABLE(1b, 2b)
5459 +#else
5460 + " addu %0, %1 \n"
5461 +#endif
5462 + : "+r" (v->counter) : "Ir" (i));
5463 + raw_local_irq_restore(flags);
5464 + }
5465 +}
5466 +
5467 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5468 {
5469 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5470 int temp;
5471 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5472 *
5473 * Atomically subtracts @i from @v.
5474 */
5475 -static __inline__ void atomic_sub(int i, atomic_t * v)
5476 +static __inline__ void atomic_sub(int i, atomic_t *v)
5477 +{
5478 + int temp;
5479 +
5480 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5481 + __asm__ __volatile__(
5482 + " .set mips3 \n"
5483 + "1: ll %0, %1 # atomic64_sub \n"
5484 +#ifdef CONFIG_PAX_REFCOUNT
5485 + /* Exception on overflow. */
5486 + "2: sub %0, %2 \n"
5487 +#else
5488 + " subu %0, %2 \n"
5489 +#endif
5490 + " sc %0, %1 \n"
5491 + " beqzl %0, 1b \n"
5492 +#ifdef CONFIG_PAX_REFCOUNT
5493 + "3: \n"
5494 + _ASM_EXTABLE(2b, 3b)
5495 +#endif
5496 + " .set mips0 \n"
5497 + : "=&r" (temp), "+m" (v->counter)
5498 + : "Ir" (i));
5499 + } else if (kernel_uses_llsc) {
5500 + __asm__ __volatile__(
5501 + " .set mips3 \n"
5502 + "1: ll %0, %1 # atomic64_sub \n"
5503 +#ifdef CONFIG_PAX_REFCOUNT
5504 + /* Exception on overflow. */
5505 + "2: sub %0, %2 \n"
5506 +#else
5507 + " subu %0, %2 \n"
5508 +#endif
5509 + " sc %0, %1 \n"
5510 + " beqz %0, 1b \n"
5511 +#ifdef CONFIG_PAX_REFCOUNT
5512 + "3: \n"
5513 + _ASM_EXTABLE(2b, 3b)
5514 +#endif
5515 + " .set mips0 \n"
5516 + : "=&r" (temp), "+m" (v->counter)
5517 + : "Ir" (i));
5518 + } else {
5519 + unsigned long flags;
5520 +
5521 + raw_local_irq_save(flags);
5522 + __asm__ __volatile__(
5523 +#ifdef CONFIG_PAX_REFCOUNT
5524 + /* Exception on overflow. */
5525 + "1: sub %0, %1 \n"
5526 + "2: \n"
5527 + _ASM_EXTABLE(1b, 2b)
5528 +#else
5529 + " subu %0, %1 \n"
5530 +#endif
5531 + : "+r" (v->counter) : "Ir" (i));
5532 + raw_local_irq_restore(flags);
5533 + }
5534 +}
5535 +
5536 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5537 {
5538 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5539 int temp;
5540 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5541 /*
5542 * Same as above, but return the result value
5543 */
5544 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5545 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5546 +{
5547 + int result;
5548 + int temp;
5549 +
5550 + smp_mb__before_llsc();
5551 +
5552 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5553 + __asm__ __volatile__(
5554 + " .set mips3 \n"
5555 + "1: ll %1, %2 # atomic_add_return \n"
5556 +#ifdef CONFIG_PAX_REFCOUNT
5557 + "2: add %0, %1, %3 \n"
5558 +#else
5559 + " addu %0, %1, %3 \n"
5560 +#endif
5561 + " sc %0, %2 \n"
5562 + " beqzl %0, 1b \n"
5563 +#ifdef CONFIG_PAX_REFCOUNT
5564 + " b 4f \n"
5565 + " .set noreorder \n"
5566 + "3: b 5f \n"
5567 + " move %0, %1 \n"
5568 + " .set reorder \n"
5569 + _ASM_EXTABLE(2b, 3b)
5570 +#endif
5571 + "4: addu %0, %1, %3 \n"
5572 +#ifdef CONFIG_PAX_REFCOUNT
5573 + "5: \n"
5574 +#endif
5575 + " .set mips0 \n"
5576 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5577 + : "Ir" (i));
5578 + } else if (kernel_uses_llsc) {
5579 + __asm__ __volatile__(
5580 + " .set mips3 \n"
5581 + "1: ll %1, %2 # atomic_add_return \n"
5582 +#ifdef CONFIG_PAX_REFCOUNT
5583 + "2: add %0, %1, %3 \n"
5584 +#else
5585 + " addu %0, %1, %3 \n"
5586 +#endif
5587 + " sc %0, %2 \n"
5588 + " bnez %0, 4f \n"
5589 + " b 1b \n"
5590 +#ifdef CONFIG_PAX_REFCOUNT
5591 + " .set noreorder \n"
5592 + "3: b 5f \n"
5593 + " move %0, %1 \n"
5594 + " .set reorder \n"
5595 + _ASM_EXTABLE(2b, 3b)
5596 +#endif
5597 + "4: addu %0, %1, %3 \n"
5598 +#ifdef CONFIG_PAX_REFCOUNT
5599 + "5: \n"
5600 +#endif
5601 + " .set mips0 \n"
5602 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5603 + : "Ir" (i));
5604 + } else {
5605 + unsigned long flags;
5606 +
5607 + raw_local_irq_save(flags);
5608 + __asm__ __volatile__(
5609 + " lw %0, %1 \n"
5610 +#ifdef CONFIG_PAX_REFCOUNT
5611 + /* Exception on overflow. */
5612 + "1: add %0, %2 \n"
5613 +#else
5614 + " addu %0, %2 \n"
5615 +#endif
5616 + " sw %0, %1 \n"
5617 +#ifdef CONFIG_PAX_REFCOUNT
5618 + /* Note: Dest reg is not modified on overflow */
5619 + "2: \n"
5620 + _ASM_EXTABLE(1b, 2b)
5621 +#endif
5622 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5623 + raw_local_irq_restore(flags);
5624 + }
5625 +
5626 + smp_llsc_mb();
5627 +
5628 + return result;
5629 +}
5630 +
5631 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5632 {
5633 int result;
5634
5635 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5636 return result;
5637 }
5638
5639 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5640 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5641 +{
5642 + int result;
5643 + int temp;
5644 +
5645 + smp_mb__before_llsc();
5646 +
5647 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5648 + __asm__ __volatile__(
5649 + " .set mips3 \n"
5650 + "1: ll %1, %2 # atomic_sub_return \n"
5651 +#ifdef CONFIG_PAX_REFCOUNT
5652 + "2: sub %0, %1, %3 \n"
5653 +#else
5654 + " subu %0, %1, %3 \n"
5655 +#endif
5656 + " sc %0, %2 \n"
5657 + " beqzl %0, 1b \n"
5658 +#ifdef CONFIG_PAX_REFCOUNT
5659 + " b 4f \n"
5660 + " .set noreorder \n"
5661 + "3: b 5f \n"
5662 + " move %0, %1 \n"
5663 + " .set reorder \n"
5664 + _ASM_EXTABLE(2b, 3b)
5665 +#endif
5666 + "4: subu %0, %1, %3 \n"
5667 +#ifdef CONFIG_PAX_REFCOUNT
5668 + "5: \n"
5669 +#endif
5670 + " .set mips0 \n"
5671 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5672 + : "Ir" (i), "m" (v->counter)
5673 + : "memory");
5674 + } else if (kernel_uses_llsc) {
5675 + __asm__ __volatile__(
5676 + " .set mips3 \n"
5677 + "1: ll %1, %2 # atomic_sub_return \n"
5678 +#ifdef CONFIG_PAX_REFCOUNT
5679 + "2: sub %0, %1, %3 \n"
5680 +#else
5681 + " subu %0, %1, %3 \n"
5682 +#endif
5683 + " sc %0, %2 \n"
5684 + " bnez %0, 4f \n"
5685 + " b 1b \n"
5686 +#ifdef CONFIG_PAX_REFCOUNT
5687 + " .set noreorder \n"
5688 + "3: b 5f \n"
5689 + " move %0, %1 \n"
5690 + " .set reorder \n"
5691 + _ASM_EXTABLE(2b, 3b)
5692 +#endif
5693 + "4: subu %0, %1, %3 \n"
5694 +#ifdef CONFIG_PAX_REFCOUNT
5695 + "5: \n"
5696 +#endif
5697 + " .set mips0 \n"
5698 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5699 + : "Ir" (i));
5700 + } else {
5701 + unsigned long flags;
5702 +
5703 + raw_local_irq_save(flags);
5704 + __asm__ __volatile__(
5705 + " lw %0, %1 \n"
5706 +#ifdef CONFIG_PAX_REFCOUNT
5707 + /* Exception on overflow. */
5708 + "1: sub %0, %2 \n"
5709 +#else
5710 + " subu %0, %2 \n"
5711 +#endif
5712 + " sw %0, %1 \n"
5713 +#ifdef CONFIG_PAX_REFCOUNT
5714 + /* Note: Dest reg is not modified on overflow */
5715 + "2: \n"
5716 + _ASM_EXTABLE(1b, 2b)
5717 +#endif
5718 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5719 + raw_local_irq_restore(flags);
5720 + }
5721 +
5722 + smp_llsc_mb();
5723 +
5724 + return result;
5725 +}
5726 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5727 {
5728 int result;
5729
5730 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5731 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5732 * The function returns the old value of @v minus @i.
5733 */
5734 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5735 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5736 {
5737 int result;
5738
5739 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5740 return result;
5741 }
5742
5743 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5744 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5745 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5746 +{
5747 + return cmpxchg(&v->counter, old, new);
5748 +}
5749 +
5750 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5751 + int new)
5752 +{
5753 + return cmpxchg(&(v->counter), old, new);
5754 +}
5755 +
5756 +static inline int atomic_xchg(atomic_t *v, int new)
5757 +{
5758 + return xchg(&v->counter, new);
5759 +}
5760 +
5761 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5762 +{
5763 + return xchg(&(v->counter), new);
5764 +}
5765
5766 /**
5767 * __atomic_add_unless - add unless the number is a given value
5768 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5769
5770 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5771 #define atomic_inc_return(v) atomic_add_return(1, (v))
5772 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5773 +{
5774 + return atomic_add_return_unchecked(1, v);
5775 +}
5776
5777 /*
5778 * atomic_sub_and_test - subtract value from variable and test result
5779 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5780 * other cases.
5781 */
5782 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5783 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5784 +{
5785 + return atomic_add_return_unchecked(1, v) == 0;
5786 +}
5787
5788 /*
5789 * atomic_dec_and_test - decrement by 1 and test
5790 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5791 * Atomically increments @v by 1.
5792 */
5793 #define atomic_inc(v) atomic_add(1, (v))
5794 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5795 +{
5796 + atomic_add_unchecked(1, v);
5797 +}
5798
5799 /*
5800 * atomic_dec - decrement and test
5801 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5802 * Atomically decrements @v by 1.
5803 */
5804 #define atomic_dec(v) atomic_sub(1, (v))
5805 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5806 +{
5807 + atomic_sub_unchecked(1, v);
5808 +}
5809
5810 /*
5811 * atomic_add_negative - add and test if negative
5812 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5813 * @v: pointer of type atomic64_t
5814 *
5815 */
5816 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5817 +static inline long atomic64_read(const atomic64_t *v)
5818 +{
5819 + return (*(volatile const long *) &v->counter);
5820 +}
5821 +
5822 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5823 +{
5824 + return (*(volatile const long *) &v->counter);
5825 +}
5826
5827 /*
5828 * atomic64_set - set atomic variable
5829 * @v: pointer of type atomic64_t
5830 * @i: required value
5831 */
5832 -#define atomic64_set(v, i) ((v)->counter = (i))
5833 +static inline void atomic64_set(atomic64_t *v, long i)
5834 +{
5835 + v->counter = i;
5836 +}
5837 +
5838 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5839 +{
5840 + v->counter = i;
5841 +}
5842
5843 /*
5844 * atomic64_add - add integer to atomic variable
5845 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5846 *
5847 * Atomically adds @i to @v.
5848 */
5849 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5850 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5851 +{
5852 + long temp;
5853 +
5854 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5855 + __asm__ __volatile__(
5856 + " .set mips3 \n"
5857 + "1: lld %0, %1 # atomic64_add \n"
5858 +#ifdef CONFIG_PAX_REFCOUNT
5859 + /* Exception on overflow. */
5860 + "2: dadd %0, %2 \n"
5861 +#else
5862 + " daddu %0, %2 \n"
5863 +#endif
5864 + " scd %0, %1 \n"
5865 + " beqzl %0, 1b \n"
5866 +#ifdef CONFIG_PAX_REFCOUNT
5867 + "3: \n"
5868 + _ASM_EXTABLE(2b, 3b)
5869 +#endif
5870 + " .set mips0 \n"
5871 + : "=&r" (temp), "+m" (v->counter)
5872 + : "Ir" (i));
5873 + } else if (kernel_uses_llsc) {
5874 + __asm__ __volatile__(
5875 + " .set mips3 \n"
5876 + "1: lld %0, %1 # atomic64_add \n"
5877 +#ifdef CONFIG_PAX_REFCOUNT
5878 + /* Exception on overflow. */
5879 + "2: dadd %0, %2 \n"
5880 +#else
5881 + " daddu %0, %2 \n"
5882 +#endif
5883 + " scd %0, %1 \n"
5884 + " beqz %0, 1b \n"
5885 +#ifdef CONFIG_PAX_REFCOUNT
5886 + "3: \n"
5887 + _ASM_EXTABLE(2b, 3b)
5888 +#endif
5889 + " .set mips0 \n"
5890 + : "=&r" (temp), "+m" (v->counter)
5891 + : "Ir" (i));
5892 + } else {
5893 + unsigned long flags;
5894 +
5895 + raw_local_irq_save(flags);
5896 + __asm__ __volatile__(
5897 +#ifdef CONFIG_PAX_REFCOUNT
5898 + /* Exception on overflow. */
5899 + "1: dadd %0, %1 \n"
5900 + "2: \n"
5901 + _ASM_EXTABLE(1b, 2b)
5902 +#else
5903 + " daddu %0, %1 \n"
5904 +#endif
5905 + : "+r" (v->counter) : "Ir" (i));
5906 + raw_local_irq_restore(flags);
5907 + }
5908 +}
5909 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5910 {
5911 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5912 long temp;
5913 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5914 *
5915 * Atomically subtracts @i from @v.
5916 */
5917 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5918 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5919 +{
5920 + long temp;
5921 +
5922 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5923 + __asm__ __volatile__(
5924 + " .set mips3 \n"
5925 + "1: lld %0, %1 # atomic64_sub \n"
5926 +#ifdef CONFIG_PAX_REFCOUNT
5927 + /* Exception on overflow. */
5928 + "2: dsub %0, %2 \n"
5929 +#else
5930 + " dsubu %0, %2 \n"
5931 +#endif
5932 + " scd %0, %1 \n"
5933 + " beqzl %0, 1b \n"
5934 +#ifdef CONFIG_PAX_REFCOUNT
5935 + "3: \n"
5936 + _ASM_EXTABLE(2b, 3b)
5937 +#endif
5938 + " .set mips0 \n"
5939 + : "=&r" (temp), "+m" (v->counter)
5940 + : "Ir" (i));
5941 + } else if (kernel_uses_llsc) {
5942 + __asm__ __volatile__(
5943 + " .set mips3 \n"
5944 + "1: lld %0, %1 # atomic64_sub \n"
5945 +#ifdef CONFIG_PAX_REFCOUNT
5946 + /* Exception on overflow. */
5947 + "2: dsub %0, %2 \n"
5948 +#else
5949 + " dsubu %0, %2 \n"
5950 +#endif
5951 + " scd %0, %1 \n"
5952 + " beqz %0, 1b \n"
5953 +#ifdef CONFIG_PAX_REFCOUNT
5954 + "3: \n"
5955 + _ASM_EXTABLE(2b, 3b)
5956 +#endif
5957 + " .set mips0 \n"
5958 + : "=&r" (temp), "+m" (v->counter)
5959 + : "Ir" (i));
5960 + } else {
5961 + unsigned long flags;
5962 +
5963 + raw_local_irq_save(flags);
5964 + __asm__ __volatile__(
5965 +#ifdef CONFIG_PAX_REFCOUNT
5966 + /* Exception on overflow. */
5967 + "1: dsub %0, %1 \n"
5968 + "2: \n"
5969 + _ASM_EXTABLE(1b, 2b)
5970 +#else
5971 + " dsubu %0, %1 \n"
5972 +#endif
5973 + : "+r" (v->counter) : "Ir" (i));
5974 + raw_local_irq_restore(flags);
5975 + }
5976 +}
5977 +
5978 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
5979 {
5980 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5981 long temp;
5982 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
5983 /*
5984 * Same as above, but return the result value
5985 */
5986 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
5987 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
5988 +{
5989 + long result;
5990 + long temp;
5991 +
5992 + smp_mb__before_llsc();
5993 +
5994 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5995 + __asm__ __volatile__(
5996 + " .set mips3 \n"
5997 + "1: lld %1, %2 # atomic64_add_return \n"
5998 +#ifdef CONFIG_PAX_REFCOUNT
5999 + "2: dadd %0, %1, %3 \n"
6000 +#else
6001 + " daddu %0, %1, %3 \n"
6002 +#endif
6003 + " scd %0, %2 \n"
6004 + " beqzl %0, 1b \n"
6005 +#ifdef CONFIG_PAX_REFCOUNT
6006 + " b 4f \n"
6007 + " .set noreorder \n"
6008 + "3: b 5f \n"
6009 + " move %0, %1 \n"
6010 + " .set reorder \n"
6011 + _ASM_EXTABLE(2b, 3b)
6012 +#endif
6013 + "4: daddu %0, %1, %3 \n"
6014 +#ifdef CONFIG_PAX_REFCOUNT
6015 + "5: \n"
6016 +#endif
6017 + " .set mips0 \n"
6018 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6019 + : "Ir" (i));
6020 + } else if (kernel_uses_llsc) {
6021 + __asm__ __volatile__(
6022 + " .set mips3 \n"
6023 + "1: lld %1, %2 # atomic64_add_return \n"
6024 +#ifdef CONFIG_PAX_REFCOUNT
6025 + "2: dadd %0, %1, %3 \n"
6026 +#else
6027 + " daddu %0, %1, %3 \n"
6028 +#endif
6029 + " scd %0, %2 \n"
6030 + " bnez %0, 4f \n"
6031 + " b 1b \n"
6032 +#ifdef CONFIG_PAX_REFCOUNT
6033 + " .set noreorder \n"
6034 + "3: b 5f \n"
6035 + " move %0, %1 \n"
6036 + " .set reorder \n"
6037 + _ASM_EXTABLE(2b, 3b)
6038 +#endif
6039 + "4: daddu %0, %1, %3 \n"
6040 +#ifdef CONFIG_PAX_REFCOUNT
6041 + "5: \n"
6042 +#endif
6043 + " .set mips0 \n"
6044 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6045 + : "Ir" (i), "m" (v->counter)
6046 + : "memory");
6047 + } else {
6048 + unsigned long flags;
6049 +
6050 + raw_local_irq_save(flags);
6051 + __asm__ __volatile__(
6052 + " ld %0, %1 \n"
6053 +#ifdef CONFIG_PAX_REFCOUNT
6054 + /* Exception on overflow. */
6055 + "1: dadd %0, %2 \n"
6056 +#else
6057 + " daddu %0, %2 \n"
6058 +#endif
6059 + " sd %0, %1 \n"
6060 +#ifdef CONFIG_PAX_REFCOUNT
6061 + /* Note: Dest reg is not modified on overflow */
6062 + "2: \n"
6063 + _ASM_EXTABLE(1b, 2b)
6064 +#endif
6065 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6066 + raw_local_irq_restore(flags);
6067 + }
6068 +
6069 + smp_llsc_mb();
6070 +
6071 + return result;
6072 +}
6073 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6074 {
6075 long result;
6076
6077 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6078 return result;
6079 }
6080
6081 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6082 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6083 +{
6084 + long result;
6085 + long temp;
6086 +
6087 + smp_mb__before_llsc();
6088 +
6089 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6090 + long temp;
6091 +
6092 + __asm__ __volatile__(
6093 + " .set mips3 \n"
6094 + "1: lld %1, %2 # atomic64_sub_return \n"
6095 +#ifdef CONFIG_PAX_REFCOUNT
6096 + "2: dsub %0, %1, %3 \n"
6097 +#else
6098 + " dsubu %0, %1, %3 \n"
6099 +#endif
6100 + " scd %0, %2 \n"
6101 + " beqzl %0, 1b \n"
6102 +#ifdef CONFIG_PAX_REFCOUNT
6103 + " b 4f \n"
6104 + " .set noreorder \n"
6105 + "3: b 5f \n"
6106 + " move %0, %1 \n"
6107 + " .set reorder \n"
6108 + _ASM_EXTABLE(2b, 3b)
6109 +#endif
6110 + "4: dsubu %0, %1, %3 \n"
6111 +#ifdef CONFIG_PAX_REFCOUNT
6112 + "5: \n"
6113 +#endif
6114 + " .set mips0 \n"
6115 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6116 + : "Ir" (i), "m" (v->counter)
6117 + : "memory");
6118 + } else if (kernel_uses_llsc) {
6119 + __asm__ __volatile__(
6120 + " .set mips3 \n"
6121 + "1: lld %1, %2 # atomic64_sub_return \n"
6122 +#ifdef CONFIG_PAX_REFCOUNT
6123 + "2: dsub %0, %1, %3 \n"
6124 +#else
6125 + " dsubu %0, %1, %3 \n"
6126 +#endif
6127 + " scd %0, %2 \n"
6128 + " bnez %0, 4f \n"
6129 + " b 1b \n"
6130 +#ifdef CONFIG_PAX_REFCOUNT
6131 + " .set noreorder \n"
6132 + "3: b 5f \n"
6133 + " move %0, %1 \n"
6134 + " .set reorder \n"
6135 + _ASM_EXTABLE(2b, 3b)
6136 +#endif
6137 + "4: dsubu %0, %1, %3 \n"
6138 +#ifdef CONFIG_PAX_REFCOUNT
6139 + "5: \n"
6140 +#endif
6141 + " .set mips0 \n"
6142 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6143 + : "Ir" (i), "m" (v->counter)
6144 + : "memory");
6145 + } else {
6146 + unsigned long flags;
6147 +
6148 + raw_local_irq_save(flags);
6149 + __asm__ __volatile__(
6150 + " ld %0, %1 \n"
6151 +#ifdef CONFIG_PAX_REFCOUNT
6152 + /* Exception on overflow. */
6153 + "1: dsub %0, %2 \n"
6154 +#else
6155 + " dsubu %0, %2 \n"
6156 +#endif
6157 + " sd %0, %1 \n"
6158 +#ifdef CONFIG_PAX_REFCOUNT
6159 + /* Note: Dest reg is not modified on overflow */
6160 + "2: \n"
6161 + _ASM_EXTABLE(1b, 2b)
6162 +#endif
6163 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6164 + raw_local_irq_restore(flags);
6165 + }
6166 +
6167 + smp_llsc_mb();
6168 +
6169 + return result;
6170 +}
6171 +
6172 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6173 {
6174 long result;
6175
6176 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6177 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6178 * The function returns the old value of @v minus @i.
6179 */
6180 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6181 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6182 {
6183 long result;
6184
6185 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6186 return result;
6187 }
6188
6189 -#define atomic64_cmpxchg(v, o, n) \
6190 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6191 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6192 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6193 +{
6194 + return cmpxchg(&v->counter, old, new);
6195 +}
6196 +
6197 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6198 + long new)
6199 +{
6200 + return cmpxchg(&(v->counter), old, new);
6201 +}
6202 +
6203 +static inline long atomic64_xchg(atomic64_t *v, long new)
6204 +{
6205 + return xchg(&v->counter, new);
6206 +}
6207 +
6208 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6209 +{
6210 + return xchg(&(v->counter), new);
6211 +}
6212
6213 /**
6214 * atomic64_add_unless - add unless the number is a given value
6215 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6216
6217 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6218 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6219 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6220
6221 /*
6222 * atomic64_sub_and_test - subtract value from variable and test result
6223 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6224 * other cases.
6225 */
6226 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6227 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6228
6229 /*
6230 * atomic64_dec_and_test - decrement by 1 and test
6231 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6232 * Atomically increments @v by 1.
6233 */
6234 #define atomic64_inc(v) atomic64_add(1, (v))
6235 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6236
6237 /*
6238 * atomic64_dec - decrement and test
6239 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6240 * Atomically decrements @v by 1.
6241 */
6242 #define atomic64_dec(v) atomic64_sub(1, (v))
6243 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6244
6245 /*
6246 * atomic64_add_negative - add and test if negative
6247 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6248 index b4db69f..8f3b093 100644
6249 --- a/arch/mips/include/asm/cache.h
6250 +++ b/arch/mips/include/asm/cache.h
6251 @@ -9,10 +9,11 @@
6252 #ifndef _ASM_CACHE_H
6253 #define _ASM_CACHE_H
6254
6255 +#include <linux/const.h>
6256 #include <kmalloc.h>
6257
6258 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6259 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6260 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6261
6262 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6263 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6264 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6265 index cf3ae24..238d22f 100644
6266 --- a/arch/mips/include/asm/elf.h
6267 +++ b/arch/mips/include/asm/elf.h
6268 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6269 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6270 #endif
6271
6272 +#ifdef CONFIG_PAX_ASLR
6273 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6274 +
6275 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6276 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6277 +#endif
6278 +
6279 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6280 struct linux_binprm;
6281 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6282 int uses_interp);
6283
6284 -struct mm_struct;
6285 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6286 -#define arch_randomize_brk arch_randomize_brk
6287 -
6288 #endif /* _ASM_ELF_H */
6289 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6290 index c1f6afa..38cc6e9 100644
6291 --- a/arch/mips/include/asm/exec.h
6292 +++ b/arch/mips/include/asm/exec.h
6293 @@ -12,6 +12,6 @@
6294 #ifndef _ASM_EXEC_H
6295 #define _ASM_EXEC_H
6296
6297 -extern unsigned long arch_align_stack(unsigned long sp);
6298 +#define arch_align_stack(x) ((x) & ~0xfUL)
6299
6300 #endif /* _ASM_EXEC_H */
6301 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6302 index d44622c..64990d2 100644
6303 --- a/arch/mips/include/asm/local.h
6304 +++ b/arch/mips/include/asm/local.h
6305 @@ -12,15 +12,25 @@ typedef struct
6306 atomic_long_t a;
6307 } local_t;
6308
6309 +typedef struct {
6310 + atomic_long_unchecked_t a;
6311 +} local_unchecked_t;
6312 +
6313 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6314
6315 #define local_read(l) atomic_long_read(&(l)->a)
6316 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6317 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6318 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6319
6320 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6321 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6322 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6323 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6324 #define local_inc(l) atomic_long_inc(&(l)->a)
6325 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6326 #define local_dec(l) atomic_long_dec(&(l)->a)
6327 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6328
6329 /*
6330 * Same as above, but return the result value
6331 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6332 return result;
6333 }
6334
6335 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6336 +{
6337 + unsigned long result;
6338 +
6339 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6340 + unsigned long temp;
6341 +
6342 + __asm__ __volatile__(
6343 + " .set mips3 \n"
6344 + "1:" __LL "%1, %2 # local_add_return \n"
6345 + " addu %0, %1, %3 \n"
6346 + __SC "%0, %2 \n"
6347 + " beqzl %0, 1b \n"
6348 + " addu %0, %1, %3 \n"
6349 + " .set mips0 \n"
6350 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6351 + : "Ir" (i), "m" (l->a.counter)
6352 + : "memory");
6353 + } else if (kernel_uses_llsc) {
6354 + unsigned long temp;
6355 +
6356 + __asm__ __volatile__(
6357 + " .set mips3 \n"
6358 + "1:" __LL "%1, %2 # local_add_return \n"
6359 + " addu %0, %1, %3 \n"
6360 + __SC "%0, %2 \n"
6361 + " beqz %0, 1b \n"
6362 + " addu %0, %1, %3 \n"
6363 + " .set mips0 \n"
6364 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6365 + : "Ir" (i), "m" (l->a.counter)
6366 + : "memory");
6367 + } else {
6368 + unsigned long flags;
6369 +
6370 + local_irq_save(flags);
6371 + result = l->a.counter;
6372 + result += i;
6373 + l->a.counter = result;
6374 + local_irq_restore(flags);
6375 + }
6376 +
6377 + return result;
6378 +}
6379 +
6380 static __inline__ long local_sub_return(long i, local_t * l)
6381 {
6382 unsigned long result;
6383 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6384
6385 #define local_cmpxchg(l, o, n) \
6386 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6387 +#define local_cmpxchg_unchecked(l, o, n) \
6388 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6389 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6390
6391 /**
6392 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6393 index f6be474..12ad554 100644
6394 --- a/arch/mips/include/asm/page.h
6395 +++ b/arch/mips/include/asm/page.h
6396 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6397 #ifdef CONFIG_CPU_MIPS32
6398 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6399 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6400 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6401 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6402 #else
6403 typedef struct { unsigned long long pte; } pte_t;
6404 #define pte_val(x) ((x).pte)
6405 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6406 index 881d18b..cea38bc 100644
6407 --- a/arch/mips/include/asm/pgalloc.h
6408 +++ b/arch/mips/include/asm/pgalloc.h
6409 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6410 {
6411 set_pud(pud, __pud((unsigned long)pmd));
6412 }
6413 +
6414 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6415 +{
6416 + pud_populate(mm, pud, pmd);
6417 +}
6418 #endif
6419
6420 /*
6421 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6422 index 25da651..ae2a259 100644
6423 --- a/arch/mips/include/asm/smtc_proc.h
6424 +++ b/arch/mips/include/asm/smtc_proc.h
6425 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6426
6427 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6428
6429 -extern atomic_t smtc_fpu_recoveries;
6430 +extern atomic_unchecked_t smtc_fpu_recoveries;
6431
6432 #endif /* __ASM_SMTC_PROC_H */
6433 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6434 index 61215a3..213ee0e 100644
6435 --- a/arch/mips/include/asm/thread_info.h
6436 +++ b/arch/mips/include/asm/thread_info.h
6437 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6438 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6439 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6440 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6441 +/* li takes a 32bit immediate */
6442 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6443 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6444
6445 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6446 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6447 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6448 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6449 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6450 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6451
6452 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6453 - _TIF_SYSCALL_AUDIT)
6454 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6455
6456 /* work to do in syscall_trace_leave() */
6457 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6458 - _TIF_SYSCALL_AUDIT)
6459 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6460
6461 /* work to do on interrupt/exception return */
6462 #define _TIF_WORK_MASK \
6463 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6464 /* work to do on any return to u-space */
6465 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6466 - _TIF_WORK_SYSCALL_EXIT)
6467 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6468
6469 #endif /* __KERNEL__ */
6470
6471 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6472 index 1188e00..41cf144 100644
6473 --- a/arch/mips/kernel/binfmt_elfn32.c
6474 +++ b/arch/mips/kernel/binfmt_elfn32.c
6475 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6476 #undef ELF_ET_DYN_BASE
6477 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6478
6479 +#ifdef CONFIG_PAX_ASLR
6480 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6481 +
6482 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6483 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6484 +#endif
6485 +
6486 #include <asm/processor.h>
6487 #include <linux/module.h>
6488 #include <linux/elfcore.h>
6489 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6490 index 202e581..689ca79 100644
6491 --- a/arch/mips/kernel/binfmt_elfo32.c
6492 +++ b/arch/mips/kernel/binfmt_elfo32.c
6493 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6494 #undef ELF_ET_DYN_BASE
6495 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6496
6497 +#ifdef CONFIG_PAX_ASLR
6498 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6499 +
6500 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6501 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6502 +#endif
6503 +
6504 #include <asm/processor.h>
6505
6506 /*
6507 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6508 index d1fea7a..45602ea 100644
6509 --- a/arch/mips/kernel/irq.c
6510 +++ b/arch/mips/kernel/irq.c
6511 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6512 printk("unexpected IRQ # %d\n", irq);
6513 }
6514
6515 -atomic_t irq_err_count;
6516 +atomic_unchecked_t irq_err_count;
6517
6518 int arch_show_interrupts(struct seq_file *p, int prec)
6519 {
6520 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6521 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6522 return 0;
6523 }
6524
6525 asmlinkage void spurious_interrupt(void)
6526 {
6527 - atomic_inc(&irq_err_count);
6528 + atomic_inc_unchecked(&irq_err_count);
6529 }
6530
6531 void __init init_IRQ(void)
6532 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6533 index ddc7610..8c58f17 100644
6534 --- a/arch/mips/kernel/process.c
6535 +++ b/arch/mips/kernel/process.c
6536 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6537 out:
6538 return pc;
6539 }
6540 -
6541 -/*
6542 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6543 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6544 - */
6545 -unsigned long arch_align_stack(unsigned long sp)
6546 -{
6547 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6548 - sp -= get_random_int() & ~PAGE_MASK;
6549 -
6550 - return sp & ALMASK;
6551 -}
6552 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6553 index 8ae1ebe..1bcbf47 100644
6554 --- a/arch/mips/kernel/ptrace.c
6555 +++ b/arch/mips/kernel/ptrace.c
6556 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6557 return arch;
6558 }
6559
6560 +#ifdef CONFIG_GRKERNSEC_SETXID
6561 +extern void gr_delayed_cred_worker(void);
6562 +#endif
6563 +
6564 /*
6565 * Notification of system call entry/exit
6566 * - triggered by current->work.syscall_trace
6567 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6568 /* do the secure computing check first */
6569 secure_computing_strict(regs->regs[2]);
6570
6571 +#ifdef CONFIG_GRKERNSEC_SETXID
6572 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6573 + gr_delayed_cred_worker();
6574 +#endif
6575 +
6576 if (!(current->ptrace & PT_PTRACED))
6577 goto out;
6578
6579 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6580 index c10aa84..9ec2e60 100644
6581 --- a/arch/mips/kernel/smtc-proc.c
6582 +++ b/arch/mips/kernel/smtc-proc.c
6583 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6584
6585 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6586
6587 -atomic_t smtc_fpu_recoveries;
6588 +atomic_unchecked_t smtc_fpu_recoveries;
6589
6590 static int smtc_proc_show(struct seq_file *m, void *v)
6591 {
6592 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6593 for(i = 0; i < NR_CPUS; i++)
6594 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6595 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6596 - atomic_read(&smtc_fpu_recoveries));
6597 + atomic_read_unchecked(&smtc_fpu_recoveries));
6598 return 0;
6599 }
6600
6601 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6602 smtc_cpu_stats[i].selfipis = 0;
6603 }
6604
6605 - atomic_set(&smtc_fpu_recoveries, 0);
6606 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6607
6608 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6609 }
6610 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6611 index dfc1b91..11a2c07 100644
6612 --- a/arch/mips/kernel/smtc.c
6613 +++ b/arch/mips/kernel/smtc.c
6614 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6615 }
6616 smtc_ipi_qdump();
6617 printk("%d Recoveries of \"stolen\" FPU\n",
6618 - atomic_read(&smtc_fpu_recoveries));
6619 + atomic_read_unchecked(&smtc_fpu_recoveries));
6620 }
6621
6622
6623 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6624 index 84536bf..79caa4d 100644
6625 --- a/arch/mips/kernel/sync-r4k.c
6626 +++ b/arch/mips/kernel/sync-r4k.c
6627 @@ -21,8 +21,8 @@
6628 #include <asm/mipsregs.h>
6629
6630 static atomic_t count_start_flag = ATOMIC_INIT(0);
6631 -static atomic_t count_count_start = ATOMIC_INIT(0);
6632 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6633 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6634 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6635 static atomic_t count_reference = ATOMIC_INIT(0);
6636
6637 #define COUNTON 100
6638 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6639
6640 for (i = 0; i < NR_LOOPS; i++) {
6641 /* slaves loop on '!= 2' */
6642 - while (atomic_read(&count_count_start) != 1)
6643 + while (atomic_read_unchecked(&count_count_start) != 1)
6644 mb();
6645 - atomic_set(&count_count_stop, 0);
6646 + atomic_set_unchecked(&count_count_stop, 0);
6647 smp_wmb();
6648
6649 /* this lets the slaves write their count register */
6650 - atomic_inc(&count_count_start);
6651 + atomic_inc_unchecked(&count_count_start);
6652
6653 /*
6654 * Everyone initialises count in the last loop:
6655 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6656 /*
6657 * Wait for all slaves to leave the synchronization point:
6658 */
6659 - while (atomic_read(&count_count_stop) != 1)
6660 + while (atomic_read_unchecked(&count_count_stop) != 1)
6661 mb();
6662 - atomic_set(&count_count_start, 0);
6663 + atomic_set_unchecked(&count_count_start, 0);
6664 smp_wmb();
6665 - atomic_inc(&count_count_stop);
6666 + atomic_inc_unchecked(&count_count_stop);
6667 }
6668 /* Arrange for an interrupt in a short while */
6669 write_c0_compare(read_c0_count() + COUNTON);
6670 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6671 initcount = atomic_read(&count_reference);
6672
6673 for (i = 0; i < NR_LOOPS; i++) {
6674 - atomic_inc(&count_count_start);
6675 - while (atomic_read(&count_count_start) != 2)
6676 + atomic_inc_unchecked(&count_count_start);
6677 + while (atomic_read_unchecked(&count_count_start) != 2)
6678 mb();
6679
6680 /*
6681 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6682 if (i == NR_LOOPS-1)
6683 write_c0_count(initcount);
6684
6685 - atomic_inc(&count_count_stop);
6686 - while (atomic_read(&count_count_stop) != 2)
6687 + atomic_inc_unchecked(&count_count_stop);
6688 + while (atomic_read_unchecked(&count_count_stop) != 2)
6689 mb();
6690 }
6691 /* Arrange for an interrupt in a short while */
6692 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6693 index aec3408..74d79d3 100644
6694 --- a/arch/mips/kernel/traps.c
6695 +++ b/arch/mips/kernel/traps.c
6696 @@ -683,7 +683,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6697 siginfo_t info;
6698
6699 prev_state = exception_enter();
6700 - die_if_kernel("Integer overflow", regs);
6701 + if (unlikely(!user_mode(regs))) {
6702 +
6703 +#ifdef CONFIG_PAX_REFCOUNT
6704 + if (fixup_exception(regs)) {
6705 + pax_report_refcount_overflow(regs);
6706 + exception_exit(prev_state);
6707 + return;
6708 + }
6709 +#endif
6710 +
6711 + die("Integer overflow", regs);
6712 + }
6713
6714 info.si_code = FPE_INTOVF;
6715 info.si_signo = SIGFPE;
6716 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6717 index 85df1cd..4f0a4de 100644
6718 --- a/arch/mips/mm/fault.c
6719 +++ b/arch/mips/mm/fault.c
6720 @@ -28,6 +28,23 @@
6721 #include <asm/highmem.h> /* For VMALLOC_END */
6722 #include <linux/kdebug.h>
6723
6724 +#ifdef CONFIG_PAX_PAGEEXEC
6725 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6726 +{
6727 + unsigned long i;
6728 +
6729 + printk(KERN_ERR "PAX: bytes at PC: ");
6730 + for (i = 0; i < 5; i++) {
6731 + unsigned int c;
6732 + if (get_user(c, (unsigned int *)pc+i))
6733 + printk(KERN_CONT "???????? ");
6734 + else
6735 + printk(KERN_CONT "%08x ", c);
6736 + }
6737 + printk("\n");
6738 +}
6739 +#endif
6740 +
6741 /*
6742 * This routine handles page faults. It determines the address,
6743 * and the problem, and then passes it off to one of the appropriate
6744 @@ -197,6 +214,14 @@ bad_area:
6745 bad_area_nosemaphore:
6746 /* User mode accesses just cause a SIGSEGV */
6747 if (user_mode(regs)) {
6748 +
6749 +#ifdef CONFIG_PAX_PAGEEXEC
6750 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6751 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6752 + do_group_exit(SIGKILL);
6753 + }
6754 +#endif
6755 +
6756 tsk->thread.cp0_badvaddr = address;
6757 tsk->thread.error_code = write;
6758 #if 0
6759 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6760 index f1baadd..8537544 100644
6761 --- a/arch/mips/mm/mmap.c
6762 +++ b/arch/mips/mm/mmap.c
6763 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6764 struct vm_area_struct *vma;
6765 unsigned long addr = addr0;
6766 int do_color_align;
6767 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6768 struct vm_unmapped_area_info info;
6769
6770 if (unlikely(len > TASK_SIZE))
6771 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6772 do_color_align = 1;
6773
6774 /* requesting a specific address */
6775 +
6776 +#ifdef CONFIG_PAX_RANDMMAP
6777 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6778 +#endif
6779 +
6780 if (addr) {
6781 if (do_color_align)
6782 addr = COLOUR_ALIGN(addr, pgoff);
6783 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6784 addr = PAGE_ALIGN(addr);
6785
6786 vma = find_vma(mm, addr);
6787 - if (TASK_SIZE - len >= addr &&
6788 - (!vma || addr + len <= vma->vm_start))
6789 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6790 return addr;
6791 }
6792
6793 info.length = len;
6794 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6795 info.align_offset = pgoff << PAGE_SHIFT;
6796 + info.threadstack_offset = offset;
6797
6798 if (dir == DOWN) {
6799 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6800 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6801 {
6802 unsigned long random_factor = 0UL;
6803
6804 +#ifdef CONFIG_PAX_RANDMMAP
6805 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6806 +#endif
6807 +
6808 if (current->flags & PF_RANDOMIZE) {
6809 random_factor = get_random_int();
6810 random_factor = random_factor << PAGE_SHIFT;
6811 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6812
6813 if (mmap_is_legacy()) {
6814 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6815 +
6816 +#ifdef CONFIG_PAX_RANDMMAP
6817 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6818 + mm->mmap_base += mm->delta_mmap;
6819 +#endif
6820 +
6821 mm->get_unmapped_area = arch_get_unmapped_area;
6822 } else {
6823 mm->mmap_base = mmap_base(random_factor);
6824 +
6825 +#ifdef CONFIG_PAX_RANDMMAP
6826 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6827 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6828 +#endif
6829 +
6830 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6831 }
6832 }
6833
6834 -static inline unsigned long brk_rnd(void)
6835 -{
6836 - unsigned long rnd = get_random_int();
6837 -
6838 - rnd = rnd << PAGE_SHIFT;
6839 - /* 8MB for 32bit, 256MB for 64bit */
6840 - if (TASK_IS_32BIT_ADDR)
6841 - rnd = rnd & 0x7ffffful;
6842 - else
6843 - rnd = rnd & 0xffffffful;
6844 -
6845 - return rnd;
6846 -}
6847 -
6848 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6849 -{
6850 - unsigned long base = mm->brk;
6851 - unsigned long ret;
6852 -
6853 - ret = PAGE_ALIGN(base + brk_rnd());
6854 -
6855 - if (ret < mm->brk)
6856 - return mm->brk;
6857 -
6858 - return ret;
6859 -}
6860 -
6861 int __virt_addr_valid(const volatile void *kaddr)
6862 {
6863 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6864 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6865 index a2358b4..7cead4f 100644
6866 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6867 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6868 @@ -187,9 +187,9 @@ void
6869 cont_nmi_dump(void)
6870 {
6871 #ifndef REAL_NMI_SIGNAL
6872 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6873 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6874
6875 - atomic_inc(&nmied_cpus);
6876 + atomic_inc_unchecked(&nmied_cpus);
6877 #endif
6878 /*
6879 * Only allow 1 cpu to proceed
6880 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6881 udelay(10000);
6882 }
6883 #else
6884 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6885 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6886 #endif
6887
6888 /*
6889 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6890 index 967d144..db12197 100644
6891 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6892 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6893 @@ -11,12 +11,14 @@
6894 #ifndef _ASM_PROC_CACHE_H
6895 #define _ASM_PROC_CACHE_H
6896
6897 +#include <linux/const.h>
6898 +
6899 /* L1 cache */
6900
6901 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6902 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6903 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6904 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6905 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6906 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6907
6908 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6909 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6910 index bcb5df2..84fabd2 100644
6911 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6912 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6913 @@ -16,13 +16,15 @@
6914 #ifndef _ASM_PROC_CACHE_H
6915 #define _ASM_PROC_CACHE_H
6916
6917 +#include <linux/const.h>
6918 +
6919 /*
6920 * L1 cache
6921 */
6922 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6923 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6924 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6925 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6926 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6927 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6928
6929 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6930 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6931 index 4ce7a01..449202a 100644
6932 --- a/arch/openrisc/include/asm/cache.h
6933 +++ b/arch/openrisc/include/asm/cache.h
6934 @@ -19,11 +19,13 @@
6935 #ifndef __ASM_OPENRISC_CACHE_H
6936 #define __ASM_OPENRISC_CACHE_H
6937
6938 +#include <linux/const.h>
6939 +
6940 /* FIXME: How can we replace these with values from the CPU...
6941 * they shouldn't be hard-coded!
6942 */
6943
6944 -#define L1_CACHE_BYTES 16
6945 #define L1_CACHE_SHIFT 4
6946 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6947
6948 #endif /* __ASM_OPENRISC_CACHE_H */
6949 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
6950 index 472886c..00e7df9 100644
6951 --- a/arch/parisc/include/asm/atomic.h
6952 +++ b/arch/parisc/include/asm/atomic.h
6953 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
6954 return dec;
6955 }
6956
6957 +#define atomic64_read_unchecked(v) atomic64_read(v)
6958 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6959 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6960 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6961 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6962 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6963 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6964 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6965 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6966 +
6967 #endif /* !CONFIG_64BIT */
6968
6969
6970 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
6971 index 47f11c7..3420df2 100644
6972 --- a/arch/parisc/include/asm/cache.h
6973 +++ b/arch/parisc/include/asm/cache.h
6974 @@ -5,6 +5,7 @@
6975 #ifndef __ARCH_PARISC_CACHE_H
6976 #define __ARCH_PARISC_CACHE_H
6977
6978 +#include <linux/const.h>
6979
6980 /*
6981 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
6982 @@ -15,13 +16,13 @@
6983 * just ruin performance.
6984 */
6985 #ifdef CONFIG_PA20
6986 -#define L1_CACHE_BYTES 64
6987 #define L1_CACHE_SHIFT 6
6988 #else
6989 -#define L1_CACHE_BYTES 32
6990 #define L1_CACHE_SHIFT 5
6991 #endif
6992
6993 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6994 +
6995 #ifndef __ASSEMBLY__
6996
6997 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6998 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
6999 index ad2b503..bdf1651 100644
7000 --- a/arch/parisc/include/asm/elf.h
7001 +++ b/arch/parisc/include/asm/elf.h
7002 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7003
7004 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7005
7006 +#ifdef CONFIG_PAX_ASLR
7007 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7008 +
7009 +#define PAX_DELTA_MMAP_LEN 16
7010 +#define PAX_DELTA_STACK_LEN 16
7011 +#endif
7012 +
7013 /* This yields a mask that user programs can use to figure out what
7014 instruction set this CPU supports. This could be done in user space,
7015 but it's not easy, and we've already done it here. */
7016 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7017 index fc987a1..6e068ef 100644
7018 --- a/arch/parisc/include/asm/pgalloc.h
7019 +++ b/arch/parisc/include/asm/pgalloc.h
7020 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7021 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7022 }
7023
7024 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7025 +{
7026 + pgd_populate(mm, pgd, pmd);
7027 +}
7028 +
7029 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7030 {
7031 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7032 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7033 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7034 #define pmd_free(mm, x) do { } while (0)
7035 #define pgd_populate(mm, pmd, pte) BUG()
7036 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7037
7038 #endif
7039
7040 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7041 index 34899b5..02dd060 100644
7042 --- a/arch/parisc/include/asm/pgtable.h
7043 +++ b/arch/parisc/include/asm/pgtable.h
7044 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7045 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7046 #define PAGE_COPY PAGE_EXECREAD
7047 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7048 +
7049 +#ifdef CONFIG_PAX_PAGEEXEC
7050 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7051 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7052 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7053 +#else
7054 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7055 +# define PAGE_COPY_NOEXEC PAGE_COPY
7056 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7057 +#endif
7058 +
7059 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7060 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7061 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7062 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7063 index e0a8235..ce2f1e1 100644
7064 --- a/arch/parisc/include/asm/uaccess.h
7065 +++ b/arch/parisc/include/asm/uaccess.h
7066 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7067 const void __user *from,
7068 unsigned long n)
7069 {
7070 - int sz = __compiletime_object_size(to);
7071 + size_t sz = __compiletime_object_size(to);
7072 int ret = -EFAULT;
7073
7074 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7075 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7076 ret = __copy_from_user(to, from, n);
7077 else
7078 copy_from_user_overflow();
7079 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7080 index 2a625fb..9908930 100644
7081 --- a/arch/parisc/kernel/module.c
7082 +++ b/arch/parisc/kernel/module.c
7083 @@ -98,16 +98,38 @@
7084
7085 /* three functions to determine where in the module core
7086 * or init pieces the location is */
7087 +static inline int in_init_rx(struct module *me, void *loc)
7088 +{
7089 + return (loc >= me->module_init_rx &&
7090 + loc < (me->module_init_rx + me->init_size_rx));
7091 +}
7092 +
7093 +static inline int in_init_rw(struct module *me, void *loc)
7094 +{
7095 + return (loc >= me->module_init_rw &&
7096 + loc < (me->module_init_rw + me->init_size_rw));
7097 +}
7098 +
7099 static inline int in_init(struct module *me, void *loc)
7100 {
7101 - return (loc >= me->module_init &&
7102 - loc <= (me->module_init + me->init_size));
7103 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7104 +}
7105 +
7106 +static inline int in_core_rx(struct module *me, void *loc)
7107 +{
7108 + return (loc >= me->module_core_rx &&
7109 + loc < (me->module_core_rx + me->core_size_rx));
7110 +}
7111 +
7112 +static inline int in_core_rw(struct module *me, void *loc)
7113 +{
7114 + return (loc >= me->module_core_rw &&
7115 + loc < (me->module_core_rw + me->core_size_rw));
7116 }
7117
7118 static inline int in_core(struct module *me, void *loc)
7119 {
7120 - return (loc >= me->module_core &&
7121 - loc <= (me->module_core + me->core_size));
7122 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7123 }
7124
7125 static inline int in_local(struct module *me, void *loc)
7126 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7127 }
7128
7129 /* align things a bit */
7130 - me->core_size = ALIGN(me->core_size, 16);
7131 - me->arch.got_offset = me->core_size;
7132 - me->core_size += gots * sizeof(struct got_entry);
7133 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7134 + me->arch.got_offset = me->core_size_rw;
7135 + me->core_size_rw += gots * sizeof(struct got_entry);
7136
7137 - me->core_size = ALIGN(me->core_size, 16);
7138 - me->arch.fdesc_offset = me->core_size;
7139 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7140 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7141 + me->arch.fdesc_offset = me->core_size_rw;
7142 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7143
7144 me->arch.got_max = gots;
7145 me->arch.fdesc_max = fdescs;
7146 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7147
7148 BUG_ON(value == 0);
7149
7150 - got = me->module_core + me->arch.got_offset;
7151 + got = me->module_core_rw + me->arch.got_offset;
7152 for (i = 0; got[i].addr; i++)
7153 if (got[i].addr == value)
7154 goto out;
7155 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7156 #ifdef CONFIG_64BIT
7157 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7158 {
7159 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7160 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7161
7162 if (!value) {
7163 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7164 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7165
7166 /* Create new one */
7167 fdesc->addr = value;
7168 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7169 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7170 return (Elf_Addr)fdesc;
7171 }
7172 #endif /* CONFIG_64BIT */
7173 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7174
7175 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7176 end = table + sechdrs[me->arch.unwind_section].sh_size;
7177 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7178 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7179
7180 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7181 me->arch.unwind_section, table, end, gp);
7182 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7183 index 5dfd248..64914ac 100644
7184 --- a/arch/parisc/kernel/sys_parisc.c
7185 +++ b/arch/parisc/kernel/sys_parisc.c
7186 @@ -33,9 +33,11 @@
7187 #include <linux/utsname.h>
7188 #include <linux/personality.h>
7189
7190 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7191 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7192 + unsigned long flags)
7193 {
7194 struct vm_unmapped_area_info info;
7195 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7196
7197 info.flags = 0;
7198 info.length = len;
7199 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7200 info.high_limit = TASK_SIZE;
7201 info.align_mask = 0;
7202 info.align_offset = 0;
7203 + info.threadstack_offset = offset;
7204 return vm_unmapped_area(&info);
7205 }
7206
7207 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7208 return (unsigned long) mapping >> 8;
7209 }
7210
7211 -static unsigned long get_shared_area(struct address_space *mapping,
7212 - unsigned long addr, unsigned long len, unsigned long pgoff)
7213 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7214 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7215 {
7216 struct vm_unmapped_area_info info;
7217 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7218
7219 info.flags = 0;
7220 info.length = len;
7221 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7222 info.high_limit = TASK_SIZE;
7223 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7224 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7225 + info.threadstack_offset = offset;
7226 return vm_unmapped_area(&info);
7227 }
7228
7229 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7230 return -EINVAL;
7231 return addr;
7232 }
7233 - if (!addr)
7234 + if (!addr) {
7235 addr = TASK_UNMAPPED_BASE;
7236
7237 +#ifdef CONFIG_PAX_RANDMMAP
7238 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7239 + addr += current->mm->delta_mmap;
7240 +#endif
7241 +
7242 + }
7243 +
7244 if (filp) {
7245 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7246 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7247 } else if(flags & MAP_SHARED) {
7248 - addr = get_shared_area(NULL, addr, len, pgoff);
7249 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7250 } else {
7251 - addr = get_unshared_area(addr, len);
7252 + addr = get_unshared_area(filp, addr, len, flags);
7253 }
7254 return addr;
7255 }
7256 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7257 index 04e47c6..7a8faf6 100644
7258 --- a/arch/parisc/kernel/traps.c
7259 +++ b/arch/parisc/kernel/traps.c
7260 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7261
7262 down_read(&current->mm->mmap_sem);
7263 vma = find_vma(current->mm,regs->iaoq[0]);
7264 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7265 - && (vma->vm_flags & VM_EXEC)) {
7266 -
7267 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7268 fault_address = regs->iaoq[0];
7269 fault_space = regs->iasq[0];
7270
7271 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7272 index f247a34..dc0f219 100644
7273 --- a/arch/parisc/mm/fault.c
7274 +++ b/arch/parisc/mm/fault.c
7275 @@ -15,6 +15,7 @@
7276 #include <linux/sched.h>
7277 #include <linux/interrupt.h>
7278 #include <linux/module.h>
7279 +#include <linux/unistd.h>
7280
7281 #include <asm/uaccess.h>
7282 #include <asm/traps.h>
7283 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7284 static unsigned long
7285 parisc_acctyp(unsigned long code, unsigned int inst)
7286 {
7287 - if (code == 6 || code == 16)
7288 + if (code == 6 || code == 7 || code == 16)
7289 return VM_EXEC;
7290
7291 switch (inst & 0xf0000000) {
7292 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7293 }
7294 #endif
7295
7296 +#ifdef CONFIG_PAX_PAGEEXEC
7297 +/*
7298 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7299 + *
7300 + * returns 1 when task should be killed
7301 + * 2 when rt_sigreturn trampoline was detected
7302 + * 3 when unpatched PLT trampoline was detected
7303 + */
7304 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7305 +{
7306 +
7307 +#ifdef CONFIG_PAX_EMUPLT
7308 + int err;
7309 +
7310 + do { /* PaX: unpatched PLT emulation */
7311 + unsigned int bl, depwi;
7312 +
7313 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7314 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7315 +
7316 + if (err)
7317 + break;
7318 +
7319 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7320 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7321 +
7322 + err = get_user(ldw, (unsigned int *)addr);
7323 + err |= get_user(bv, (unsigned int *)(addr+4));
7324 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7325 +
7326 + if (err)
7327 + break;
7328 +
7329 + if (ldw == 0x0E801096U &&
7330 + bv == 0xEAC0C000U &&
7331 + ldw2 == 0x0E881095U)
7332 + {
7333 + unsigned int resolver, map;
7334 +
7335 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7336 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7337 + if (err)
7338 + break;
7339 +
7340 + regs->gr[20] = instruction_pointer(regs)+8;
7341 + regs->gr[21] = map;
7342 + regs->gr[22] = resolver;
7343 + regs->iaoq[0] = resolver | 3UL;
7344 + regs->iaoq[1] = regs->iaoq[0] + 4;
7345 + return 3;
7346 + }
7347 + }
7348 + } while (0);
7349 +#endif
7350 +
7351 +#ifdef CONFIG_PAX_EMUTRAMP
7352 +
7353 +#ifndef CONFIG_PAX_EMUSIGRT
7354 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7355 + return 1;
7356 +#endif
7357 +
7358 + do { /* PaX: rt_sigreturn emulation */
7359 + unsigned int ldi1, ldi2, bel, nop;
7360 +
7361 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7362 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7363 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7364 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7365 +
7366 + if (err)
7367 + break;
7368 +
7369 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7370 + ldi2 == 0x3414015AU &&
7371 + bel == 0xE4008200U &&
7372 + nop == 0x08000240U)
7373 + {
7374 + regs->gr[25] = (ldi1 & 2) >> 1;
7375 + regs->gr[20] = __NR_rt_sigreturn;
7376 + regs->gr[31] = regs->iaoq[1] + 16;
7377 + regs->sr[0] = regs->iasq[1];
7378 + regs->iaoq[0] = 0x100UL;
7379 + regs->iaoq[1] = regs->iaoq[0] + 4;
7380 + regs->iasq[0] = regs->sr[2];
7381 + regs->iasq[1] = regs->sr[2];
7382 + return 2;
7383 + }
7384 + } while (0);
7385 +#endif
7386 +
7387 + return 1;
7388 +}
7389 +
7390 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7391 +{
7392 + unsigned long i;
7393 +
7394 + printk(KERN_ERR "PAX: bytes at PC: ");
7395 + for (i = 0; i < 5; i++) {
7396 + unsigned int c;
7397 + if (get_user(c, (unsigned int *)pc+i))
7398 + printk(KERN_CONT "???????? ");
7399 + else
7400 + printk(KERN_CONT "%08x ", c);
7401 + }
7402 + printk("\n");
7403 +}
7404 +#endif
7405 +
7406 int fixup_exception(struct pt_regs *regs)
7407 {
7408 const struct exception_table_entry *fix;
7409 @@ -194,8 +305,33 @@ good_area:
7410
7411 acc_type = parisc_acctyp(code,regs->iir);
7412
7413 - if ((vma->vm_flags & acc_type) != acc_type)
7414 + if ((vma->vm_flags & acc_type) != acc_type) {
7415 +
7416 +#ifdef CONFIG_PAX_PAGEEXEC
7417 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7418 + (address & ~3UL) == instruction_pointer(regs))
7419 + {
7420 + up_read(&mm->mmap_sem);
7421 + switch (pax_handle_fetch_fault(regs)) {
7422 +
7423 +#ifdef CONFIG_PAX_EMUPLT
7424 + case 3:
7425 + return;
7426 +#endif
7427 +
7428 +#ifdef CONFIG_PAX_EMUTRAMP
7429 + case 2:
7430 + return;
7431 +#endif
7432 +
7433 + }
7434 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7435 + do_group_exit(SIGKILL);
7436 + }
7437 +#endif
7438 +
7439 goto bad_area;
7440 + }
7441
7442 /*
7443 * If for any reason at all we couldn't handle the fault, make
7444 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7445 index e3b1d41..8e81edf 100644
7446 --- a/arch/powerpc/include/asm/atomic.h
7447 +++ b/arch/powerpc/include/asm/atomic.h
7448 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7449 return t1;
7450 }
7451
7452 +#define atomic64_read_unchecked(v) atomic64_read(v)
7453 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7454 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7455 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7456 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7457 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7458 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7459 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7460 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7461 +
7462 #endif /* __powerpc64__ */
7463
7464 #endif /* __KERNEL__ */
7465 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7466 index 9e495c9..b6878e5 100644
7467 --- a/arch/powerpc/include/asm/cache.h
7468 +++ b/arch/powerpc/include/asm/cache.h
7469 @@ -3,6 +3,7 @@
7470
7471 #ifdef __KERNEL__
7472
7473 +#include <linux/const.h>
7474
7475 /* bytes per L1 cache line */
7476 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7477 @@ -22,7 +23,7 @@
7478 #define L1_CACHE_SHIFT 7
7479 #endif
7480
7481 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7482 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7483
7484 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7485
7486 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7487 index cc0655a..13eac2e 100644
7488 --- a/arch/powerpc/include/asm/elf.h
7489 +++ b/arch/powerpc/include/asm/elf.h
7490 @@ -28,8 +28,19 @@
7491 the loader. We need to make sure that it is out of the way of the program
7492 that it will "exec", and that there is sufficient room for the brk. */
7493
7494 -extern unsigned long randomize_et_dyn(unsigned long base);
7495 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7496 +#define ELF_ET_DYN_BASE (0x20000000)
7497 +
7498 +#ifdef CONFIG_PAX_ASLR
7499 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7500 +
7501 +#ifdef __powerpc64__
7502 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7503 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7504 +#else
7505 +#define PAX_DELTA_MMAP_LEN 15
7506 +#define PAX_DELTA_STACK_LEN 15
7507 +#endif
7508 +#endif
7509
7510 /*
7511 * Our registers are always unsigned longs, whether we're a 32 bit
7512 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7513 (0x7ff >> (PAGE_SHIFT - 12)) : \
7514 (0x3ffff >> (PAGE_SHIFT - 12)))
7515
7516 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7517 -#define arch_randomize_brk arch_randomize_brk
7518 -
7519 -
7520 #ifdef CONFIG_SPU_BASE
7521 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7522 #define NT_SPU 1
7523 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7524 index 8196e9c..d83a9f3 100644
7525 --- a/arch/powerpc/include/asm/exec.h
7526 +++ b/arch/powerpc/include/asm/exec.h
7527 @@ -4,6 +4,6 @@
7528 #ifndef _ASM_POWERPC_EXEC_H
7529 #define _ASM_POWERPC_EXEC_H
7530
7531 -extern unsigned long arch_align_stack(unsigned long sp);
7532 +#define arch_align_stack(x) ((x) & ~0xfUL)
7533
7534 #endif /* _ASM_POWERPC_EXEC_H */
7535 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7536 index 5acabbd..7ea14fa 100644
7537 --- a/arch/powerpc/include/asm/kmap_types.h
7538 +++ b/arch/powerpc/include/asm/kmap_types.h
7539 @@ -10,7 +10,7 @@
7540 * 2 of the License, or (at your option) any later version.
7541 */
7542
7543 -#define KM_TYPE_NR 16
7544 +#define KM_TYPE_NR 17
7545
7546 #endif /* __KERNEL__ */
7547 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7548 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7549 index 8565c25..2865190 100644
7550 --- a/arch/powerpc/include/asm/mman.h
7551 +++ b/arch/powerpc/include/asm/mman.h
7552 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7553 }
7554 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7555
7556 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7557 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7558 {
7559 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7560 }
7561 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7562 index b9f4262..dcf04f7 100644
7563 --- a/arch/powerpc/include/asm/page.h
7564 +++ b/arch/powerpc/include/asm/page.h
7565 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7566 * and needs to be executable. This means the whole heap ends
7567 * up being executable.
7568 */
7569 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7570 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7571 +#define VM_DATA_DEFAULT_FLAGS32 \
7572 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7573 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7574
7575 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7576 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7577 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7578 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7579 #endif
7580
7581 +#define ktla_ktva(addr) (addr)
7582 +#define ktva_ktla(addr) (addr)
7583 +
7584 #ifndef CONFIG_PPC_BOOK3S_64
7585 /*
7586 * Use the top bit of the higher-level page table entries to indicate whether
7587 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7588 index 88693ce..ac6f9ab 100644
7589 --- a/arch/powerpc/include/asm/page_64.h
7590 +++ b/arch/powerpc/include/asm/page_64.h
7591 @@ -153,15 +153,18 @@ do { \
7592 * stack by default, so in the absence of a PT_GNU_STACK program header
7593 * we turn execute permission off.
7594 */
7595 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7596 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7597 +#define VM_STACK_DEFAULT_FLAGS32 \
7598 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7599 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7600
7601 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7602 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7603
7604 +#ifndef CONFIG_PAX_PAGEEXEC
7605 #define VM_STACK_DEFAULT_FLAGS \
7606 (is_32bit_task() ? \
7607 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7608 +#endif
7609
7610 #include <asm-generic/getorder.h>
7611
7612 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7613 index f65e27b..23ffb5b 100644
7614 --- a/arch/powerpc/include/asm/pgalloc-64.h
7615 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7616 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7617 #ifndef CONFIG_PPC_64K_PAGES
7618
7619 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7620 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7621
7622 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7623 {
7624 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7625 pud_set(pud, (unsigned long)pmd);
7626 }
7627
7628 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7629 +{
7630 + pud_populate(mm, pud, pmd);
7631 +}
7632 +
7633 #define pmd_populate(mm, pmd, pte_page) \
7634 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7635 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7636 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7637 #endif
7638
7639 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7640 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7641
7642 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7643 pte_t *pte)
7644 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7645 index 7d6eacf..14c0240 100644
7646 --- a/arch/powerpc/include/asm/pgtable.h
7647 +++ b/arch/powerpc/include/asm/pgtable.h
7648 @@ -2,6 +2,7 @@
7649 #define _ASM_POWERPC_PGTABLE_H
7650 #ifdef __KERNEL__
7651
7652 +#include <linux/const.h>
7653 #ifndef __ASSEMBLY__
7654 #include <asm/processor.h> /* For TASK_SIZE */
7655 #include <asm/mmu.h>
7656 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7657 index 4aad413..85d86bf 100644
7658 --- a/arch/powerpc/include/asm/pte-hash32.h
7659 +++ b/arch/powerpc/include/asm/pte-hash32.h
7660 @@ -21,6 +21,7 @@
7661 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7662 #define _PAGE_USER 0x004 /* usermode access allowed */
7663 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7664 +#define _PAGE_EXEC _PAGE_GUARDED
7665 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7666 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7667 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7668 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7669 index 99222e2..f629aef 100644
7670 --- a/arch/powerpc/include/asm/reg.h
7671 +++ b/arch/powerpc/include/asm/reg.h
7672 @@ -234,6 +234,7 @@
7673 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7674 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7675 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7676 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7677 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7678 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7679 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7680 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7681 index 48cfc85..891382f 100644
7682 --- a/arch/powerpc/include/asm/smp.h
7683 +++ b/arch/powerpc/include/asm/smp.h
7684 @@ -50,7 +50,7 @@ struct smp_ops_t {
7685 int (*cpu_disable)(void);
7686 void (*cpu_die)(unsigned int nr);
7687 int (*cpu_bootable)(unsigned int nr);
7688 -};
7689 +} __no_const;
7690
7691 extern void smp_send_debugger_break(void);
7692 extern void start_secondary_resume(void);
7693 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7694 index ba7b197..d292e26 100644
7695 --- a/arch/powerpc/include/asm/thread_info.h
7696 +++ b/arch/powerpc/include/asm/thread_info.h
7697 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7698 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7699 TIF_NEED_RESCHED */
7700 #define TIF_32BIT 4 /* 32 bit binary */
7701 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7702 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7703 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7704 #define TIF_SINGLESTEP 8 /* singlestepping active */
7705 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7706 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7707 for stack store? */
7708 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7709 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7710 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7711 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7712
7713 /* as above, but as bit values */
7714 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7715 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7716 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7717 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7718 #define _TIF_NOHZ (1<<TIF_NOHZ)
7719 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7720 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7721 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7722 - _TIF_NOHZ)
7723 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7724
7725 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7726 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7727 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7728 index 9485b43..4718d50 100644
7729 --- a/arch/powerpc/include/asm/uaccess.h
7730 +++ b/arch/powerpc/include/asm/uaccess.h
7731 @@ -318,52 +318,6 @@ do { \
7732 extern unsigned long __copy_tofrom_user(void __user *to,
7733 const void __user *from, unsigned long size);
7734
7735 -#ifndef __powerpc64__
7736 -
7737 -static inline unsigned long copy_from_user(void *to,
7738 - const void __user *from, unsigned long n)
7739 -{
7740 - unsigned long over;
7741 -
7742 - if (access_ok(VERIFY_READ, from, n))
7743 - return __copy_tofrom_user((__force void __user *)to, from, n);
7744 - if ((unsigned long)from < TASK_SIZE) {
7745 - over = (unsigned long)from + n - TASK_SIZE;
7746 - return __copy_tofrom_user((__force void __user *)to, from,
7747 - n - over) + over;
7748 - }
7749 - return n;
7750 -}
7751 -
7752 -static inline unsigned long copy_to_user(void __user *to,
7753 - const void *from, unsigned long n)
7754 -{
7755 - unsigned long over;
7756 -
7757 - if (access_ok(VERIFY_WRITE, to, n))
7758 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7759 - if ((unsigned long)to < TASK_SIZE) {
7760 - over = (unsigned long)to + n - TASK_SIZE;
7761 - return __copy_tofrom_user(to, (__force void __user *)from,
7762 - n - over) + over;
7763 - }
7764 - return n;
7765 -}
7766 -
7767 -#else /* __powerpc64__ */
7768 -
7769 -#define __copy_in_user(to, from, size) \
7770 - __copy_tofrom_user((to), (from), (size))
7771 -
7772 -extern unsigned long copy_from_user(void *to, const void __user *from,
7773 - unsigned long n);
7774 -extern unsigned long copy_to_user(void __user *to, const void *from,
7775 - unsigned long n);
7776 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7777 - unsigned long n);
7778 -
7779 -#endif /* __powerpc64__ */
7780 -
7781 static inline unsigned long __copy_from_user_inatomic(void *to,
7782 const void __user *from, unsigned long n)
7783 {
7784 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7785 if (ret == 0)
7786 return 0;
7787 }
7788 +
7789 + if (!__builtin_constant_p(n))
7790 + check_object_size(to, n, false);
7791 +
7792 return __copy_tofrom_user((__force void __user *)to, from, n);
7793 }
7794
7795 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7796 if (ret == 0)
7797 return 0;
7798 }
7799 +
7800 + if (!__builtin_constant_p(n))
7801 + check_object_size(from, n, true);
7802 +
7803 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7804 }
7805
7806 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7807 return __copy_to_user_inatomic(to, from, size);
7808 }
7809
7810 +#ifndef __powerpc64__
7811 +
7812 +static inline unsigned long __must_check copy_from_user(void *to,
7813 + const void __user *from, unsigned long n)
7814 +{
7815 + unsigned long over;
7816 +
7817 + if ((long)n < 0)
7818 + return n;
7819 +
7820 + if (access_ok(VERIFY_READ, from, n)) {
7821 + if (!__builtin_constant_p(n))
7822 + check_object_size(to, n, false);
7823 + return __copy_tofrom_user((__force void __user *)to, from, n);
7824 + }
7825 + if ((unsigned long)from < TASK_SIZE) {
7826 + over = (unsigned long)from + n - TASK_SIZE;
7827 + if (!__builtin_constant_p(n - over))
7828 + check_object_size(to, n - over, false);
7829 + return __copy_tofrom_user((__force void __user *)to, from,
7830 + n - over) + over;
7831 + }
7832 + return n;
7833 +}
7834 +
7835 +static inline unsigned long __must_check copy_to_user(void __user *to,
7836 + const void *from, unsigned long n)
7837 +{
7838 + unsigned long over;
7839 +
7840 + if ((long)n < 0)
7841 + return n;
7842 +
7843 + if (access_ok(VERIFY_WRITE, to, n)) {
7844 + if (!__builtin_constant_p(n))
7845 + check_object_size(from, n, true);
7846 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7847 + }
7848 + if ((unsigned long)to < TASK_SIZE) {
7849 + over = (unsigned long)to + n - TASK_SIZE;
7850 + if (!__builtin_constant_p(n))
7851 + check_object_size(from, n - over, true);
7852 + return __copy_tofrom_user(to, (__force void __user *)from,
7853 + n - over) + over;
7854 + }
7855 + return n;
7856 +}
7857 +
7858 +#else /* __powerpc64__ */
7859 +
7860 +#define __copy_in_user(to, from, size) \
7861 + __copy_tofrom_user((to), (from), (size))
7862 +
7863 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7864 +{
7865 + if ((long)n < 0 || n > INT_MAX)
7866 + return n;
7867 +
7868 + if (!__builtin_constant_p(n))
7869 + check_object_size(to, n, false);
7870 +
7871 + if (likely(access_ok(VERIFY_READ, from, n)))
7872 + n = __copy_from_user(to, from, n);
7873 + else
7874 + memset(to, 0, n);
7875 + return n;
7876 +}
7877 +
7878 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7879 +{
7880 + if ((long)n < 0 || n > INT_MAX)
7881 + return n;
7882 +
7883 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7884 + if (!__builtin_constant_p(n))
7885 + check_object_size(from, n, true);
7886 + n = __copy_to_user(to, from, n);
7887 + }
7888 + return n;
7889 +}
7890 +
7891 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7892 + unsigned long n);
7893 +
7894 +#endif /* __powerpc64__ */
7895 +
7896 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7897
7898 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7899 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7900 index 645170a..6cf0271 100644
7901 --- a/arch/powerpc/kernel/exceptions-64e.S
7902 +++ b/arch/powerpc/kernel/exceptions-64e.S
7903 @@ -757,6 +757,7 @@ storage_fault_common:
7904 std r14,_DAR(r1)
7905 std r15,_DSISR(r1)
7906 addi r3,r1,STACK_FRAME_OVERHEAD
7907 + bl .save_nvgprs
7908 mr r4,r14
7909 mr r5,r15
7910 ld r14,PACA_EXGEN+EX_R14(r13)
7911 @@ -765,8 +766,7 @@ storage_fault_common:
7912 cmpdi r3,0
7913 bne- 1f
7914 b .ret_from_except_lite
7915 -1: bl .save_nvgprs
7916 - mr r5,r3
7917 +1: mr r5,r3
7918 addi r3,r1,STACK_FRAME_OVERHEAD
7919 ld r4,_DAR(r1)
7920 bl .bad_page_fault
7921 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7922 index 902ca3c..e942155 100644
7923 --- a/arch/powerpc/kernel/exceptions-64s.S
7924 +++ b/arch/powerpc/kernel/exceptions-64s.S
7925 @@ -1357,10 +1357,10 @@ handle_page_fault:
7926 11: ld r4,_DAR(r1)
7927 ld r5,_DSISR(r1)
7928 addi r3,r1,STACK_FRAME_OVERHEAD
7929 + bl .save_nvgprs
7930 bl .do_page_fault
7931 cmpdi r3,0
7932 beq+ 12f
7933 - bl .save_nvgprs
7934 mr r5,r3
7935 addi r3,r1,STACK_FRAME_OVERHEAD
7936 lwz r4,_DAR(r1)
7937 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7938 index 2e3200c..72095ce 100644
7939 --- a/arch/powerpc/kernel/module_32.c
7940 +++ b/arch/powerpc/kernel/module_32.c
7941 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7942 me->arch.core_plt_section = i;
7943 }
7944 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7945 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7946 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7947 return -ENOEXEC;
7948 }
7949
7950 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7951
7952 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7953 /* Init, or core PLT? */
7954 - if (location >= mod->module_core
7955 - && location < mod->module_core + mod->core_size)
7956 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7957 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7958 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7959 - else
7960 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7961 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7962 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7963 + else {
7964 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7965 + return ~0UL;
7966 + }
7967
7968 /* Find this entry, or if that fails, the next avail. entry */
7969 while (entry->jump[0]) {
7970 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7971 index 8083be2..10aa352 100644
7972 --- a/arch/powerpc/kernel/process.c
7973 +++ b/arch/powerpc/kernel/process.c
7974 @@ -884,8 +884,8 @@ void show_regs(struct pt_regs * regs)
7975 * Lookup NIP late so we have the best change of getting the
7976 * above info out without failing
7977 */
7978 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7979 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7980 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7981 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7982 #endif
7983 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
7984 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
7985 @@ -1349,10 +1349,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7986 newsp = stack[0];
7987 ip = stack[STACK_FRAME_LR_SAVE];
7988 if (!firstframe || ip != lr) {
7989 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
7990 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
7991 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
7992 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
7993 - printk(" (%pS)",
7994 + printk(" (%pA)",
7995 (void *)current->ret_stack[curr_frame].ret);
7996 curr_frame--;
7997 }
7998 @@ -1372,7 +1372,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7999 struct pt_regs *regs = (struct pt_regs *)
8000 (sp + STACK_FRAME_OVERHEAD);
8001 lr = regs->link;
8002 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8003 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8004 regs->trap, (void *)regs->nip, (void *)lr);
8005 firstframe = 1;
8006 }
8007 @@ -1408,58 +1408,3 @@ void notrace __ppc64_runlatch_off(void)
8008 mtspr(SPRN_CTRLT, ctrl);
8009 }
8010 #endif /* CONFIG_PPC64 */
8011 -
8012 -unsigned long arch_align_stack(unsigned long sp)
8013 -{
8014 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8015 - sp -= get_random_int() & ~PAGE_MASK;
8016 - return sp & ~0xf;
8017 -}
8018 -
8019 -static inline unsigned long brk_rnd(void)
8020 -{
8021 - unsigned long rnd = 0;
8022 -
8023 - /* 8MB for 32bit, 1GB for 64bit */
8024 - if (is_32bit_task())
8025 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8026 - else
8027 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8028 -
8029 - return rnd << PAGE_SHIFT;
8030 -}
8031 -
8032 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8033 -{
8034 - unsigned long base = mm->brk;
8035 - unsigned long ret;
8036 -
8037 -#ifdef CONFIG_PPC_STD_MMU_64
8038 - /*
8039 - * If we are using 1TB segments and we are allowed to randomise
8040 - * the heap, we can put it above 1TB so it is backed by a 1TB
8041 - * segment. Otherwise the heap will be in the bottom 1TB
8042 - * which always uses 256MB segments and this may result in a
8043 - * performance penalty.
8044 - */
8045 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8046 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8047 -#endif
8048 -
8049 - ret = PAGE_ALIGN(base + brk_rnd());
8050 -
8051 - if (ret < mm->brk)
8052 - return mm->brk;
8053 -
8054 - return ret;
8055 -}
8056 -
8057 -unsigned long randomize_et_dyn(unsigned long base)
8058 -{
8059 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8060 -
8061 - if (ret < base)
8062 - return base;
8063 -
8064 - return ret;
8065 -}
8066 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8067 index 9a0d24c..e7fbedf 100644
8068 --- a/arch/powerpc/kernel/ptrace.c
8069 +++ b/arch/powerpc/kernel/ptrace.c
8070 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8071 return ret;
8072 }
8073
8074 +#ifdef CONFIG_GRKERNSEC_SETXID
8075 +extern void gr_delayed_cred_worker(void);
8076 +#endif
8077 +
8078 /*
8079 * We must return the syscall number to actually look up in the table.
8080 * This can be -1L to skip running any syscall at all.
8081 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8082
8083 secure_computing_strict(regs->gpr[0]);
8084
8085 +#ifdef CONFIG_GRKERNSEC_SETXID
8086 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8087 + gr_delayed_cred_worker();
8088 +#endif
8089 +
8090 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8091 tracehook_report_syscall_entry(regs))
8092 /*
8093 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8094 {
8095 int step;
8096
8097 +#ifdef CONFIG_GRKERNSEC_SETXID
8098 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8099 + gr_delayed_cred_worker();
8100 +#endif
8101 +
8102 audit_syscall_exit(regs);
8103
8104 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8105 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8106 index 0f83122..c0aca6a 100644
8107 --- a/arch/powerpc/kernel/signal_32.c
8108 +++ b/arch/powerpc/kernel/signal_32.c
8109 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8110 /* Save user registers on the stack */
8111 frame = &rt_sf->uc.uc_mcontext;
8112 addr = frame;
8113 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8114 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8115 sigret = 0;
8116 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8117 } else {
8118 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8119 index 887e99d..310bc11 100644
8120 --- a/arch/powerpc/kernel/signal_64.c
8121 +++ b/arch/powerpc/kernel/signal_64.c
8122 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8123 #endif
8124
8125 /* Set up to return from userspace. */
8126 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8127 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8128 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8129 } else {
8130 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8131 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8132 index e435bc0..41c2964 100644
8133 --- a/arch/powerpc/kernel/traps.c
8134 +++ b/arch/powerpc/kernel/traps.c
8135 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8136 return flags;
8137 }
8138
8139 +extern void gr_handle_kernel_exploit(void);
8140 +
8141 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8142 int signr)
8143 {
8144 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8145 panic("Fatal exception in interrupt");
8146 if (panic_on_oops)
8147 panic("Fatal exception");
8148 +
8149 + gr_handle_kernel_exploit();
8150 +
8151 do_exit(signr);
8152 }
8153
8154 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8155 index 1d9c926..25f4741 100644
8156 --- a/arch/powerpc/kernel/vdso.c
8157 +++ b/arch/powerpc/kernel/vdso.c
8158 @@ -34,6 +34,7 @@
8159 #include <asm/firmware.h>
8160 #include <asm/vdso.h>
8161 #include <asm/vdso_datapage.h>
8162 +#include <asm/mman.h>
8163
8164 #include "setup.h"
8165
8166 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8167 vdso_base = VDSO32_MBASE;
8168 #endif
8169
8170 - current->mm->context.vdso_base = 0;
8171 + current->mm->context.vdso_base = ~0UL;
8172
8173 /* vDSO has a problem and was disabled, just don't "enable" it for the
8174 * process
8175 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8176 vdso_base = get_unmapped_area(NULL, vdso_base,
8177 (vdso_pages << PAGE_SHIFT) +
8178 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8179 - 0, 0);
8180 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8181 if (IS_ERR_VALUE(vdso_base)) {
8182 rc = vdso_base;
8183 goto fail_mmapsem;
8184 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8185 index 5eea6f3..5d10396 100644
8186 --- a/arch/powerpc/lib/usercopy_64.c
8187 +++ b/arch/powerpc/lib/usercopy_64.c
8188 @@ -9,22 +9,6 @@
8189 #include <linux/module.h>
8190 #include <asm/uaccess.h>
8191
8192 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8193 -{
8194 - if (likely(access_ok(VERIFY_READ, from, n)))
8195 - n = __copy_from_user(to, from, n);
8196 - else
8197 - memset(to, 0, n);
8198 - return n;
8199 -}
8200 -
8201 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8202 -{
8203 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8204 - n = __copy_to_user(to, from, n);
8205 - return n;
8206 -}
8207 -
8208 unsigned long copy_in_user(void __user *to, const void __user *from,
8209 unsigned long n)
8210 {
8211 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8212 return n;
8213 }
8214
8215 -EXPORT_SYMBOL(copy_from_user);
8216 -EXPORT_SYMBOL(copy_to_user);
8217 EXPORT_SYMBOL(copy_in_user);
8218
8219 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8220 index 8726779..a33c512 100644
8221 --- a/arch/powerpc/mm/fault.c
8222 +++ b/arch/powerpc/mm/fault.c
8223 @@ -33,6 +33,10 @@
8224 #include <linux/magic.h>
8225 #include <linux/ratelimit.h>
8226 #include <linux/context_tracking.h>
8227 +#include <linux/slab.h>
8228 +#include <linux/pagemap.h>
8229 +#include <linux/compiler.h>
8230 +#include <linux/unistd.h>
8231
8232 #include <asm/firmware.h>
8233 #include <asm/page.h>
8234 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8235 }
8236 #endif
8237
8238 +#ifdef CONFIG_PAX_PAGEEXEC
8239 +/*
8240 + * PaX: decide what to do with offenders (regs->nip = fault address)
8241 + *
8242 + * returns 1 when task should be killed
8243 + */
8244 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8245 +{
8246 + return 1;
8247 +}
8248 +
8249 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8250 +{
8251 + unsigned long i;
8252 +
8253 + printk(KERN_ERR "PAX: bytes at PC: ");
8254 + for (i = 0; i < 5; i++) {
8255 + unsigned int c;
8256 + if (get_user(c, (unsigned int __user *)pc+i))
8257 + printk(KERN_CONT "???????? ");
8258 + else
8259 + printk(KERN_CONT "%08x ", c);
8260 + }
8261 + printk("\n");
8262 +}
8263 +#endif
8264 +
8265 /*
8266 * Check whether the instruction at regs->nip is a store using
8267 * an update addressing form which will update r1.
8268 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8269 * indicate errors in DSISR but can validly be set in SRR1.
8270 */
8271 if (trap == 0x400)
8272 - error_code &= 0x48200000;
8273 + error_code &= 0x58200000;
8274 else
8275 is_write = error_code & DSISR_ISSTORE;
8276 #else
8277 @@ -371,7 +402,7 @@ good_area:
8278 * "undefined". Of those that can be set, this is the only
8279 * one which seems bad.
8280 */
8281 - if (error_code & 0x10000000)
8282 + if (error_code & DSISR_GUARDED)
8283 /* Guarded storage error. */
8284 goto bad_area;
8285 #endif /* CONFIG_8xx */
8286 @@ -386,7 +417,7 @@ good_area:
8287 * processors use the same I/D cache coherency mechanism
8288 * as embedded.
8289 */
8290 - if (error_code & DSISR_PROTFAULT)
8291 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8292 goto bad_area;
8293 #endif /* CONFIG_PPC_STD_MMU */
8294
8295 @@ -471,6 +502,23 @@ bad_area:
8296 bad_area_nosemaphore:
8297 /* User mode accesses cause a SIGSEGV */
8298 if (user_mode(regs)) {
8299 +
8300 +#ifdef CONFIG_PAX_PAGEEXEC
8301 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8302 +#ifdef CONFIG_PPC_STD_MMU
8303 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8304 +#else
8305 + if (is_exec && regs->nip == address) {
8306 +#endif
8307 + switch (pax_handle_fetch_fault(regs)) {
8308 + }
8309 +
8310 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8311 + do_group_exit(SIGKILL);
8312 + }
8313 + }
8314 +#endif
8315 +
8316 _exception(SIGSEGV, regs, code, address);
8317 goto bail;
8318 }
8319 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8320 index cb8bdbe..d770680 100644
8321 --- a/arch/powerpc/mm/mmap.c
8322 +++ b/arch/powerpc/mm/mmap.c
8323 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8324 {
8325 unsigned long rnd = 0;
8326
8327 +#ifdef CONFIG_PAX_RANDMMAP
8328 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8329 +#endif
8330 +
8331 if (current->flags & PF_RANDOMIZE) {
8332 /* 8MB for 32bit, 1GB for 64bit */
8333 if (is_32bit_task())
8334 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8335 */
8336 if (mmap_is_legacy()) {
8337 mm->mmap_base = TASK_UNMAPPED_BASE;
8338 +
8339 +#ifdef CONFIG_PAX_RANDMMAP
8340 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8341 + mm->mmap_base += mm->delta_mmap;
8342 +#endif
8343 +
8344 mm->get_unmapped_area = arch_get_unmapped_area;
8345 } else {
8346 mm->mmap_base = mmap_base();
8347 +
8348 +#ifdef CONFIG_PAX_RANDMMAP
8349 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8350 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8351 +#endif
8352 +
8353 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8354 }
8355 }
8356 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8357 index 3e99c14..f00953c 100644
8358 --- a/arch/powerpc/mm/slice.c
8359 +++ b/arch/powerpc/mm/slice.c
8360 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8361 if ((mm->task_size - len) < addr)
8362 return 0;
8363 vma = find_vma(mm, addr);
8364 - return (!vma || (addr + len) <= vma->vm_start);
8365 + return check_heap_stack_gap(vma, addr, len, 0);
8366 }
8367
8368 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8369 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8370 info.align_offset = 0;
8371
8372 addr = TASK_UNMAPPED_BASE;
8373 +
8374 +#ifdef CONFIG_PAX_RANDMMAP
8375 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8376 + addr += mm->delta_mmap;
8377 +#endif
8378 +
8379 while (addr < TASK_SIZE) {
8380 info.low_limit = addr;
8381 if (!slice_scan_available(addr, available, 1, &addr))
8382 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8383 if (fixed && addr > (mm->task_size - len))
8384 return -EINVAL;
8385
8386 +#ifdef CONFIG_PAX_RANDMMAP
8387 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8388 + addr = 0;
8389 +#endif
8390 +
8391 /* If hint, make sure it matches our alignment restrictions */
8392 if (!fixed && addr) {
8393 addr = _ALIGN_UP(addr, 1ul << pshift);
8394 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8395 index 9098692..3d54cd1 100644
8396 --- a/arch/powerpc/platforms/cell/spufs/file.c
8397 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8398 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8399 return VM_FAULT_NOPAGE;
8400 }
8401
8402 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8403 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8404 unsigned long address,
8405 - void *buf, int len, int write)
8406 + void *buf, size_t len, int write)
8407 {
8408 struct spu_context *ctx = vma->vm_file->private_data;
8409 unsigned long offset = address - vma->vm_start;
8410 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8411 index c797832..ce575c8 100644
8412 --- a/arch/s390/include/asm/atomic.h
8413 +++ b/arch/s390/include/asm/atomic.h
8414 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8415 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8416 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8417
8418 +#define atomic64_read_unchecked(v) atomic64_read(v)
8419 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8420 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8421 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8422 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8423 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8424 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8425 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8426 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8427 +
8428 #define smp_mb__before_atomic_dec() smp_mb()
8429 #define smp_mb__after_atomic_dec() smp_mb()
8430 #define smp_mb__before_atomic_inc() smp_mb()
8431 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8432 index 4d7ccac..d03d0ad 100644
8433 --- a/arch/s390/include/asm/cache.h
8434 +++ b/arch/s390/include/asm/cache.h
8435 @@ -9,8 +9,10 @@
8436 #ifndef __ARCH_S390_CACHE_H
8437 #define __ARCH_S390_CACHE_H
8438
8439 -#define L1_CACHE_BYTES 256
8440 +#include <linux/const.h>
8441 +
8442 #define L1_CACHE_SHIFT 8
8443 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8444 #define NET_SKB_PAD 32
8445
8446 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8447 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8448 index 78f4f87..598ce39 100644
8449 --- a/arch/s390/include/asm/elf.h
8450 +++ b/arch/s390/include/asm/elf.h
8451 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8452 the loader. We need to make sure that it is out of the way of the program
8453 that it will "exec", and that there is sufficient room for the brk. */
8454
8455 -extern unsigned long randomize_et_dyn(unsigned long base);
8456 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8457 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8458 +
8459 +#ifdef CONFIG_PAX_ASLR
8460 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8461 +
8462 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8463 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8464 +#endif
8465
8466 /* This yields a mask that user programs can use to figure out what
8467 instruction set this CPU supports. */
8468 @@ -222,9 +228,6 @@ struct linux_binprm;
8469 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8470 int arch_setup_additional_pages(struct linux_binprm *, int);
8471
8472 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8473 -#define arch_randomize_brk arch_randomize_brk
8474 -
8475 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8476
8477 #endif
8478 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8479 index c4a93d6..4d2a9b4 100644
8480 --- a/arch/s390/include/asm/exec.h
8481 +++ b/arch/s390/include/asm/exec.h
8482 @@ -7,6 +7,6 @@
8483 #ifndef __ASM_EXEC_H
8484 #define __ASM_EXEC_H
8485
8486 -extern unsigned long arch_align_stack(unsigned long sp);
8487 +#define arch_align_stack(x) ((x) & ~0xfUL)
8488
8489 #endif /* __ASM_EXEC_H */
8490 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8491 index 9c33ed4..e40cbef 100644
8492 --- a/arch/s390/include/asm/uaccess.h
8493 +++ b/arch/s390/include/asm/uaccess.h
8494 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8495 copy_to_user(void __user *to, const void *from, unsigned long n)
8496 {
8497 might_fault();
8498 +
8499 + if ((long)n < 0)
8500 + return n;
8501 +
8502 return __copy_to_user(to, from, n);
8503 }
8504
8505 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8506 static inline unsigned long __must_check
8507 __copy_from_user(void *to, const void __user *from, unsigned long n)
8508 {
8509 + if ((long)n < 0)
8510 + return n;
8511 +
8512 if (__builtin_constant_p(n) && (n <= 256))
8513 return uaccess.copy_from_user_small(n, from, to);
8514 else
8515 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8516 static inline unsigned long __must_check
8517 copy_from_user(void *to, const void __user *from, unsigned long n)
8518 {
8519 - unsigned int sz = __compiletime_object_size(to);
8520 + size_t sz = __compiletime_object_size(to);
8521
8522 might_fault();
8523 - if (unlikely(sz != -1 && sz < n)) {
8524 +
8525 + if ((long)n < 0)
8526 + return n;
8527 +
8528 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8529 copy_from_user_overflow();
8530 return n;
8531 }
8532 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8533 index 7845e15..59c4353 100644
8534 --- a/arch/s390/kernel/module.c
8535 +++ b/arch/s390/kernel/module.c
8536 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8537
8538 /* Increase core size by size of got & plt and set start
8539 offsets for got and plt. */
8540 - me->core_size = ALIGN(me->core_size, 4);
8541 - me->arch.got_offset = me->core_size;
8542 - me->core_size += me->arch.got_size;
8543 - me->arch.plt_offset = me->core_size;
8544 - me->core_size += me->arch.plt_size;
8545 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8546 + me->arch.got_offset = me->core_size_rw;
8547 + me->core_size_rw += me->arch.got_size;
8548 + me->arch.plt_offset = me->core_size_rx;
8549 + me->core_size_rx += me->arch.plt_size;
8550 return 0;
8551 }
8552
8553 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8554 if (info->got_initialized == 0) {
8555 Elf_Addr *gotent;
8556
8557 - gotent = me->module_core + me->arch.got_offset +
8558 + gotent = me->module_core_rw + me->arch.got_offset +
8559 info->got_offset;
8560 *gotent = val;
8561 info->got_initialized = 1;
8562 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8563 rc = apply_rela_bits(loc, val, 0, 64, 0);
8564 else if (r_type == R_390_GOTENT ||
8565 r_type == R_390_GOTPLTENT) {
8566 - val += (Elf_Addr) me->module_core - loc;
8567 + val += (Elf_Addr) me->module_core_rw - loc;
8568 rc = apply_rela_bits(loc, val, 1, 32, 1);
8569 }
8570 break;
8571 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8572 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8573 if (info->plt_initialized == 0) {
8574 unsigned int *ip;
8575 - ip = me->module_core + me->arch.plt_offset +
8576 + ip = me->module_core_rx + me->arch.plt_offset +
8577 info->plt_offset;
8578 #ifndef CONFIG_64BIT
8579 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8580 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8581 val - loc + 0xffffUL < 0x1ffffeUL) ||
8582 (r_type == R_390_PLT32DBL &&
8583 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8584 - val = (Elf_Addr) me->module_core +
8585 + val = (Elf_Addr) me->module_core_rx +
8586 me->arch.plt_offset +
8587 info->plt_offset;
8588 val += rela->r_addend - loc;
8589 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8590 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8591 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8592 val = val + rela->r_addend -
8593 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8594 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8595 if (r_type == R_390_GOTOFF16)
8596 rc = apply_rela_bits(loc, val, 0, 16, 0);
8597 else if (r_type == R_390_GOTOFF32)
8598 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8599 break;
8600 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8601 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8602 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8603 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8604 rela->r_addend - loc;
8605 if (r_type == R_390_GOTPC)
8606 rc = apply_rela_bits(loc, val, 1, 32, 0);
8607 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8608 index 2bc3edd..ab9d598 100644
8609 --- a/arch/s390/kernel/process.c
8610 +++ b/arch/s390/kernel/process.c
8611 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
8612 }
8613 return 0;
8614 }
8615 -
8616 -unsigned long arch_align_stack(unsigned long sp)
8617 -{
8618 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8619 - sp -= get_random_int() & ~PAGE_MASK;
8620 - return sp & ~0xf;
8621 -}
8622 -
8623 -static inline unsigned long brk_rnd(void)
8624 -{
8625 - /* 8MB for 32bit, 1GB for 64bit */
8626 - if (is_32bit_task())
8627 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8628 - else
8629 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8630 -}
8631 -
8632 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8633 -{
8634 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8635 -
8636 - if (ret < mm->brk)
8637 - return mm->brk;
8638 - return ret;
8639 -}
8640 -
8641 -unsigned long randomize_et_dyn(unsigned long base)
8642 -{
8643 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8644 -
8645 - if (!(current->flags & PF_RANDOMIZE))
8646 - return base;
8647 - if (ret < base)
8648 - return base;
8649 - return ret;
8650 -}
8651 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8652 index 4002329..99b67cb 100644
8653 --- a/arch/s390/mm/mmap.c
8654 +++ b/arch/s390/mm/mmap.c
8655 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8656 */
8657 if (mmap_is_legacy()) {
8658 mm->mmap_base = TASK_UNMAPPED_BASE;
8659 +
8660 +#ifdef CONFIG_PAX_RANDMMAP
8661 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8662 + mm->mmap_base += mm->delta_mmap;
8663 +#endif
8664 +
8665 mm->get_unmapped_area = arch_get_unmapped_area;
8666 } else {
8667 mm->mmap_base = mmap_base();
8668 +
8669 +#ifdef CONFIG_PAX_RANDMMAP
8670 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8671 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8672 +#endif
8673 +
8674 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8675 }
8676 }
8677 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8678 */
8679 if (mmap_is_legacy()) {
8680 mm->mmap_base = TASK_UNMAPPED_BASE;
8681 +
8682 +#ifdef CONFIG_PAX_RANDMMAP
8683 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8684 + mm->mmap_base += mm->delta_mmap;
8685 +#endif
8686 +
8687 mm->get_unmapped_area = s390_get_unmapped_area;
8688 } else {
8689 mm->mmap_base = mmap_base();
8690 +
8691 +#ifdef CONFIG_PAX_RANDMMAP
8692 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8693 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8694 +#endif
8695 +
8696 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8697 }
8698 }
8699 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8700 index ae3d59f..f65f075 100644
8701 --- a/arch/score/include/asm/cache.h
8702 +++ b/arch/score/include/asm/cache.h
8703 @@ -1,7 +1,9 @@
8704 #ifndef _ASM_SCORE_CACHE_H
8705 #define _ASM_SCORE_CACHE_H
8706
8707 +#include <linux/const.h>
8708 +
8709 #define L1_CACHE_SHIFT 4
8710 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8711 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8712
8713 #endif /* _ASM_SCORE_CACHE_H */
8714 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8715 index f9f3cd5..58ff438 100644
8716 --- a/arch/score/include/asm/exec.h
8717 +++ b/arch/score/include/asm/exec.h
8718 @@ -1,6 +1,6 @@
8719 #ifndef _ASM_SCORE_EXEC_H
8720 #define _ASM_SCORE_EXEC_H
8721
8722 -extern unsigned long arch_align_stack(unsigned long sp);
8723 +#define arch_align_stack(x) (x)
8724
8725 #endif /* _ASM_SCORE_EXEC_H */
8726 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8727 index f4c6d02..e9355c3 100644
8728 --- a/arch/score/kernel/process.c
8729 +++ b/arch/score/kernel/process.c
8730 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8731
8732 return task_pt_regs(task)->cp0_epc;
8733 }
8734 -
8735 -unsigned long arch_align_stack(unsigned long sp)
8736 -{
8737 - return sp;
8738 -}
8739 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8740 index ef9e555..331bd29 100644
8741 --- a/arch/sh/include/asm/cache.h
8742 +++ b/arch/sh/include/asm/cache.h
8743 @@ -9,10 +9,11 @@
8744 #define __ASM_SH_CACHE_H
8745 #ifdef __KERNEL__
8746
8747 +#include <linux/const.h>
8748 #include <linux/init.h>
8749 #include <cpu/cache.h>
8750
8751 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8752 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8753
8754 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8755
8756 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8757 index 6777177..cb5e44f 100644
8758 --- a/arch/sh/mm/mmap.c
8759 +++ b/arch/sh/mm/mmap.c
8760 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8761 struct mm_struct *mm = current->mm;
8762 struct vm_area_struct *vma;
8763 int do_colour_align;
8764 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8765 struct vm_unmapped_area_info info;
8766
8767 if (flags & MAP_FIXED) {
8768 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8769 if (filp || (flags & MAP_SHARED))
8770 do_colour_align = 1;
8771
8772 +#ifdef CONFIG_PAX_RANDMMAP
8773 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8774 +#endif
8775 +
8776 if (addr) {
8777 if (do_colour_align)
8778 addr = COLOUR_ALIGN(addr, pgoff);
8779 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8780 addr = PAGE_ALIGN(addr);
8781
8782 vma = find_vma(mm, addr);
8783 - if (TASK_SIZE - len >= addr &&
8784 - (!vma || addr + len <= vma->vm_start))
8785 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8786 return addr;
8787 }
8788
8789 info.flags = 0;
8790 info.length = len;
8791 - info.low_limit = TASK_UNMAPPED_BASE;
8792 + info.low_limit = mm->mmap_base;
8793 info.high_limit = TASK_SIZE;
8794 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8795 info.align_offset = pgoff << PAGE_SHIFT;
8796 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8797 struct mm_struct *mm = current->mm;
8798 unsigned long addr = addr0;
8799 int do_colour_align;
8800 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8801 struct vm_unmapped_area_info info;
8802
8803 if (flags & MAP_FIXED) {
8804 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8805 if (filp || (flags & MAP_SHARED))
8806 do_colour_align = 1;
8807
8808 +#ifdef CONFIG_PAX_RANDMMAP
8809 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8810 +#endif
8811 +
8812 /* requesting a specific address */
8813 if (addr) {
8814 if (do_colour_align)
8815 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8816 addr = PAGE_ALIGN(addr);
8817
8818 vma = find_vma(mm, addr);
8819 - if (TASK_SIZE - len >= addr &&
8820 - (!vma || addr + len <= vma->vm_start))
8821 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8822 return addr;
8823 }
8824
8825 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8826 VM_BUG_ON(addr != -ENOMEM);
8827 info.flags = 0;
8828 info.low_limit = TASK_UNMAPPED_BASE;
8829 +
8830 +#ifdef CONFIG_PAX_RANDMMAP
8831 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8832 + info.low_limit += mm->delta_mmap;
8833 +#endif
8834 +
8835 info.high_limit = TASK_SIZE;
8836 addr = vm_unmapped_area(&info);
8837 }
8838 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8839 index be56a24..443328f 100644
8840 --- a/arch/sparc/include/asm/atomic_64.h
8841 +++ b/arch/sparc/include/asm/atomic_64.h
8842 @@ -14,18 +14,40 @@
8843 #define ATOMIC64_INIT(i) { (i) }
8844
8845 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8846 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8847 +{
8848 + return v->counter;
8849 +}
8850 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8851 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8852 +{
8853 + return v->counter;
8854 +}
8855
8856 #define atomic_set(v, i) (((v)->counter) = i)
8857 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8858 +{
8859 + v->counter = i;
8860 +}
8861 #define atomic64_set(v, i) (((v)->counter) = i)
8862 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8863 +{
8864 + v->counter = i;
8865 +}
8866
8867 extern void atomic_add(int, atomic_t *);
8868 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8869 extern void atomic64_add(long, atomic64_t *);
8870 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8871 extern void atomic_sub(int, atomic_t *);
8872 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8873 extern void atomic64_sub(long, atomic64_t *);
8874 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8875
8876 extern int atomic_add_ret(int, atomic_t *);
8877 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8878 extern long atomic64_add_ret(long, atomic64_t *);
8879 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8880 extern int atomic_sub_ret(int, atomic_t *);
8881 extern long atomic64_sub_ret(long, atomic64_t *);
8882
8883 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8884 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8885
8886 #define atomic_inc_return(v) atomic_add_ret(1, v)
8887 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8888 +{
8889 + return atomic_add_ret_unchecked(1, v);
8890 +}
8891 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8892 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8893 +{
8894 + return atomic64_add_ret_unchecked(1, v);
8895 +}
8896
8897 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8898 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8899
8900 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8901 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8902 +{
8903 + return atomic_add_ret_unchecked(i, v);
8904 +}
8905 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8906 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8907 +{
8908 + return atomic64_add_ret_unchecked(i, v);
8909 +}
8910
8911 /*
8912 * atomic_inc_and_test - increment and test
8913 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8914 * other cases.
8915 */
8916 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8917 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8918 +{
8919 + return atomic_inc_return_unchecked(v) == 0;
8920 +}
8921 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8922
8923 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8924 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8925 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8926
8927 #define atomic_inc(v) atomic_add(1, v)
8928 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8929 +{
8930 + atomic_add_unchecked(1, v);
8931 +}
8932 #define atomic64_inc(v) atomic64_add(1, v)
8933 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8934 +{
8935 + atomic64_add_unchecked(1, v);
8936 +}
8937
8938 #define atomic_dec(v) atomic_sub(1, v)
8939 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8940 +{
8941 + atomic_sub_unchecked(1, v);
8942 +}
8943 #define atomic64_dec(v) atomic64_sub(1, v)
8944 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8945 +{
8946 + atomic64_sub_unchecked(1, v);
8947 +}
8948
8949 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8950 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8951
8952 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8953 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8954 +{
8955 + return cmpxchg(&v->counter, old, new);
8956 +}
8957 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8958 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8959 +{
8960 + return xchg(&v->counter, new);
8961 +}
8962
8963 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8964 {
8965 - int c, old;
8966 + int c, old, new;
8967 c = atomic_read(v);
8968 for (;;) {
8969 - if (unlikely(c == (u)))
8970 + if (unlikely(c == u))
8971 break;
8972 - old = atomic_cmpxchg((v), c, c + (a));
8973 +
8974 + asm volatile("addcc %2, %0, %0\n"
8975 +
8976 +#ifdef CONFIG_PAX_REFCOUNT
8977 + "tvs %%icc, 6\n"
8978 +#endif
8979 +
8980 + : "=r" (new)
8981 + : "0" (c), "ir" (a)
8982 + : "cc");
8983 +
8984 + old = atomic_cmpxchg(v, c, new);
8985 if (likely(old == c))
8986 break;
8987 c = old;
8988 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8989 #define atomic64_cmpxchg(v, o, n) \
8990 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8991 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8992 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8993 +{
8994 + return xchg(&v->counter, new);
8995 +}
8996
8997 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8998 {
8999 - long c, old;
9000 + long c, old, new;
9001 c = atomic64_read(v);
9002 for (;;) {
9003 - if (unlikely(c == (u)))
9004 + if (unlikely(c == u))
9005 break;
9006 - old = atomic64_cmpxchg((v), c, c + (a));
9007 +
9008 + asm volatile("addcc %2, %0, %0\n"
9009 +
9010 +#ifdef CONFIG_PAX_REFCOUNT
9011 + "tvs %%xcc, 6\n"
9012 +#endif
9013 +
9014 + : "=r" (new)
9015 + : "0" (c), "ir" (a)
9016 + : "cc");
9017 +
9018 + old = atomic64_cmpxchg(v, c, new);
9019 if (likely(old == c))
9020 break;
9021 c = old;
9022 }
9023 - return c != (u);
9024 + return c != u;
9025 }
9026
9027 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9028 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9029 index 5bb6991..5c2132e 100644
9030 --- a/arch/sparc/include/asm/cache.h
9031 +++ b/arch/sparc/include/asm/cache.h
9032 @@ -7,10 +7,12 @@
9033 #ifndef _SPARC_CACHE_H
9034 #define _SPARC_CACHE_H
9035
9036 +#include <linux/const.h>
9037 +
9038 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9039
9040 #define L1_CACHE_SHIFT 5
9041 -#define L1_CACHE_BYTES 32
9042 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9043
9044 #ifdef CONFIG_SPARC32
9045 #define SMP_CACHE_BYTES_SHIFT 5
9046 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9047 index a24e41f..47677ff 100644
9048 --- a/arch/sparc/include/asm/elf_32.h
9049 +++ b/arch/sparc/include/asm/elf_32.h
9050 @@ -114,6 +114,13 @@ typedef struct {
9051
9052 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9053
9054 +#ifdef CONFIG_PAX_ASLR
9055 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9056 +
9057 +#define PAX_DELTA_MMAP_LEN 16
9058 +#define PAX_DELTA_STACK_LEN 16
9059 +#endif
9060 +
9061 /* This yields a mask that user programs can use to figure out what
9062 instruction set this cpu supports. This can NOT be done in userspace
9063 on Sparc. */
9064 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9065 index 370ca1e..d4f4a98 100644
9066 --- a/arch/sparc/include/asm/elf_64.h
9067 +++ b/arch/sparc/include/asm/elf_64.h
9068 @@ -189,6 +189,13 @@ typedef struct {
9069 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9070 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9071
9072 +#ifdef CONFIG_PAX_ASLR
9073 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9074 +
9075 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9076 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9077 +#endif
9078 +
9079 extern unsigned long sparc64_elf_hwcap;
9080 #define ELF_HWCAP sparc64_elf_hwcap
9081
9082 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9083 index 9b1c36d..209298b 100644
9084 --- a/arch/sparc/include/asm/pgalloc_32.h
9085 +++ b/arch/sparc/include/asm/pgalloc_32.h
9086 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9087 }
9088
9089 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9090 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9091
9092 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9093 unsigned long address)
9094 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9095 index bcfe063..b333142 100644
9096 --- a/arch/sparc/include/asm/pgalloc_64.h
9097 +++ b/arch/sparc/include/asm/pgalloc_64.h
9098 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9099 }
9100
9101 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9102 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9103
9104 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9105 {
9106 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9107 index 502f632..da1917f 100644
9108 --- a/arch/sparc/include/asm/pgtable_32.h
9109 +++ b/arch/sparc/include/asm/pgtable_32.h
9110 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9111 #define PAGE_SHARED SRMMU_PAGE_SHARED
9112 #define PAGE_COPY SRMMU_PAGE_COPY
9113 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9114 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9115 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9116 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9117 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9118
9119 /* Top-level page directory - dummy used by init-mm.
9120 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9121
9122 /* xwr */
9123 #define __P000 PAGE_NONE
9124 -#define __P001 PAGE_READONLY
9125 -#define __P010 PAGE_COPY
9126 -#define __P011 PAGE_COPY
9127 +#define __P001 PAGE_READONLY_NOEXEC
9128 +#define __P010 PAGE_COPY_NOEXEC
9129 +#define __P011 PAGE_COPY_NOEXEC
9130 #define __P100 PAGE_READONLY
9131 #define __P101 PAGE_READONLY
9132 #define __P110 PAGE_COPY
9133 #define __P111 PAGE_COPY
9134
9135 #define __S000 PAGE_NONE
9136 -#define __S001 PAGE_READONLY
9137 -#define __S010 PAGE_SHARED
9138 -#define __S011 PAGE_SHARED
9139 +#define __S001 PAGE_READONLY_NOEXEC
9140 +#define __S010 PAGE_SHARED_NOEXEC
9141 +#define __S011 PAGE_SHARED_NOEXEC
9142 #define __S100 PAGE_READONLY
9143 #define __S101 PAGE_READONLY
9144 #define __S110 PAGE_SHARED
9145 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9146 index 79da178..c2eede8 100644
9147 --- a/arch/sparc/include/asm/pgtsrmmu.h
9148 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9149 @@ -115,6 +115,11 @@
9150 SRMMU_EXEC | SRMMU_REF)
9151 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9152 SRMMU_EXEC | SRMMU_REF)
9153 +
9154 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9155 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9156 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9157 +
9158 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9159 SRMMU_DIRTY | SRMMU_REF)
9160
9161 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9162 index 9689176..63c18ea 100644
9163 --- a/arch/sparc/include/asm/spinlock_64.h
9164 +++ b/arch/sparc/include/asm/spinlock_64.h
9165 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9166
9167 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9168
9169 -static void inline arch_read_lock(arch_rwlock_t *lock)
9170 +static inline void arch_read_lock(arch_rwlock_t *lock)
9171 {
9172 unsigned long tmp1, tmp2;
9173
9174 __asm__ __volatile__ (
9175 "1: ldsw [%2], %0\n"
9176 " brlz,pn %0, 2f\n"
9177 -"4: add %0, 1, %1\n"
9178 +"4: addcc %0, 1, %1\n"
9179 +
9180 +#ifdef CONFIG_PAX_REFCOUNT
9181 +" tvs %%icc, 6\n"
9182 +#endif
9183 +
9184 " cas [%2], %0, %1\n"
9185 " cmp %0, %1\n"
9186 " bne,pn %%icc, 1b\n"
9187 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9188 " .previous"
9189 : "=&r" (tmp1), "=&r" (tmp2)
9190 : "r" (lock)
9191 - : "memory");
9192 + : "memory", "cc");
9193 }
9194
9195 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9196 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9197 {
9198 int tmp1, tmp2;
9199
9200 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9201 "1: ldsw [%2], %0\n"
9202 " brlz,a,pn %0, 2f\n"
9203 " mov 0, %0\n"
9204 -" add %0, 1, %1\n"
9205 +" addcc %0, 1, %1\n"
9206 +
9207 +#ifdef CONFIG_PAX_REFCOUNT
9208 +" tvs %%icc, 6\n"
9209 +#endif
9210 +
9211 " cas [%2], %0, %1\n"
9212 " cmp %0, %1\n"
9213 " bne,pn %%icc, 1b\n"
9214 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9215 return tmp1;
9216 }
9217
9218 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9219 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9220 {
9221 unsigned long tmp1, tmp2;
9222
9223 __asm__ __volatile__(
9224 "1: lduw [%2], %0\n"
9225 -" sub %0, 1, %1\n"
9226 +" subcc %0, 1, %1\n"
9227 +
9228 +#ifdef CONFIG_PAX_REFCOUNT
9229 +" tvs %%icc, 6\n"
9230 +#endif
9231 +
9232 " cas [%2], %0, %1\n"
9233 " cmp %0, %1\n"
9234 " bne,pn %%xcc, 1b\n"
9235 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9236 : "memory");
9237 }
9238
9239 -static void inline arch_write_lock(arch_rwlock_t *lock)
9240 +static inline void arch_write_lock(arch_rwlock_t *lock)
9241 {
9242 unsigned long mask, tmp1, tmp2;
9243
9244 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9245 : "memory");
9246 }
9247
9248 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9249 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9250 {
9251 __asm__ __volatile__(
9252 " stw %%g0, [%0]"
9253 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9254 : "memory");
9255 }
9256
9257 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9258 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9259 {
9260 unsigned long mask, tmp1, tmp2, result;
9261
9262 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9263 index dd38075..e7cac83 100644
9264 --- a/arch/sparc/include/asm/thread_info_32.h
9265 +++ b/arch/sparc/include/asm/thread_info_32.h
9266 @@ -49,6 +49,8 @@ struct thread_info {
9267 unsigned long w_saved;
9268
9269 struct restart_block restart_block;
9270 +
9271 + unsigned long lowest_stack;
9272 };
9273
9274 /*
9275 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9276 index d5e5042..9bfee76 100644
9277 --- a/arch/sparc/include/asm/thread_info_64.h
9278 +++ b/arch/sparc/include/asm/thread_info_64.h
9279 @@ -63,6 +63,8 @@ struct thread_info {
9280 struct pt_regs *kern_una_regs;
9281 unsigned int kern_una_insn;
9282
9283 + unsigned long lowest_stack;
9284 +
9285 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9286 };
9287
9288 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9289 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9290 /* flag bit 6 is available */
9291 #define TIF_32BIT 7 /* 32-bit binary */
9292 -/* flag bit 8 is available */
9293 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9294 #define TIF_SECCOMP 9 /* secure computing */
9295 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9296 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9297 +
9298 /* NOTE: Thread flags >= 12 should be ones we have no interest
9299 * in using in assembly, else we can't use the mask as
9300 * an immediate value in instructions such as andcc.
9301 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9302 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9303 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9304 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9305 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9306
9307 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9308 _TIF_DO_NOTIFY_RESUME_MASK | \
9309 _TIF_NEED_RESCHED)
9310 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9311
9312 +#define _TIF_WORK_SYSCALL \
9313 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9314 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9315 +
9316 +
9317 /*
9318 * Thread-synchronous status.
9319 *
9320 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9321 index 0167d26..767bb0c 100644
9322 --- a/arch/sparc/include/asm/uaccess.h
9323 +++ b/arch/sparc/include/asm/uaccess.h
9324 @@ -1,5 +1,6 @@
9325 #ifndef ___ASM_SPARC_UACCESS_H
9326 #define ___ASM_SPARC_UACCESS_H
9327 +
9328 #if defined(__sparc__) && defined(__arch64__)
9329 #include <asm/uaccess_64.h>
9330 #else
9331 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9332 index 53a28dd..50c38c3 100644
9333 --- a/arch/sparc/include/asm/uaccess_32.h
9334 +++ b/arch/sparc/include/asm/uaccess_32.h
9335 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9336
9337 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9338 {
9339 - if (n && __access_ok((unsigned long) to, n))
9340 + if ((long)n < 0)
9341 + return n;
9342 +
9343 + if (n && __access_ok((unsigned long) to, n)) {
9344 + if (!__builtin_constant_p(n))
9345 + check_object_size(from, n, true);
9346 return __copy_user(to, (__force void __user *) from, n);
9347 - else
9348 + } else
9349 return n;
9350 }
9351
9352 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9353 {
9354 + if ((long)n < 0)
9355 + return n;
9356 +
9357 + if (!__builtin_constant_p(n))
9358 + check_object_size(from, n, true);
9359 +
9360 return __copy_user(to, (__force void __user *) from, n);
9361 }
9362
9363 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9364 {
9365 - if (n && __access_ok((unsigned long) from, n))
9366 + if ((long)n < 0)
9367 + return n;
9368 +
9369 + if (n && __access_ok((unsigned long) from, n)) {
9370 + if (!__builtin_constant_p(n))
9371 + check_object_size(to, n, false);
9372 return __copy_user((__force void __user *) to, from, n);
9373 - else
9374 + } else
9375 return n;
9376 }
9377
9378 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9379 {
9380 + if ((long)n < 0)
9381 + return n;
9382 +
9383 return __copy_user((__force void __user *) to, from, n);
9384 }
9385
9386 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9387 index e562d3c..191f176 100644
9388 --- a/arch/sparc/include/asm/uaccess_64.h
9389 +++ b/arch/sparc/include/asm/uaccess_64.h
9390 @@ -10,6 +10,7 @@
9391 #include <linux/compiler.h>
9392 #include <linux/string.h>
9393 #include <linux/thread_info.h>
9394 +#include <linux/kernel.h>
9395 #include <asm/asi.h>
9396 #include <asm/spitfire.h>
9397 #include <asm-generic/uaccess-unaligned.h>
9398 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9399 static inline unsigned long __must_check
9400 copy_from_user(void *to, const void __user *from, unsigned long size)
9401 {
9402 - unsigned long ret = ___copy_from_user(to, from, size);
9403 + unsigned long ret;
9404
9405 + if ((long)size < 0 || size > INT_MAX)
9406 + return size;
9407 +
9408 + if (!__builtin_constant_p(size))
9409 + check_object_size(to, size, false);
9410 +
9411 + ret = ___copy_from_user(to, from, size);
9412 if (unlikely(ret))
9413 ret = copy_from_user_fixup(to, from, size);
9414
9415 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9416 static inline unsigned long __must_check
9417 copy_to_user(void __user *to, const void *from, unsigned long size)
9418 {
9419 - unsigned long ret = ___copy_to_user(to, from, size);
9420 + unsigned long ret;
9421
9422 + if ((long)size < 0 || size > INT_MAX)
9423 + return size;
9424 +
9425 + if (!__builtin_constant_p(size))
9426 + check_object_size(from, size, true);
9427 +
9428 + ret = ___copy_to_user(to, from, size);
9429 if (unlikely(ret))
9430 ret = copy_to_user_fixup(to, from, size);
9431 return ret;
9432 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9433 index d432fb2..6056af1 100644
9434 --- a/arch/sparc/kernel/Makefile
9435 +++ b/arch/sparc/kernel/Makefile
9436 @@ -3,7 +3,7 @@
9437 #
9438
9439 asflags-y := -ansi
9440 -ccflags-y := -Werror
9441 +#ccflags-y := -Werror
9442
9443 extra-y := head_$(BITS).o
9444
9445 diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
9446 index 62d6b15..4d9ac84 100644
9447 --- a/arch/sparc/kernel/ds.c
9448 +++ b/arch/sparc/kernel/ds.c
9449 @@ -851,7 +851,7 @@ void ldom_reboot(const char *boot_command)
9450
9451 strcpy(full_boot_str, "boot ");
9452 strlcpy(full_boot_str + strlen("boot "), boot_command,
9453 - sizeof(full_boot_str + strlen("boot ")));
9454 + sizeof(full_boot_str));
9455 len = strlen(full_boot_str);
9456
9457 if (reboot_data_supported) {
9458 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9459 index fdd819d..5af08c8 100644
9460 --- a/arch/sparc/kernel/process_32.c
9461 +++ b/arch/sparc/kernel/process_32.c
9462 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9463
9464 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9465 r->psr, r->pc, r->npc, r->y, print_tainted());
9466 - printk("PC: <%pS>\n", (void *) r->pc);
9467 + printk("PC: <%pA>\n", (void *) r->pc);
9468 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9469 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9470 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9471 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9472 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9473 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9474 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9475 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9476
9477 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9478 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9479 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9480 rw = (struct reg_window32 *) fp;
9481 pc = rw->ins[7];
9482 printk("[%08lx : ", pc);
9483 - printk("%pS ] ", (void *) pc);
9484 + printk("%pA ] ", (void *) pc);
9485 fp = rw->ins[6];
9486 } while (++count < 16);
9487 printk("\n");
9488 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9489 index baebab2..9cd13b1 100644
9490 --- a/arch/sparc/kernel/process_64.c
9491 +++ b/arch/sparc/kernel/process_64.c
9492 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9493 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9494 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9495 if (regs->tstate & TSTATE_PRIV)
9496 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9497 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9498 }
9499
9500 void show_regs(struct pt_regs *regs)
9501 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9502
9503 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9504 regs->tpc, regs->tnpc, regs->y, print_tainted());
9505 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9506 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9507 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9508 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9509 regs->u_regs[3]);
9510 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9511 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9512 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9513 regs->u_regs[15]);
9514 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9515 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9516 show_regwindow(regs);
9517 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9518 }
9519 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9520 ((tp && tp->task) ? tp->task->pid : -1));
9521
9522 if (gp->tstate & TSTATE_PRIV) {
9523 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9524 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9525 (void *) gp->tpc,
9526 (void *) gp->o7,
9527 (void *) gp->i7,
9528 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9529 index 79cc0d1..ec62734 100644
9530 --- a/arch/sparc/kernel/prom_common.c
9531 +++ b/arch/sparc/kernel/prom_common.c
9532 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9533
9534 unsigned int prom_early_allocated __initdata;
9535
9536 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9537 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9538 .nextprop = prom_common_nextprop,
9539 .getproplen = prom_getproplen,
9540 .getproperty = prom_getproperty,
9541 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9542 index 7ff45e4..a58f271 100644
9543 --- a/arch/sparc/kernel/ptrace_64.c
9544 +++ b/arch/sparc/kernel/ptrace_64.c
9545 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
9546 return ret;
9547 }
9548
9549 +#ifdef CONFIG_GRKERNSEC_SETXID
9550 +extern void gr_delayed_cred_worker(void);
9551 +#endif
9552 +
9553 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9554 {
9555 int ret = 0;
9556 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9557 /* do the secure computing check first */
9558 secure_computing_strict(regs->u_regs[UREG_G1]);
9559
9560 +#ifdef CONFIG_GRKERNSEC_SETXID
9561 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9562 + gr_delayed_cred_worker();
9563 +#endif
9564 +
9565 if (test_thread_flag(TIF_SYSCALL_TRACE))
9566 ret = tracehook_report_syscall_entry(regs);
9567
9568 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9569
9570 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9571 {
9572 +#ifdef CONFIG_GRKERNSEC_SETXID
9573 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9574 + gr_delayed_cred_worker();
9575 +#endif
9576 +
9577 audit_syscall_exit(regs);
9578
9579 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9580 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9581 index e142545..fd29654 100644
9582 --- a/arch/sparc/kernel/smp_64.c
9583 +++ b/arch/sparc/kernel/smp_64.c
9584 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9585 extern unsigned long xcall_flush_dcache_page_spitfire;
9586
9587 #ifdef CONFIG_DEBUG_DCFLUSH
9588 -extern atomic_t dcpage_flushes;
9589 -extern atomic_t dcpage_flushes_xcall;
9590 +extern atomic_unchecked_t dcpage_flushes;
9591 +extern atomic_unchecked_t dcpage_flushes_xcall;
9592 #endif
9593
9594 static inline void __local_flush_dcache_page(struct page *page)
9595 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9596 return;
9597
9598 #ifdef CONFIG_DEBUG_DCFLUSH
9599 - atomic_inc(&dcpage_flushes);
9600 + atomic_inc_unchecked(&dcpage_flushes);
9601 #endif
9602
9603 this_cpu = get_cpu();
9604 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9605 xcall_deliver(data0, __pa(pg_addr),
9606 (u64) pg_addr, cpumask_of(cpu));
9607 #ifdef CONFIG_DEBUG_DCFLUSH
9608 - atomic_inc(&dcpage_flushes_xcall);
9609 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9610 #endif
9611 }
9612 }
9613 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9614 preempt_disable();
9615
9616 #ifdef CONFIG_DEBUG_DCFLUSH
9617 - atomic_inc(&dcpage_flushes);
9618 + atomic_inc_unchecked(&dcpage_flushes);
9619 #endif
9620 data0 = 0;
9621 pg_addr = page_address(page);
9622 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9623 xcall_deliver(data0, __pa(pg_addr),
9624 (u64) pg_addr, cpu_online_mask);
9625 #ifdef CONFIG_DEBUG_DCFLUSH
9626 - atomic_inc(&dcpage_flushes_xcall);
9627 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9628 #endif
9629 }
9630 __local_flush_dcache_page(page);
9631 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9632 index 3a8d184..49498a8 100644
9633 --- a/arch/sparc/kernel/sys_sparc_32.c
9634 +++ b/arch/sparc/kernel/sys_sparc_32.c
9635 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9636 if (len > TASK_SIZE - PAGE_SIZE)
9637 return -ENOMEM;
9638 if (!addr)
9639 - addr = TASK_UNMAPPED_BASE;
9640 + addr = current->mm->mmap_base;
9641
9642 info.flags = 0;
9643 info.length = len;
9644 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9645 index 51561b8..8256764 100644
9646 --- a/arch/sparc/kernel/sys_sparc_64.c
9647 +++ b/arch/sparc/kernel/sys_sparc_64.c
9648 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9649 struct vm_area_struct * vma;
9650 unsigned long task_size = TASK_SIZE;
9651 int do_color_align;
9652 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9653 struct vm_unmapped_area_info info;
9654
9655 if (flags & MAP_FIXED) {
9656 /* We do not accept a shared mapping if it would violate
9657 * cache aliasing constraints.
9658 */
9659 - if ((flags & MAP_SHARED) &&
9660 + if ((filp || (flags & MAP_SHARED)) &&
9661 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9662 return -EINVAL;
9663 return addr;
9664 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9665 if (filp || (flags & MAP_SHARED))
9666 do_color_align = 1;
9667
9668 +#ifdef CONFIG_PAX_RANDMMAP
9669 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9670 +#endif
9671 +
9672 if (addr) {
9673 if (do_color_align)
9674 addr = COLOR_ALIGN(addr, pgoff);
9675 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9676 addr = PAGE_ALIGN(addr);
9677
9678 vma = find_vma(mm, addr);
9679 - if (task_size - len >= addr &&
9680 - (!vma || addr + len <= vma->vm_start))
9681 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9682 return addr;
9683 }
9684
9685 info.flags = 0;
9686 info.length = len;
9687 - info.low_limit = TASK_UNMAPPED_BASE;
9688 + info.low_limit = mm->mmap_base;
9689 info.high_limit = min(task_size, VA_EXCLUDE_START);
9690 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9691 info.align_offset = pgoff << PAGE_SHIFT;
9692 + info.threadstack_offset = offset;
9693 addr = vm_unmapped_area(&info);
9694
9695 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9696 VM_BUG_ON(addr != -ENOMEM);
9697 info.low_limit = VA_EXCLUDE_END;
9698 +
9699 +#ifdef CONFIG_PAX_RANDMMAP
9700 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9701 + info.low_limit += mm->delta_mmap;
9702 +#endif
9703 +
9704 info.high_limit = task_size;
9705 addr = vm_unmapped_area(&info);
9706 }
9707 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9708 unsigned long task_size = STACK_TOP32;
9709 unsigned long addr = addr0;
9710 int do_color_align;
9711 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9712 struct vm_unmapped_area_info info;
9713
9714 /* This should only ever run for 32-bit processes. */
9715 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9716 /* We do not accept a shared mapping if it would violate
9717 * cache aliasing constraints.
9718 */
9719 - if ((flags & MAP_SHARED) &&
9720 + if ((filp || (flags & MAP_SHARED)) &&
9721 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9722 return -EINVAL;
9723 return addr;
9724 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9725 if (filp || (flags & MAP_SHARED))
9726 do_color_align = 1;
9727
9728 +#ifdef CONFIG_PAX_RANDMMAP
9729 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9730 +#endif
9731 +
9732 /* requesting a specific address */
9733 if (addr) {
9734 if (do_color_align)
9735 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9736 addr = PAGE_ALIGN(addr);
9737
9738 vma = find_vma(mm, addr);
9739 - if (task_size - len >= addr &&
9740 - (!vma || addr + len <= vma->vm_start))
9741 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9742 return addr;
9743 }
9744
9745 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9746 info.high_limit = mm->mmap_base;
9747 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9748 info.align_offset = pgoff << PAGE_SHIFT;
9749 + info.threadstack_offset = offset;
9750 addr = vm_unmapped_area(&info);
9751
9752 /*
9753 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9754 VM_BUG_ON(addr != -ENOMEM);
9755 info.flags = 0;
9756 info.low_limit = TASK_UNMAPPED_BASE;
9757 +
9758 +#ifdef CONFIG_PAX_RANDMMAP
9759 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9760 + info.low_limit += mm->delta_mmap;
9761 +#endif
9762 +
9763 info.high_limit = STACK_TOP32;
9764 addr = vm_unmapped_area(&info);
9765 }
9766 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9767 EXPORT_SYMBOL(get_fb_unmapped_area);
9768
9769 /* Essentially the same as PowerPC. */
9770 -static unsigned long mmap_rnd(void)
9771 +static unsigned long mmap_rnd(struct mm_struct *mm)
9772 {
9773 unsigned long rnd = 0UL;
9774
9775 +#ifdef CONFIG_PAX_RANDMMAP
9776 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9777 +#endif
9778 +
9779 if (current->flags & PF_RANDOMIZE) {
9780 unsigned long val = get_random_int();
9781 if (test_thread_flag(TIF_32BIT))
9782 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9783
9784 void arch_pick_mmap_layout(struct mm_struct *mm)
9785 {
9786 - unsigned long random_factor = mmap_rnd();
9787 + unsigned long random_factor = mmap_rnd(mm);
9788 unsigned long gap;
9789
9790 /*
9791 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9792 gap == RLIM_INFINITY ||
9793 sysctl_legacy_va_layout) {
9794 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9795 +
9796 +#ifdef CONFIG_PAX_RANDMMAP
9797 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9798 + mm->mmap_base += mm->delta_mmap;
9799 +#endif
9800 +
9801 mm->get_unmapped_area = arch_get_unmapped_area;
9802 } else {
9803 /* We know it's 32-bit */
9804 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9805 gap = (task_size / 6 * 5);
9806
9807 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9808 +
9809 +#ifdef CONFIG_PAX_RANDMMAP
9810 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9811 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9812 +#endif
9813 +
9814 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9815 }
9816 }
9817 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9818 index 22a1098..6255eb9 100644
9819 --- a/arch/sparc/kernel/syscalls.S
9820 +++ b/arch/sparc/kernel/syscalls.S
9821 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9822 #endif
9823 .align 32
9824 1: ldx [%g6 + TI_FLAGS], %l5
9825 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9826 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9827 be,pt %icc, rtrap
9828 nop
9829 call syscall_trace_leave
9830 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9831
9832 srl %i5, 0, %o5 ! IEU1
9833 srl %i2, 0, %o2 ! IEU0 Group
9834 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9835 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9836 bne,pn %icc, linux_syscall_trace32 ! CTI
9837 mov %i0, %l5 ! IEU1
9838 call %l7 ! CTI Group brk forced
9839 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9840
9841 mov %i3, %o3 ! IEU1
9842 mov %i4, %o4 ! IEU0 Group
9843 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9844 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9845 bne,pn %icc, linux_syscall_trace ! CTI Group
9846 mov %i0, %l5 ! IEU0
9847 2: call %l7 ! CTI Group brk forced
9848 @@ -223,7 +223,7 @@ ret_sys_call:
9849
9850 cmp %o0, -ERESTART_RESTARTBLOCK
9851 bgeu,pn %xcc, 1f
9852 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9853 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9854 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9855
9856 2:
9857 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9858 index 6629829..036032d 100644
9859 --- a/arch/sparc/kernel/traps_32.c
9860 +++ b/arch/sparc/kernel/traps_32.c
9861 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9862 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9863 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9864
9865 +extern void gr_handle_kernel_exploit(void);
9866 +
9867 void die_if_kernel(char *str, struct pt_regs *regs)
9868 {
9869 static int die_counter;
9870 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9871 count++ < 30 &&
9872 (((unsigned long) rw) >= PAGE_OFFSET) &&
9873 !(((unsigned long) rw) & 0x7)) {
9874 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9875 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9876 (void *) rw->ins[7]);
9877 rw = (struct reg_window32 *)rw->ins[6];
9878 }
9879 }
9880 printk("Instruction DUMP:");
9881 instruction_dump ((unsigned long *) regs->pc);
9882 - if(regs->psr & PSR_PS)
9883 + if(regs->psr & PSR_PS) {
9884 + gr_handle_kernel_exploit();
9885 do_exit(SIGKILL);
9886 + }
9887 do_exit(SIGSEGV);
9888 }
9889
9890 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9891 index b3f833a..f485f80 100644
9892 --- a/arch/sparc/kernel/traps_64.c
9893 +++ b/arch/sparc/kernel/traps_64.c
9894 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9895 i + 1,
9896 p->trapstack[i].tstate, p->trapstack[i].tpc,
9897 p->trapstack[i].tnpc, p->trapstack[i].tt);
9898 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9899 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9900 }
9901 }
9902
9903 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9904
9905 lvl -= 0x100;
9906 if (regs->tstate & TSTATE_PRIV) {
9907 +
9908 +#ifdef CONFIG_PAX_REFCOUNT
9909 + if (lvl == 6)
9910 + pax_report_refcount_overflow(regs);
9911 +#endif
9912 +
9913 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9914 die_if_kernel(buffer, regs);
9915 }
9916 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9917 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9918 {
9919 char buffer[32];
9920 -
9921 +
9922 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9923 0, lvl, SIGTRAP) == NOTIFY_STOP)
9924 return;
9925
9926 +#ifdef CONFIG_PAX_REFCOUNT
9927 + if (lvl == 6)
9928 + pax_report_refcount_overflow(regs);
9929 +#endif
9930 +
9931 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9932
9933 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9934 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9935 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9936 printk("%s" "ERROR(%d): ",
9937 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9938 - printk("TPC<%pS>\n", (void *) regs->tpc);
9939 + printk("TPC<%pA>\n", (void *) regs->tpc);
9940 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9941 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9942 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9943 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9944 smp_processor_id(),
9945 (type & 0x1) ? 'I' : 'D',
9946 regs->tpc);
9947 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9948 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9949 panic("Irrecoverable Cheetah+ parity error.");
9950 }
9951
9952 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9953 smp_processor_id(),
9954 (type & 0x1) ? 'I' : 'D',
9955 regs->tpc);
9956 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9957 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9958 }
9959
9960 struct sun4v_error_entry {
9961 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
9962 /*0x38*/u64 reserved_5;
9963 };
9964
9965 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9966 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9967 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9968 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9969
9970 static const char *sun4v_err_type_to_str(u8 type)
9971 {
9972 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
9973 }
9974
9975 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9976 - int cpu, const char *pfx, atomic_t *ocnt)
9977 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
9978 {
9979 u64 *raw_ptr = (u64 *) ent;
9980 u32 attrs;
9981 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9982
9983 show_regs(regs);
9984
9985 - if ((cnt = atomic_read(ocnt)) != 0) {
9986 - atomic_set(ocnt, 0);
9987 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
9988 + atomic_set_unchecked(ocnt, 0);
9989 wmb();
9990 printk("%s: Queue overflowed %d times.\n",
9991 pfx, cnt);
9992 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
9993 */
9994 void sun4v_resum_overflow(struct pt_regs *regs)
9995 {
9996 - atomic_inc(&sun4v_resum_oflow_cnt);
9997 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
9998 }
9999
10000 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10001 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10002 /* XXX Actually even this can make not that much sense. Perhaps
10003 * XXX we should just pull the plug and panic directly from here?
10004 */
10005 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10006 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10007 }
10008
10009 unsigned long sun4v_err_itlb_vaddr;
10010 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10011
10012 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10013 regs->tpc, tl);
10014 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10015 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10016 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10017 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10018 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10019 (void *) regs->u_regs[UREG_I7]);
10020 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10021 "pte[%lx] error[%lx]\n",
10022 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10023
10024 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10025 regs->tpc, tl);
10026 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10027 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10028 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10029 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10030 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10031 (void *) regs->u_regs[UREG_I7]);
10032 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10033 "pte[%lx] error[%lx]\n",
10034 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10035 fp = (unsigned long)sf->fp + STACK_BIAS;
10036 }
10037
10038 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10039 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10040 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10041 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10042 int index = tsk->curr_ret_stack;
10043 if (tsk->ret_stack && index >= graph) {
10044 pc = tsk->ret_stack[index - graph].ret;
10045 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10046 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10047 graph++;
10048 }
10049 }
10050 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10051 return (struct reg_window *) (fp + STACK_BIAS);
10052 }
10053
10054 +extern void gr_handle_kernel_exploit(void);
10055 +
10056 void die_if_kernel(char *str, struct pt_regs *regs)
10057 {
10058 static int die_counter;
10059 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10060 while (rw &&
10061 count++ < 30 &&
10062 kstack_valid(tp, (unsigned long) rw)) {
10063 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10064 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10065 (void *) rw->ins[7]);
10066
10067 rw = kernel_stack_up(rw);
10068 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10069 }
10070 user_instruction_dump ((unsigned int __user *) regs->tpc);
10071 }
10072 - if (regs->tstate & TSTATE_PRIV)
10073 + if (regs->tstate & TSTATE_PRIV) {
10074 + gr_handle_kernel_exploit();
10075 do_exit(SIGKILL);
10076 + }
10077 do_exit(SIGSEGV);
10078 }
10079 EXPORT_SYMBOL(die_if_kernel);
10080 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10081 index 8201c25e..072a2a7 100644
10082 --- a/arch/sparc/kernel/unaligned_64.c
10083 +++ b/arch/sparc/kernel/unaligned_64.c
10084 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10085 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10086
10087 if (__ratelimit(&ratelimit)) {
10088 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10089 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10090 regs->tpc, (void *) regs->tpc);
10091 }
10092 }
10093 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10094 index dbe119b..089c7c1 100644
10095 --- a/arch/sparc/lib/Makefile
10096 +++ b/arch/sparc/lib/Makefile
10097 @@ -2,7 +2,7 @@
10098 #
10099
10100 asflags-y := -ansi -DST_DIV0=0x02
10101 -ccflags-y := -Werror
10102 +#ccflags-y := -Werror
10103
10104 lib-$(CONFIG_SPARC32) += ashrdi3.o
10105 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10106 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10107 index 85c233d..68500e0 100644
10108 --- a/arch/sparc/lib/atomic_64.S
10109 +++ b/arch/sparc/lib/atomic_64.S
10110 @@ -17,7 +17,12 @@
10111 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10112 BACKOFF_SETUP(%o2)
10113 1: lduw [%o1], %g1
10114 - add %g1, %o0, %g7
10115 + addcc %g1, %o0, %g7
10116 +
10117 +#ifdef CONFIG_PAX_REFCOUNT
10118 + tvs %icc, 6
10119 +#endif
10120 +
10121 cas [%o1], %g1, %g7
10122 cmp %g1, %g7
10123 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10124 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10125 2: BACKOFF_SPIN(%o2, %o3, 1b)
10126 ENDPROC(atomic_add)
10127
10128 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10129 + BACKOFF_SETUP(%o2)
10130 +1: lduw [%o1], %g1
10131 + add %g1, %o0, %g7
10132 + cas [%o1], %g1, %g7
10133 + cmp %g1, %g7
10134 + bne,pn %icc, 2f
10135 + nop
10136 + retl
10137 + nop
10138 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10139 +ENDPROC(atomic_add_unchecked)
10140 +
10141 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10142 BACKOFF_SETUP(%o2)
10143 1: lduw [%o1], %g1
10144 - sub %g1, %o0, %g7
10145 + subcc %g1, %o0, %g7
10146 +
10147 +#ifdef CONFIG_PAX_REFCOUNT
10148 + tvs %icc, 6
10149 +#endif
10150 +
10151 cas [%o1], %g1, %g7
10152 cmp %g1, %g7
10153 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10154 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10155 2: BACKOFF_SPIN(%o2, %o3, 1b)
10156 ENDPROC(atomic_sub)
10157
10158 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10159 + BACKOFF_SETUP(%o2)
10160 +1: lduw [%o1], %g1
10161 + sub %g1, %o0, %g7
10162 + cas [%o1], %g1, %g7
10163 + cmp %g1, %g7
10164 + bne,pn %icc, 2f
10165 + nop
10166 + retl
10167 + nop
10168 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10169 +ENDPROC(atomic_sub_unchecked)
10170 +
10171 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10172 BACKOFF_SETUP(%o2)
10173 1: lduw [%o1], %g1
10174 - add %g1, %o0, %g7
10175 + addcc %g1, %o0, %g7
10176 +
10177 +#ifdef CONFIG_PAX_REFCOUNT
10178 + tvs %icc, 6
10179 +#endif
10180 +
10181 cas [%o1], %g1, %g7
10182 cmp %g1, %g7
10183 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10184 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10185 2: BACKOFF_SPIN(%o2, %o3, 1b)
10186 ENDPROC(atomic_add_ret)
10187
10188 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10189 + BACKOFF_SETUP(%o2)
10190 +1: lduw [%o1], %g1
10191 + addcc %g1, %o0, %g7
10192 + cas [%o1], %g1, %g7
10193 + cmp %g1, %g7
10194 + bne,pn %icc, 2f
10195 + add %g7, %o0, %g7
10196 + sra %g7, 0, %o0
10197 + retl
10198 + nop
10199 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10200 +ENDPROC(atomic_add_ret_unchecked)
10201 +
10202 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10203 BACKOFF_SETUP(%o2)
10204 1: lduw [%o1], %g1
10205 - sub %g1, %o0, %g7
10206 + subcc %g1, %o0, %g7
10207 +
10208 +#ifdef CONFIG_PAX_REFCOUNT
10209 + tvs %icc, 6
10210 +#endif
10211 +
10212 cas [%o1], %g1, %g7
10213 cmp %g1, %g7
10214 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10215 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10216 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10217 BACKOFF_SETUP(%o2)
10218 1: ldx [%o1], %g1
10219 - add %g1, %o0, %g7
10220 + addcc %g1, %o0, %g7
10221 +
10222 +#ifdef CONFIG_PAX_REFCOUNT
10223 + tvs %xcc, 6
10224 +#endif
10225 +
10226 casx [%o1], %g1, %g7
10227 cmp %g1, %g7
10228 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10229 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10230 2: BACKOFF_SPIN(%o2, %o3, 1b)
10231 ENDPROC(atomic64_add)
10232
10233 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10234 + BACKOFF_SETUP(%o2)
10235 +1: ldx [%o1], %g1
10236 + addcc %g1, %o0, %g7
10237 + casx [%o1], %g1, %g7
10238 + cmp %g1, %g7
10239 + bne,pn %xcc, 2f
10240 + nop
10241 + retl
10242 + nop
10243 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10244 +ENDPROC(atomic64_add_unchecked)
10245 +
10246 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10247 BACKOFF_SETUP(%o2)
10248 1: ldx [%o1], %g1
10249 - sub %g1, %o0, %g7
10250 + subcc %g1, %o0, %g7
10251 +
10252 +#ifdef CONFIG_PAX_REFCOUNT
10253 + tvs %xcc, 6
10254 +#endif
10255 +
10256 casx [%o1], %g1, %g7
10257 cmp %g1, %g7
10258 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10259 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10260 2: BACKOFF_SPIN(%o2, %o3, 1b)
10261 ENDPROC(atomic64_sub)
10262
10263 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10264 + BACKOFF_SETUP(%o2)
10265 +1: ldx [%o1], %g1
10266 + subcc %g1, %o0, %g7
10267 + casx [%o1], %g1, %g7
10268 + cmp %g1, %g7
10269 + bne,pn %xcc, 2f
10270 + nop
10271 + retl
10272 + nop
10273 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10274 +ENDPROC(atomic64_sub_unchecked)
10275 +
10276 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10277 BACKOFF_SETUP(%o2)
10278 1: ldx [%o1], %g1
10279 - add %g1, %o0, %g7
10280 + addcc %g1, %o0, %g7
10281 +
10282 +#ifdef CONFIG_PAX_REFCOUNT
10283 + tvs %xcc, 6
10284 +#endif
10285 +
10286 casx [%o1], %g1, %g7
10287 cmp %g1, %g7
10288 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10289 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10290 2: BACKOFF_SPIN(%o2, %o3, 1b)
10291 ENDPROC(atomic64_add_ret)
10292
10293 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10294 + BACKOFF_SETUP(%o2)
10295 +1: ldx [%o1], %g1
10296 + addcc %g1, %o0, %g7
10297 + casx [%o1], %g1, %g7
10298 + cmp %g1, %g7
10299 + bne,pn %xcc, 2f
10300 + add %g7, %o0, %g7
10301 + mov %g7, %o0
10302 + retl
10303 + nop
10304 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10305 +ENDPROC(atomic64_add_ret_unchecked)
10306 +
10307 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10308 BACKOFF_SETUP(%o2)
10309 1: ldx [%o1], %g1
10310 - sub %g1, %o0, %g7
10311 + subcc %g1, %o0, %g7
10312 +
10313 +#ifdef CONFIG_PAX_REFCOUNT
10314 + tvs %xcc, 6
10315 +#endif
10316 +
10317 casx [%o1], %g1, %g7
10318 cmp %g1, %g7
10319 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10320 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10321 index 0c4e35e..745d3e4 100644
10322 --- a/arch/sparc/lib/ksyms.c
10323 +++ b/arch/sparc/lib/ksyms.c
10324 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
10325
10326 /* Atomic counter implementation. */
10327 EXPORT_SYMBOL(atomic_add);
10328 +EXPORT_SYMBOL(atomic_add_unchecked);
10329 EXPORT_SYMBOL(atomic_add_ret);
10330 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10331 EXPORT_SYMBOL(atomic_sub);
10332 +EXPORT_SYMBOL(atomic_sub_unchecked);
10333 EXPORT_SYMBOL(atomic_sub_ret);
10334 EXPORT_SYMBOL(atomic64_add);
10335 +EXPORT_SYMBOL(atomic64_add_unchecked);
10336 EXPORT_SYMBOL(atomic64_add_ret);
10337 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10338 EXPORT_SYMBOL(atomic64_sub);
10339 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10340 EXPORT_SYMBOL(atomic64_sub_ret);
10341 EXPORT_SYMBOL(atomic64_dec_if_positive);
10342
10343 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10344 index 30c3ecc..736f015 100644
10345 --- a/arch/sparc/mm/Makefile
10346 +++ b/arch/sparc/mm/Makefile
10347 @@ -2,7 +2,7 @@
10348 #
10349
10350 asflags-y := -ansi
10351 -ccflags-y := -Werror
10352 +#ccflags-y := -Werror
10353
10354 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10355 obj-y += fault_$(BITS).o
10356 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10357 index e98bfda..ea8d221 100644
10358 --- a/arch/sparc/mm/fault_32.c
10359 +++ b/arch/sparc/mm/fault_32.c
10360 @@ -21,6 +21,9 @@
10361 #include <linux/perf_event.h>
10362 #include <linux/interrupt.h>
10363 #include <linux/kdebug.h>
10364 +#include <linux/slab.h>
10365 +#include <linux/pagemap.h>
10366 +#include <linux/compiler.h>
10367
10368 #include <asm/page.h>
10369 #include <asm/pgtable.h>
10370 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10371 return safe_compute_effective_address(regs, insn);
10372 }
10373
10374 +#ifdef CONFIG_PAX_PAGEEXEC
10375 +#ifdef CONFIG_PAX_DLRESOLVE
10376 +static void pax_emuplt_close(struct vm_area_struct *vma)
10377 +{
10378 + vma->vm_mm->call_dl_resolve = 0UL;
10379 +}
10380 +
10381 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10382 +{
10383 + unsigned int *kaddr;
10384 +
10385 + vmf->page = alloc_page(GFP_HIGHUSER);
10386 + if (!vmf->page)
10387 + return VM_FAULT_OOM;
10388 +
10389 + kaddr = kmap(vmf->page);
10390 + memset(kaddr, 0, PAGE_SIZE);
10391 + kaddr[0] = 0x9DE3BFA8U; /* save */
10392 + flush_dcache_page(vmf->page);
10393 + kunmap(vmf->page);
10394 + return VM_FAULT_MAJOR;
10395 +}
10396 +
10397 +static const struct vm_operations_struct pax_vm_ops = {
10398 + .close = pax_emuplt_close,
10399 + .fault = pax_emuplt_fault
10400 +};
10401 +
10402 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10403 +{
10404 + int ret;
10405 +
10406 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10407 + vma->vm_mm = current->mm;
10408 + vma->vm_start = addr;
10409 + vma->vm_end = addr + PAGE_SIZE;
10410 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10411 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10412 + vma->vm_ops = &pax_vm_ops;
10413 +
10414 + ret = insert_vm_struct(current->mm, vma);
10415 + if (ret)
10416 + return ret;
10417 +
10418 + ++current->mm->total_vm;
10419 + return 0;
10420 +}
10421 +#endif
10422 +
10423 +/*
10424 + * PaX: decide what to do with offenders (regs->pc = fault address)
10425 + *
10426 + * returns 1 when task should be killed
10427 + * 2 when patched PLT trampoline was detected
10428 + * 3 when unpatched PLT trampoline was detected
10429 + */
10430 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10431 +{
10432 +
10433 +#ifdef CONFIG_PAX_EMUPLT
10434 + int err;
10435 +
10436 + do { /* PaX: patched PLT emulation #1 */
10437 + unsigned int sethi1, sethi2, jmpl;
10438 +
10439 + err = get_user(sethi1, (unsigned int *)regs->pc);
10440 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10441 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10442 +
10443 + if (err)
10444 + break;
10445 +
10446 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10447 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10448 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10449 + {
10450 + unsigned int addr;
10451 +
10452 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10453 + addr = regs->u_regs[UREG_G1];
10454 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10455 + regs->pc = addr;
10456 + regs->npc = addr+4;
10457 + return 2;
10458 + }
10459 + } while (0);
10460 +
10461 + do { /* PaX: patched PLT emulation #2 */
10462 + unsigned int ba;
10463 +
10464 + err = get_user(ba, (unsigned int *)regs->pc);
10465 +
10466 + if (err)
10467 + break;
10468 +
10469 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10470 + unsigned int addr;
10471 +
10472 + if ((ba & 0xFFC00000U) == 0x30800000U)
10473 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10474 + else
10475 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10476 + regs->pc = addr;
10477 + regs->npc = addr+4;
10478 + return 2;
10479 + }
10480 + } while (0);
10481 +
10482 + do { /* PaX: patched PLT emulation #3 */
10483 + unsigned int sethi, bajmpl, nop;
10484 +
10485 + err = get_user(sethi, (unsigned int *)regs->pc);
10486 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10487 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10488 +
10489 + if (err)
10490 + break;
10491 +
10492 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10493 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10494 + nop == 0x01000000U)
10495 + {
10496 + unsigned int addr;
10497 +
10498 + addr = (sethi & 0x003FFFFFU) << 10;
10499 + regs->u_regs[UREG_G1] = addr;
10500 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10501 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10502 + else
10503 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10504 + regs->pc = addr;
10505 + regs->npc = addr+4;
10506 + return 2;
10507 + }
10508 + } while (0);
10509 +
10510 + do { /* PaX: unpatched PLT emulation step 1 */
10511 + unsigned int sethi, ba, nop;
10512 +
10513 + err = get_user(sethi, (unsigned int *)regs->pc);
10514 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10515 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10516 +
10517 + if (err)
10518 + break;
10519 +
10520 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10521 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10522 + nop == 0x01000000U)
10523 + {
10524 + unsigned int addr, save, call;
10525 +
10526 + if ((ba & 0xFFC00000U) == 0x30800000U)
10527 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10528 + else
10529 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10530 +
10531 + err = get_user(save, (unsigned int *)addr);
10532 + err |= get_user(call, (unsigned int *)(addr+4));
10533 + err |= get_user(nop, (unsigned int *)(addr+8));
10534 + if (err)
10535 + break;
10536 +
10537 +#ifdef CONFIG_PAX_DLRESOLVE
10538 + if (save == 0x9DE3BFA8U &&
10539 + (call & 0xC0000000U) == 0x40000000U &&
10540 + nop == 0x01000000U)
10541 + {
10542 + struct vm_area_struct *vma;
10543 + unsigned long call_dl_resolve;
10544 +
10545 + down_read(&current->mm->mmap_sem);
10546 + call_dl_resolve = current->mm->call_dl_resolve;
10547 + up_read(&current->mm->mmap_sem);
10548 + if (likely(call_dl_resolve))
10549 + goto emulate;
10550 +
10551 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10552 +
10553 + down_write(&current->mm->mmap_sem);
10554 + if (current->mm->call_dl_resolve) {
10555 + call_dl_resolve = current->mm->call_dl_resolve;
10556 + up_write(&current->mm->mmap_sem);
10557 + if (vma)
10558 + kmem_cache_free(vm_area_cachep, vma);
10559 + goto emulate;
10560 + }
10561 +
10562 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10563 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10564 + up_write(&current->mm->mmap_sem);
10565 + if (vma)
10566 + kmem_cache_free(vm_area_cachep, vma);
10567 + return 1;
10568 + }
10569 +
10570 + if (pax_insert_vma(vma, call_dl_resolve)) {
10571 + up_write(&current->mm->mmap_sem);
10572 + kmem_cache_free(vm_area_cachep, vma);
10573 + return 1;
10574 + }
10575 +
10576 + current->mm->call_dl_resolve = call_dl_resolve;
10577 + up_write(&current->mm->mmap_sem);
10578 +
10579 +emulate:
10580 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10581 + regs->pc = call_dl_resolve;
10582 + regs->npc = addr+4;
10583 + return 3;
10584 + }
10585 +#endif
10586 +
10587 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10588 + if ((save & 0xFFC00000U) == 0x05000000U &&
10589 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10590 + nop == 0x01000000U)
10591 + {
10592 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10593 + regs->u_regs[UREG_G2] = addr + 4;
10594 + addr = (save & 0x003FFFFFU) << 10;
10595 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10596 + regs->pc = addr;
10597 + regs->npc = addr+4;
10598 + return 3;
10599 + }
10600 + }
10601 + } while (0);
10602 +
10603 + do { /* PaX: unpatched PLT emulation step 2 */
10604 + unsigned int save, call, nop;
10605 +
10606 + err = get_user(save, (unsigned int *)(regs->pc-4));
10607 + err |= get_user(call, (unsigned int *)regs->pc);
10608 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10609 + if (err)
10610 + break;
10611 +
10612 + if (save == 0x9DE3BFA8U &&
10613 + (call & 0xC0000000U) == 0x40000000U &&
10614 + nop == 0x01000000U)
10615 + {
10616 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10617 +
10618 + regs->u_regs[UREG_RETPC] = regs->pc;
10619 + regs->pc = dl_resolve;
10620 + regs->npc = dl_resolve+4;
10621 + return 3;
10622 + }
10623 + } while (0);
10624 +#endif
10625 +
10626 + return 1;
10627 +}
10628 +
10629 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10630 +{
10631 + unsigned long i;
10632 +
10633 + printk(KERN_ERR "PAX: bytes at PC: ");
10634 + for (i = 0; i < 8; i++) {
10635 + unsigned int c;
10636 + if (get_user(c, (unsigned int *)pc+i))
10637 + printk(KERN_CONT "???????? ");
10638 + else
10639 + printk(KERN_CONT "%08x ", c);
10640 + }
10641 + printk("\n");
10642 +}
10643 +#endif
10644 +
10645 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10646 int text_fault)
10647 {
10648 @@ -230,6 +504,24 @@ good_area:
10649 if (!(vma->vm_flags & VM_WRITE))
10650 goto bad_area;
10651 } else {
10652 +
10653 +#ifdef CONFIG_PAX_PAGEEXEC
10654 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10655 + up_read(&mm->mmap_sem);
10656 + switch (pax_handle_fetch_fault(regs)) {
10657 +
10658 +#ifdef CONFIG_PAX_EMUPLT
10659 + case 2:
10660 + case 3:
10661 + return;
10662 +#endif
10663 +
10664 + }
10665 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10666 + do_group_exit(SIGKILL);
10667 + }
10668 +#endif
10669 +
10670 /* Allow reads even for write-only mappings */
10671 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10672 goto bad_area;
10673 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10674 index 5062ff3..e0b75f3 100644
10675 --- a/arch/sparc/mm/fault_64.c
10676 +++ b/arch/sparc/mm/fault_64.c
10677 @@ -21,6 +21,9 @@
10678 #include <linux/kprobes.h>
10679 #include <linux/kdebug.h>
10680 #include <linux/percpu.h>
10681 +#include <linux/slab.h>
10682 +#include <linux/pagemap.h>
10683 +#include <linux/compiler.h>
10684
10685 #include <asm/page.h>
10686 #include <asm/pgtable.h>
10687 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10688 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10689 regs->tpc);
10690 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10691 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10692 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10693 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10694 dump_stack();
10695 unhandled_fault(regs->tpc, current, regs);
10696 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10697 show_regs(regs);
10698 }
10699
10700 +#ifdef CONFIG_PAX_PAGEEXEC
10701 +#ifdef CONFIG_PAX_DLRESOLVE
10702 +static void pax_emuplt_close(struct vm_area_struct *vma)
10703 +{
10704 + vma->vm_mm->call_dl_resolve = 0UL;
10705 +}
10706 +
10707 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10708 +{
10709 + unsigned int *kaddr;
10710 +
10711 + vmf->page = alloc_page(GFP_HIGHUSER);
10712 + if (!vmf->page)
10713 + return VM_FAULT_OOM;
10714 +
10715 + kaddr = kmap(vmf->page);
10716 + memset(kaddr, 0, PAGE_SIZE);
10717 + kaddr[0] = 0x9DE3BFA8U; /* save */
10718 + flush_dcache_page(vmf->page);
10719 + kunmap(vmf->page);
10720 + return VM_FAULT_MAJOR;
10721 +}
10722 +
10723 +static const struct vm_operations_struct pax_vm_ops = {
10724 + .close = pax_emuplt_close,
10725 + .fault = pax_emuplt_fault
10726 +};
10727 +
10728 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10729 +{
10730 + int ret;
10731 +
10732 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10733 + vma->vm_mm = current->mm;
10734 + vma->vm_start = addr;
10735 + vma->vm_end = addr + PAGE_SIZE;
10736 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10737 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10738 + vma->vm_ops = &pax_vm_ops;
10739 +
10740 + ret = insert_vm_struct(current->mm, vma);
10741 + if (ret)
10742 + return ret;
10743 +
10744 + ++current->mm->total_vm;
10745 + return 0;
10746 +}
10747 +#endif
10748 +
10749 +/*
10750 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10751 + *
10752 + * returns 1 when task should be killed
10753 + * 2 when patched PLT trampoline was detected
10754 + * 3 when unpatched PLT trampoline was detected
10755 + */
10756 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10757 +{
10758 +
10759 +#ifdef CONFIG_PAX_EMUPLT
10760 + int err;
10761 +
10762 + do { /* PaX: patched PLT emulation #1 */
10763 + unsigned int sethi1, sethi2, jmpl;
10764 +
10765 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10766 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10767 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10768 +
10769 + if (err)
10770 + break;
10771 +
10772 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10773 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10774 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10775 + {
10776 + unsigned long addr;
10777 +
10778 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10779 + addr = regs->u_regs[UREG_G1];
10780 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10781 +
10782 + if (test_thread_flag(TIF_32BIT))
10783 + addr &= 0xFFFFFFFFUL;
10784 +
10785 + regs->tpc = addr;
10786 + regs->tnpc = addr+4;
10787 + return 2;
10788 + }
10789 + } while (0);
10790 +
10791 + do { /* PaX: patched PLT emulation #2 */
10792 + unsigned int ba;
10793 +
10794 + err = get_user(ba, (unsigned int *)regs->tpc);
10795 +
10796 + if (err)
10797 + break;
10798 +
10799 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10800 + unsigned long addr;
10801 +
10802 + if ((ba & 0xFFC00000U) == 0x30800000U)
10803 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10804 + else
10805 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10806 +
10807 + if (test_thread_flag(TIF_32BIT))
10808 + addr &= 0xFFFFFFFFUL;
10809 +
10810 + regs->tpc = addr;
10811 + regs->tnpc = addr+4;
10812 + return 2;
10813 + }
10814 + } while (0);
10815 +
10816 + do { /* PaX: patched PLT emulation #3 */
10817 + unsigned int sethi, bajmpl, nop;
10818 +
10819 + err = get_user(sethi, (unsigned int *)regs->tpc);
10820 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10821 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10822 +
10823 + if (err)
10824 + break;
10825 +
10826 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10827 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10828 + nop == 0x01000000U)
10829 + {
10830 + unsigned long addr;
10831 +
10832 + addr = (sethi & 0x003FFFFFU) << 10;
10833 + regs->u_regs[UREG_G1] = addr;
10834 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10835 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10836 + else
10837 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10838 +
10839 + if (test_thread_flag(TIF_32BIT))
10840 + addr &= 0xFFFFFFFFUL;
10841 +
10842 + regs->tpc = addr;
10843 + regs->tnpc = addr+4;
10844 + return 2;
10845 + }
10846 + } while (0);
10847 +
10848 + do { /* PaX: patched PLT emulation #4 */
10849 + unsigned int sethi, mov1, call, mov2;
10850 +
10851 + err = get_user(sethi, (unsigned int *)regs->tpc);
10852 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10853 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10854 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10855 +
10856 + if (err)
10857 + break;
10858 +
10859 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10860 + mov1 == 0x8210000FU &&
10861 + (call & 0xC0000000U) == 0x40000000U &&
10862 + mov2 == 0x9E100001U)
10863 + {
10864 + unsigned long addr;
10865 +
10866 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10867 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10868 +
10869 + if (test_thread_flag(TIF_32BIT))
10870 + addr &= 0xFFFFFFFFUL;
10871 +
10872 + regs->tpc = addr;
10873 + regs->tnpc = addr+4;
10874 + return 2;
10875 + }
10876 + } while (0);
10877 +
10878 + do { /* PaX: patched PLT emulation #5 */
10879 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10880 +
10881 + err = get_user(sethi, (unsigned int *)regs->tpc);
10882 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10883 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10884 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10885 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10886 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10887 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10888 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10889 +
10890 + if (err)
10891 + break;
10892 +
10893 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10894 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10895 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10896 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10897 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10898 + sllx == 0x83287020U &&
10899 + jmpl == 0x81C04005U &&
10900 + nop == 0x01000000U)
10901 + {
10902 + unsigned long addr;
10903 +
10904 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10905 + regs->u_regs[UREG_G1] <<= 32;
10906 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10907 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10908 + regs->tpc = addr;
10909 + regs->tnpc = addr+4;
10910 + return 2;
10911 + }
10912 + } while (0);
10913 +
10914 + do { /* PaX: patched PLT emulation #6 */
10915 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10916 +
10917 + err = get_user(sethi, (unsigned int *)regs->tpc);
10918 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10919 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10920 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10921 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10922 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10923 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10924 +
10925 + if (err)
10926 + break;
10927 +
10928 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10929 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10930 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10931 + sllx == 0x83287020U &&
10932 + (or & 0xFFFFE000U) == 0x8A116000U &&
10933 + jmpl == 0x81C04005U &&
10934 + nop == 0x01000000U)
10935 + {
10936 + unsigned long addr;
10937 +
10938 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10939 + regs->u_regs[UREG_G1] <<= 32;
10940 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10941 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10942 + regs->tpc = addr;
10943 + regs->tnpc = addr+4;
10944 + return 2;
10945 + }
10946 + } while (0);
10947 +
10948 + do { /* PaX: unpatched PLT emulation step 1 */
10949 + unsigned int sethi, ba, nop;
10950 +
10951 + err = get_user(sethi, (unsigned int *)regs->tpc);
10952 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10953 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10954 +
10955 + if (err)
10956 + break;
10957 +
10958 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10959 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10960 + nop == 0x01000000U)
10961 + {
10962 + unsigned long addr;
10963 + unsigned int save, call;
10964 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10965 +
10966 + if ((ba & 0xFFC00000U) == 0x30800000U)
10967 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10968 + else
10969 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10970 +
10971 + if (test_thread_flag(TIF_32BIT))
10972 + addr &= 0xFFFFFFFFUL;
10973 +
10974 + err = get_user(save, (unsigned int *)addr);
10975 + err |= get_user(call, (unsigned int *)(addr+4));
10976 + err |= get_user(nop, (unsigned int *)(addr+8));
10977 + if (err)
10978 + break;
10979 +
10980 +#ifdef CONFIG_PAX_DLRESOLVE
10981 + if (save == 0x9DE3BFA8U &&
10982 + (call & 0xC0000000U) == 0x40000000U &&
10983 + nop == 0x01000000U)
10984 + {
10985 + struct vm_area_struct *vma;
10986 + unsigned long call_dl_resolve;
10987 +
10988 + down_read(&current->mm->mmap_sem);
10989 + call_dl_resolve = current->mm->call_dl_resolve;
10990 + up_read(&current->mm->mmap_sem);
10991 + if (likely(call_dl_resolve))
10992 + goto emulate;
10993 +
10994 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10995 +
10996 + down_write(&current->mm->mmap_sem);
10997 + if (current->mm->call_dl_resolve) {
10998 + call_dl_resolve = current->mm->call_dl_resolve;
10999 + up_write(&current->mm->mmap_sem);
11000 + if (vma)
11001 + kmem_cache_free(vm_area_cachep, vma);
11002 + goto emulate;
11003 + }
11004 +
11005 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11006 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11007 + up_write(&current->mm->mmap_sem);
11008 + if (vma)
11009 + kmem_cache_free(vm_area_cachep, vma);
11010 + return 1;
11011 + }
11012 +
11013 + if (pax_insert_vma(vma, call_dl_resolve)) {
11014 + up_write(&current->mm->mmap_sem);
11015 + kmem_cache_free(vm_area_cachep, vma);
11016 + return 1;
11017 + }
11018 +
11019 + current->mm->call_dl_resolve = call_dl_resolve;
11020 + up_write(&current->mm->mmap_sem);
11021 +
11022 +emulate:
11023 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11024 + regs->tpc = call_dl_resolve;
11025 + regs->tnpc = addr+4;
11026 + return 3;
11027 + }
11028 +#endif
11029 +
11030 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11031 + if ((save & 0xFFC00000U) == 0x05000000U &&
11032 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11033 + nop == 0x01000000U)
11034 + {
11035 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11036 + regs->u_regs[UREG_G2] = addr + 4;
11037 + addr = (save & 0x003FFFFFU) << 10;
11038 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11039 +
11040 + if (test_thread_flag(TIF_32BIT))
11041 + addr &= 0xFFFFFFFFUL;
11042 +
11043 + regs->tpc = addr;
11044 + regs->tnpc = addr+4;
11045 + return 3;
11046 + }
11047 +
11048 + /* PaX: 64-bit PLT stub */
11049 + err = get_user(sethi1, (unsigned int *)addr);
11050 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11051 + err |= get_user(or1, (unsigned int *)(addr+8));
11052 + err |= get_user(or2, (unsigned int *)(addr+12));
11053 + err |= get_user(sllx, (unsigned int *)(addr+16));
11054 + err |= get_user(add, (unsigned int *)(addr+20));
11055 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11056 + err |= get_user(nop, (unsigned int *)(addr+28));
11057 + if (err)
11058 + break;
11059 +
11060 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11061 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11062 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11063 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11064 + sllx == 0x89293020U &&
11065 + add == 0x8A010005U &&
11066 + jmpl == 0x89C14000U &&
11067 + nop == 0x01000000U)
11068 + {
11069 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11070 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11071 + regs->u_regs[UREG_G4] <<= 32;
11072 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11073 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11074 + regs->u_regs[UREG_G4] = addr + 24;
11075 + addr = regs->u_regs[UREG_G5];
11076 + regs->tpc = addr;
11077 + regs->tnpc = addr+4;
11078 + return 3;
11079 + }
11080 + }
11081 + } while (0);
11082 +
11083 +#ifdef CONFIG_PAX_DLRESOLVE
11084 + do { /* PaX: unpatched PLT emulation step 2 */
11085 + unsigned int save, call, nop;
11086 +
11087 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11088 + err |= get_user(call, (unsigned int *)regs->tpc);
11089 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11090 + if (err)
11091 + break;
11092 +
11093 + if (save == 0x9DE3BFA8U &&
11094 + (call & 0xC0000000U) == 0x40000000U &&
11095 + nop == 0x01000000U)
11096 + {
11097 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11098 +
11099 + if (test_thread_flag(TIF_32BIT))
11100 + dl_resolve &= 0xFFFFFFFFUL;
11101 +
11102 + regs->u_regs[UREG_RETPC] = regs->tpc;
11103 + regs->tpc = dl_resolve;
11104 + regs->tnpc = dl_resolve+4;
11105 + return 3;
11106 + }
11107 + } while (0);
11108 +#endif
11109 +
11110 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11111 + unsigned int sethi, ba, nop;
11112 +
11113 + err = get_user(sethi, (unsigned int *)regs->tpc);
11114 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11115 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11116 +
11117 + if (err)
11118 + break;
11119 +
11120 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11121 + (ba & 0xFFF00000U) == 0x30600000U &&
11122 + nop == 0x01000000U)
11123 + {
11124 + unsigned long addr;
11125 +
11126 + addr = (sethi & 0x003FFFFFU) << 10;
11127 + regs->u_regs[UREG_G1] = addr;
11128 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11129 +
11130 + if (test_thread_flag(TIF_32BIT))
11131 + addr &= 0xFFFFFFFFUL;
11132 +
11133 + regs->tpc = addr;
11134 + regs->tnpc = addr+4;
11135 + return 2;
11136 + }
11137 + } while (0);
11138 +
11139 +#endif
11140 +
11141 + return 1;
11142 +}
11143 +
11144 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11145 +{
11146 + unsigned long i;
11147 +
11148 + printk(KERN_ERR "PAX: bytes at PC: ");
11149 + for (i = 0; i < 8; i++) {
11150 + unsigned int c;
11151 + if (get_user(c, (unsigned int *)pc+i))
11152 + printk(KERN_CONT "???????? ");
11153 + else
11154 + printk(KERN_CONT "%08x ", c);
11155 + }
11156 + printk("\n");
11157 +}
11158 +#endif
11159 +
11160 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11161 {
11162 struct mm_struct *mm = current->mm;
11163 @@ -341,6 +804,29 @@ retry:
11164 if (!vma)
11165 goto bad_area;
11166
11167 +#ifdef CONFIG_PAX_PAGEEXEC
11168 + /* PaX: detect ITLB misses on non-exec pages */
11169 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11170 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11171 + {
11172 + if (address != regs->tpc)
11173 + goto good_area;
11174 +
11175 + up_read(&mm->mmap_sem);
11176 + switch (pax_handle_fetch_fault(regs)) {
11177 +
11178 +#ifdef CONFIG_PAX_EMUPLT
11179 + case 2:
11180 + case 3:
11181 + return;
11182 +#endif
11183 +
11184 + }
11185 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11186 + do_group_exit(SIGKILL);
11187 + }
11188 +#endif
11189 +
11190 /* Pure DTLB misses do not tell us whether the fault causing
11191 * load/store/atomic was a write or not, it only says that there
11192 * was no match. So in such a case we (carefully) read the
11193 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11194 index d2b5944..d878f3c 100644
11195 --- a/arch/sparc/mm/hugetlbpage.c
11196 +++ b/arch/sparc/mm/hugetlbpage.c
11197 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11198 unsigned long addr,
11199 unsigned long len,
11200 unsigned long pgoff,
11201 - unsigned long flags)
11202 + unsigned long flags,
11203 + unsigned long offset)
11204 {
11205 unsigned long task_size = TASK_SIZE;
11206 struct vm_unmapped_area_info info;
11207 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11208
11209 info.flags = 0;
11210 info.length = len;
11211 - info.low_limit = TASK_UNMAPPED_BASE;
11212 + info.low_limit = mm->mmap_base;
11213 info.high_limit = min(task_size, VA_EXCLUDE_START);
11214 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11215 info.align_offset = 0;
11216 + info.threadstack_offset = offset;
11217 addr = vm_unmapped_area(&info);
11218
11219 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11220 VM_BUG_ON(addr != -ENOMEM);
11221 info.low_limit = VA_EXCLUDE_END;
11222 +
11223 +#ifdef CONFIG_PAX_RANDMMAP
11224 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11225 + info.low_limit += mm->delta_mmap;
11226 +#endif
11227 +
11228 info.high_limit = task_size;
11229 addr = vm_unmapped_area(&info);
11230 }
11231 @@ -58,7 +66,8 @@ static unsigned long
11232 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11233 const unsigned long len,
11234 const unsigned long pgoff,
11235 - const unsigned long flags)
11236 + const unsigned long flags,
11237 + const unsigned long offset)
11238 {
11239 struct mm_struct *mm = current->mm;
11240 unsigned long addr = addr0;
11241 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11242 info.high_limit = mm->mmap_base;
11243 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11244 info.align_offset = 0;
11245 + info.threadstack_offset = offset;
11246 addr = vm_unmapped_area(&info);
11247
11248 /*
11249 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11250 VM_BUG_ON(addr != -ENOMEM);
11251 info.flags = 0;
11252 info.low_limit = TASK_UNMAPPED_BASE;
11253 +
11254 +#ifdef CONFIG_PAX_RANDMMAP
11255 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11256 + info.low_limit += mm->delta_mmap;
11257 +#endif
11258 +
11259 info.high_limit = STACK_TOP32;
11260 addr = vm_unmapped_area(&info);
11261 }
11262 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11263 struct mm_struct *mm = current->mm;
11264 struct vm_area_struct *vma;
11265 unsigned long task_size = TASK_SIZE;
11266 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11267
11268 if (test_thread_flag(TIF_32BIT))
11269 task_size = STACK_TOP32;
11270 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11271 return addr;
11272 }
11273
11274 +#ifdef CONFIG_PAX_RANDMMAP
11275 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11276 +#endif
11277 +
11278 if (addr) {
11279 addr = ALIGN(addr, HPAGE_SIZE);
11280 vma = find_vma(mm, addr);
11281 - if (task_size - len >= addr &&
11282 - (!vma || addr + len <= vma->vm_start))
11283 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11284 return addr;
11285 }
11286 if (mm->get_unmapped_area == arch_get_unmapped_area)
11287 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11288 - pgoff, flags);
11289 + pgoff, flags, offset);
11290 else
11291 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11292 - pgoff, flags);
11293 + pgoff, flags, offset);
11294 }
11295
11296 pte_t *huge_pte_alloc(struct mm_struct *mm,
11297 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11298 index ed82eda..0d80e77 100644
11299 --- a/arch/sparc/mm/init_64.c
11300 +++ b/arch/sparc/mm/init_64.c
11301 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11302 int num_kernel_image_mappings;
11303
11304 #ifdef CONFIG_DEBUG_DCFLUSH
11305 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11306 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11307 #ifdef CONFIG_SMP
11308 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11309 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11310 #endif
11311 #endif
11312
11313 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11314 {
11315 BUG_ON(tlb_type == hypervisor);
11316 #ifdef CONFIG_DEBUG_DCFLUSH
11317 - atomic_inc(&dcpage_flushes);
11318 + atomic_inc_unchecked(&dcpage_flushes);
11319 #endif
11320
11321 #ifdef DCACHE_ALIASING_POSSIBLE
11322 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11323
11324 #ifdef CONFIG_DEBUG_DCFLUSH
11325 seq_printf(m, "DCPageFlushes\t: %d\n",
11326 - atomic_read(&dcpage_flushes));
11327 + atomic_read_unchecked(&dcpage_flushes));
11328 #ifdef CONFIG_SMP
11329 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11330 - atomic_read(&dcpage_flushes_xcall));
11331 + atomic_read_unchecked(&dcpage_flushes_xcall));
11332 #endif /* CONFIG_SMP */
11333 #endif /* CONFIG_DEBUG_DCFLUSH */
11334 }
11335 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11336 index f4500c6..889656c 100644
11337 --- a/arch/tile/include/asm/atomic_64.h
11338 +++ b/arch/tile/include/asm/atomic_64.h
11339 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11340
11341 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11342
11343 +#define atomic64_read_unchecked(v) atomic64_read(v)
11344 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11345 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11346 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11347 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11348 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11349 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11350 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11351 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11352 +
11353 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11354 #define smp_mb__before_atomic_dec() smp_mb()
11355 #define smp_mb__after_atomic_dec() smp_mb()
11356 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11357 index a9a5299..0fce79e 100644
11358 --- a/arch/tile/include/asm/cache.h
11359 +++ b/arch/tile/include/asm/cache.h
11360 @@ -15,11 +15,12 @@
11361 #ifndef _ASM_TILE_CACHE_H
11362 #define _ASM_TILE_CACHE_H
11363
11364 +#include <linux/const.h>
11365 #include <arch/chip.h>
11366
11367 /* bytes per L1 data cache line */
11368 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11369 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11370 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11371
11372 /* bytes per L2 cache line */
11373 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11374 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11375 index e4d44bd..99927a3 100644
11376 --- a/arch/tile/include/asm/uaccess.h
11377 +++ b/arch/tile/include/asm/uaccess.h
11378 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11379 const void __user *from,
11380 unsigned long n)
11381 {
11382 - int sz = __compiletime_object_size(to);
11383 + size_t sz = __compiletime_object_size(to);
11384
11385 - if (likely(sz == -1 || sz >= n))
11386 + if (likely(sz == (size_t)-1 || sz >= n))
11387 n = _copy_from_user(to, from, n);
11388 else
11389 copy_from_user_overflow();
11390 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11391 index 650ccff..45fe2d6 100644
11392 --- a/arch/tile/mm/hugetlbpage.c
11393 +++ b/arch/tile/mm/hugetlbpage.c
11394 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11395 info.high_limit = TASK_SIZE;
11396 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11397 info.align_offset = 0;
11398 + info.threadstack_offset = 0;
11399 return vm_unmapped_area(&info);
11400 }
11401
11402 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11403 info.high_limit = current->mm->mmap_base;
11404 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11405 info.align_offset = 0;
11406 + info.threadstack_offset = 0;
11407 addr = vm_unmapped_area(&info);
11408
11409 /*
11410 diff --git a/arch/um/Makefile b/arch/um/Makefile
11411 index 133f7de..1d6f2f1 100644
11412 --- a/arch/um/Makefile
11413 +++ b/arch/um/Makefile
11414 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11415 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11416 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11417
11418 +ifdef CONSTIFY_PLUGIN
11419 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11420 +endif
11421 +
11422 #This will adjust *FLAGS accordingly to the platform.
11423 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11424
11425 diff --git a/arch/um/defconfig b/arch/um/defconfig
11426 index 08107a7..ab22afe 100644
11427 --- a/arch/um/defconfig
11428 +++ b/arch/um/defconfig
11429 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11430 CONFIG_X86_L1_CACHE_SHIFT=5
11431 CONFIG_X86_XADD=y
11432 CONFIG_X86_PPRO_FENCE=y
11433 -CONFIG_X86_WP_WORKS_OK=y
11434 CONFIG_X86_INVLPG=y
11435 CONFIG_X86_BSWAP=y
11436 CONFIG_X86_POPAD_OK=y
11437 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11438 index 19e1bdd..3665b77 100644
11439 --- a/arch/um/include/asm/cache.h
11440 +++ b/arch/um/include/asm/cache.h
11441 @@ -1,6 +1,7 @@
11442 #ifndef __UM_CACHE_H
11443 #define __UM_CACHE_H
11444
11445 +#include <linux/const.h>
11446
11447 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11448 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11449 @@ -12,6 +13,6 @@
11450 # define L1_CACHE_SHIFT 5
11451 #endif
11452
11453 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11454 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11455
11456 #endif
11457 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11458 index 2e0a6b1..a64d0f5 100644
11459 --- a/arch/um/include/asm/kmap_types.h
11460 +++ b/arch/um/include/asm/kmap_types.h
11461 @@ -8,6 +8,6 @@
11462
11463 /* No more #include "asm/arch/kmap_types.h" ! */
11464
11465 -#define KM_TYPE_NR 14
11466 +#define KM_TYPE_NR 15
11467
11468 #endif
11469 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11470 index 5ff53d9..5850cdf 100644
11471 --- a/arch/um/include/asm/page.h
11472 +++ b/arch/um/include/asm/page.h
11473 @@ -14,6 +14,9 @@
11474 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11475 #define PAGE_MASK (~(PAGE_SIZE-1))
11476
11477 +#define ktla_ktva(addr) (addr)
11478 +#define ktva_ktla(addr) (addr)
11479 +
11480 #ifndef __ASSEMBLY__
11481
11482 struct page;
11483 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11484 index 0032f92..cd151e0 100644
11485 --- a/arch/um/include/asm/pgtable-3level.h
11486 +++ b/arch/um/include/asm/pgtable-3level.h
11487 @@ -58,6 +58,7 @@
11488 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11489 #define pud_populate(mm, pud, pmd) \
11490 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11491 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11492
11493 #ifdef CONFIG_64BIT
11494 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11495 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11496 index bbcef52..6a2a483 100644
11497 --- a/arch/um/kernel/process.c
11498 +++ b/arch/um/kernel/process.c
11499 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11500 return 2;
11501 }
11502
11503 -/*
11504 - * Only x86 and x86_64 have an arch_align_stack().
11505 - * All other arches have "#define arch_align_stack(x) (x)"
11506 - * in their asm/system.h
11507 - * As this is included in UML from asm-um/system-generic.h,
11508 - * we can use it to behave as the subarch does.
11509 - */
11510 -#ifndef arch_align_stack
11511 -unsigned long arch_align_stack(unsigned long sp)
11512 -{
11513 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11514 - sp -= get_random_int() % 8192;
11515 - return sp & ~0xf;
11516 -}
11517 -#endif
11518 -
11519 unsigned long get_wchan(struct task_struct *p)
11520 {
11521 unsigned long stack_page, sp, ip;
11522 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11523 index ad8f795..2c7eec6 100644
11524 --- a/arch/unicore32/include/asm/cache.h
11525 +++ b/arch/unicore32/include/asm/cache.h
11526 @@ -12,8 +12,10 @@
11527 #ifndef __UNICORE_CACHE_H__
11528 #define __UNICORE_CACHE_H__
11529
11530 -#define L1_CACHE_SHIFT (5)
11531 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11532 +#include <linux/const.h>
11533 +
11534 +#define L1_CACHE_SHIFT 5
11535 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11536
11537 /*
11538 * Memory returned by kmalloc() may be used for DMA, so we must make
11539 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11540 index b32ebf9..5704f98 100644
11541 --- a/arch/x86/Kconfig
11542 +++ b/arch/x86/Kconfig
11543 @@ -248,7 +248,7 @@ config X86_HT
11544
11545 config X86_32_LAZY_GS
11546 def_bool y
11547 - depends on X86_32 && !CC_STACKPROTECTOR
11548 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11549
11550 config ARCH_HWEIGHT_CFLAGS
11551 string
11552 @@ -1088,6 +1088,7 @@ config MICROCODE_EARLY
11553
11554 config X86_MSR
11555 tristate "/dev/cpu/*/msr - Model-specific register support"
11556 + depends on !GRKERNSEC_KMEM
11557 ---help---
11558 This device gives privileged processes access to the x86
11559 Model-Specific Registers (MSRs). It is a character device with
11560 @@ -1111,7 +1112,7 @@ choice
11561
11562 config NOHIGHMEM
11563 bool "off"
11564 - depends on !X86_NUMAQ
11565 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11566 ---help---
11567 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11568 However, the address space of 32-bit x86 processors is only 4
11569 @@ -1148,7 +1149,7 @@ config NOHIGHMEM
11570
11571 config HIGHMEM4G
11572 bool "4GB"
11573 - depends on !X86_NUMAQ
11574 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11575 ---help---
11576 Select this if you have a 32-bit processor and between 1 and 4
11577 gigabytes of physical RAM.
11578 @@ -1201,7 +1202,7 @@ config PAGE_OFFSET
11579 hex
11580 default 0xB0000000 if VMSPLIT_3G_OPT
11581 default 0x80000000 if VMSPLIT_2G
11582 - default 0x78000000 if VMSPLIT_2G_OPT
11583 + default 0x70000000 if VMSPLIT_2G_OPT
11584 default 0x40000000 if VMSPLIT_1G
11585 default 0xC0000000
11586 depends on X86_32
11587 @@ -1599,6 +1600,7 @@ config SECCOMP
11588
11589 config CC_STACKPROTECTOR
11590 bool "Enable -fstack-protector buffer overflow detection"
11591 + depends on X86_64 || !PAX_MEMORY_UDEREF
11592 ---help---
11593 This option turns on the -fstack-protector GCC feature. This
11594 feature puts, at the beginning of functions, a canary value on
11595 @@ -1718,6 +1720,8 @@ config X86_NEED_RELOCS
11596 config PHYSICAL_ALIGN
11597 hex "Alignment value to which kernel should be aligned" if X86_32
11598 default "0x1000000"
11599 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11600 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11601 range 0x2000 0x1000000
11602 ---help---
11603 This value puts the alignment restrictions on physical address
11604 @@ -1793,9 +1797,10 @@ config DEBUG_HOTPLUG_CPU0
11605 If unsure, say N.
11606
11607 config COMPAT_VDSO
11608 - def_bool y
11609 + def_bool n
11610 prompt "Compat VDSO support"
11611 depends on X86_32 || IA32_EMULATION
11612 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11613 ---help---
11614 Map the 32-bit VDSO to the predictable old-style address too.
11615
11616 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11617 index c026cca..14657ae 100644
11618 --- a/arch/x86/Kconfig.cpu
11619 +++ b/arch/x86/Kconfig.cpu
11620 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11621
11622 config X86_F00F_BUG
11623 def_bool y
11624 - depends on M586MMX || M586TSC || M586 || M486
11625 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11626
11627 config X86_INVD_BUG
11628 def_bool y
11629 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11630
11631 config X86_ALIGNMENT_16
11632 def_bool y
11633 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11634 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11635
11636 config X86_INTEL_USERCOPY
11637 def_bool y
11638 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11639 # generates cmov.
11640 config X86_CMOV
11641 def_bool y
11642 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11643 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11644
11645 config X86_MINIMUM_CPU_FAMILY
11646 int
11647 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11648 index 78d91af..8ceb94b 100644
11649 --- a/arch/x86/Kconfig.debug
11650 +++ b/arch/x86/Kconfig.debug
11651 @@ -74,7 +74,7 @@ config X86_PTDUMP
11652 config DEBUG_RODATA
11653 bool "Write protect kernel read-only data structures"
11654 default y
11655 - depends on DEBUG_KERNEL
11656 + depends on DEBUG_KERNEL && BROKEN
11657 ---help---
11658 Mark the kernel read-only data as write-protected in the pagetables,
11659 in order to catch accidental (and incorrect) writes to such const
11660 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11661
11662 config DEBUG_SET_MODULE_RONX
11663 bool "Set loadable kernel module data as NX and text as RO"
11664 - depends on MODULES
11665 + depends on MODULES && BROKEN
11666 ---help---
11667 This option helps catch unintended modifications to loadable
11668 kernel module's text and read-only data. It also prevents execution
11669 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11670 index 07639c6..6f2c901 100644
11671 --- a/arch/x86/Makefile
11672 +++ b/arch/x86/Makefile
11673 @@ -54,6 +54,7 @@ else
11674 UTS_MACHINE := x86_64
11675 CHECKFLAGS += -D__x86_64__ -m64
11676
11677 + biarch := $(call cc-option,-m64)
11678 KBUILD_AFLAGS += -m64
11679 KBUILD_CFLAGS += -m64
11680
11681 @@ -241,3 +242,12 @@ define archhelp
11682 echo ' FDINITRD=file initrd for the booted kernel'
11683 echo ' kvmconfig - Enable additional options for guest kernel support'
11684 endef
11685 +
11686 +define OLD_LD
11687 +
11688 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11689 +*** Please upgrade your binutils to 2.18 or newer
11690 +endef
11691 +
11692 +archprepare:
11693 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11694 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11695 index 379814b..add62ce 100644
11696 --- a/arch/x86/boot/Makefile
11697 +++ b/arch/x86/boot/Makefile
11698 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11699 $(call cc-option, -fno-stack-protector) \
11700 $(call cc-option, -mpreferred-stack-boundary=2)
11701 KBUILD_CFLAGS += $(call cc-option, -m32)
11702 +ifdef CONSTIFY_PLUGIN
11703 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11704 +endif
11705 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11706 GCOV_PROFILE := n
11707
11708 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11709 index 878e4b9..20537ab 100644
11710 --- a/arch/x86/boot/bitops.h
11711 +++ b/arch/x86/boot/bitops.h
11712 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11713 u8 v;
11714 const u32 *p = (const u32 *)addr;
11715
11716 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11717 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11718 return v;
11719 }
11720
11721 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11722
11723 static inline void set_bit(int nr, void *addr)
11724 {
11725 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11726 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11727 }
11728
11729 #endif /* BOOT_BITOPS_H */
11730 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11731 index 5b75319..331a4ca 100644
11732 --- a/arch/x86/boot/boot.h
11733 +++ b/arch/x86/boot/boot.h
11734 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11735 static inline u16 ds(void)
11736 {
11737 u16 seg;
11738 - asm("movw %%ds,%0" : "=rm" (seg));
11739 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11740 return seg;
11741 }
11742
11743 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11744 static inline int memcmp(const void *s1, const void *s2, size_t len)
11745 {
11746 u8 diff;
11747 - asm("repe; cmpsb; setnz %0"
11748 + asm volatile("repe; cmpsb; setnz %0"
11749 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11750 return diff;
11751 }
11752 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11753 index dcd90df..c830d7d 100644
11754 --- a/arch/x86/boot/compressed/Makefile
11755 +++ b/arch/x86/boot/compressed/Makefile
11756 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11757 KBUILD_CFLAGS += $(cflags-y)
11758 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11759 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11760 +ifdef CONSTIFY_PLUGIN
11761 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11762 +endif
11763
11764 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11765 GCOV_PROFILE := n
11766 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11767 index b7388a4..03844ec 100644
11768 --- a/arch/x86/boot/compressed/eboot.c
11769 +++ b/arch/x86/boot/compressed/eboot.c
11770 @@ -150,7 +150,6 @@ again:
11771 *addr = max_addr;
11772 }
11773
11774 -free_pool:
11775 efi_call_phys1(sys_table->boottime->free_pool, map);
11776
11777 fail:
11778 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11779 if (i == map_size / desc_size)
11780 status = EFI_NOT_FOUND;
11781
11782 -free_pool:
11783 efi_call_phys1(sys_table->boottime->free_pool, map);
11784 fail:
11785 return status;
11786 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11787 index a53440e..c3dbf1e 100644
11788 --- a/arch/x86/boot/compressed/efi_stub_32.S
11789 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11790 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11791 * parameter 2, ..., param n. To make things easy, we save the return
11792 * address of efi_call_phys in a global variable.
11793 */
11794 - popl %ecx
11795 - movl %ecx, saved_return_addr(%edx)
11796 - /* get the function pointer into ECX*/
11797 - popl %ecx
11798 - movl %ecx, efi_rt_function_ptr(%edx)
11799 + popl saved_return_addr(%edx)
11800 + popl efi_rt_function_ptr(%edx)
11801
11802 /*
11803 * 3. Call the physical function.
11804 */
11805 - call *%ecx
11806 + call *efi_rt_function_ptr(%edx)
11807
11808 /*
11809 * 4. Balance the stack. And because EAX contain the return value,
11810 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11811 1: popl %edx
11812 subl $1b, %edx
11813
11814 - movl efi_rt_function_ptr(%edx), %ecx
11815 - pushl %ecx
11816 + pushl efi_rt_function_ptr(%edx)
11817
11818 /*
11819 * 10. Push the saved return address onto the stack and return.
11820 */
11821 - movl saved_return_addr(%edx), %ecx
11822 - pushl %ecx
11823 - ret
11824 + jmpl *saved_return_addr(%edx)
11825 ENDPROC(efi_call_phys)
11826 .previous
11827
11828 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11829 index 1e3184f..0d11e2e 100644
11830 --- a/arch/x86/boot/compressed/head_32.S
11831 +++ b/arch/x86/boot/compressed/head_32.S
11832 @@ -118,7 +118,7 @@ preferred_addr:
11833 notl %eax
11834 andl %eax, %ebx
11835 #else
11836 - movl $LOAD_PHYSICAL_ADDR, %ebx
11837 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11838 #endif
11839
11840 /* Target address to relocate to for decompression */
11841 @@ -204,7 +204,7 @@ relocated:
11842 * and where it was actually loaded.
11843 */
11844 movl %ebp, %ebx
11845 - subl $LOAD_PHYSICAL_ADDR, %ebx
11846 + subl $____LOAD_PHYSICAL_ADDR, %ebx
11847 jz 2f /* Nothing to be done if loaded at compiled addr. */
11848 /*
11849 * Process relocations.
11850 @@ -212,8 +212,7 @@ relocated:
11851
11852 1: subl $4, %edi
11853 movl (%edi), %ecx
11854 - testl %ecx, %ecx
11855 - jz 2f
11856 + jecxz 2f
11857 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
11858 jmp 1b
11859 2:
11860 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11861 index 06e71c2..88a98264 100644
11862 --- a/arch/x86/boot/compressed/head_64.S
11863 +++ b/arch/x86/boot/compressed/head_64.S
11864 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11865 notl %eax
11866 andl %eax, %ebx
11867 #else
11868 - movl $LOAD_PHYSICAL_ADDR, %ebx
11869 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11870 #endif
11871
11872 /* Target address to relocate to for decompression */
11873 @@ -270,7 +270,7 @@ preferred_addr:
11874 notq %rax
11875 andq %rax, %rbp
11876 #else
11877 - movq $LOAD_PHYSICAL_ADDR, %rbp
11878 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11879 #endif
11880
11881 /* Target address to relocate to for decompression */
11882 @@ -361,8 +361,8 @@ gdt:
11883 .long gdt
11884 .word 0
11885 .quad 0x0000000000000000 /* NULL descriptor */
11886 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11887 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11888 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11889 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11890 .quad 0x0080890000000000 /* TS descriptor */
11891 .quad 0x0000000000000000 /* TS continued */
11892 gdt_end:
11893 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11894 index 0319c88..7c1931f 100644
11895 --- a/arch/x86/boot/compressed/misc.c
11896 +++ b/arch/x86/boot/compressed/misc.c
11897 @@ -307,7 +307,7 @@ static void parse_elf(void *output)
11898 case PT_LOAD:
11899 #ifdef CONFIG_RELOCATABLE
11900 dest = output;
11901 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11902 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11903 #else
11904 dest = (void *)(phdr->p_paddr);
11905 #endif
11906 @@ -358,7 +358,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11907 error("Destination address too large");
11908 #endif
11909 #ifndef CONFIG_RELOCATABLE
11910 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11911 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11912 error("Wrong destination address");
11913 #endif
11914
11915 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11916 index 4d3ff03..e4972ff 100644
11917 --- a/arch/x86/boot/cpucheck.c
11918 +++ b/arch/x86/boot/cpucheck.c
11919 @@ -74,7 +74,7 @@ static int has_fpu(void)
11920 u16 fcw = -1, fsw = -1;
11921 u32 cr0;
11922
11923 - asm("movl %%cr0,%0" : "=r" (cr0));
11924 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11925 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11926 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11927 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11928 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11929 {
11930 u32 f0, f1;
11931
11932 - asm("pushfl ; "
11933 + asm volatile("pushfl ; "
11934 "pushfl ; "
11935 "popl %0 ; "
11936 "movl %0,%1 ; "
11937 @@ -115,7 +115,7 @@ static void get_flags(void)
11938 set_bit(X86_FEATURE_FPU, cpu.flags);
11939
11940 if (has_eflag(X86_EFLAGS_ID)) {
11941 - asm("cpuid"
11942 + asm volatile("cpuid"
11943 : "=a" (max_intel_level),
11944 "=b" (cpu_vendor[0]),
11945 "=d" (cpu_vendor[1]),
11946 @@ -124,7 +124,7 @@ static void get_flags(void)
11947
11948 if (max_intel_level >= 0x00000001 &&
11949 max_intel_level <= 0x0000ffff) {
11950 - asm("cpuid"
11951 + asm volatile("cpuid"
11952 : "=a" (tfms),
11953 "=c" (cpu.flags[4]),
11954 "=d" (cpu.flags[0])
11955 @@ -136,7 +136,7 @@ static void get_flags(void)
11956 cpu.model += ((tfms >> 16) & 0xf) << 4;
11957 }
11958
11959 - asm("cpuid"
11960 + asm volatile("cpuid"
11961 : "=a" (max_amd_level)
11962 : "a" (0x80000000)
11963 : "ebx", "ecx", "edx");
11964 @@ -144,7 +144,7 @@ static void get_flags(void)
11965 if (max_amd_level >= 0x80000001 &&
11966 max_amd_level <= 0x8000ffff) {
11967 u32 eax = 0x80000001;
11968 - asm("cpuid"
11969 + asm volatile("cpuid"
11970 : "+a" (eax),
11971 "=c" (cpu.flags[6]),
11972 "=d" (cpu.flags[1])
11973 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11974 u32 ecx = MSR_K7_HWCR;
11975 u32 eax, edx;
11976
11977 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11978 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11979 eax &= ~(1 << 15);
11980 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11981 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11982
11983 get_flags(); /* Make sure it really did something */
11984 err = check_flags();
11985 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11986 u32 ecx = MSR_VIA_FCR;
11987 u32 eax, edx;
11988
11989 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11990 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11991 eax |= (1<<1)|(1<<7);
11992 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11993 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11994
11995 set_bit(X86_FEATURE_CX8, cpu.flags);
11996 err = check_flags();
11997 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11998 u32 eax, edx;
11999 u32 level = 1;
12000
12001 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12002 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12003 - asm("cpuid"
12004 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12005 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12006 + asm volatile("cpuid"
12007 : "+a" (level), "=d" (cpu.flags[0])
12008 : : "ecx", "ebx");
12009 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12010 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12011
12012 err = check_flags();
12013 }
12014 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12015 index 9ec06a1..2c25e79 100644
12016 --- a/arch/x86/boot/header.S
12017 +++ b/arch/x86/boot/header.S
12018 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12019 # single linked list of
12020 # struct setup_data
12021
12022 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12023 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12024
12025 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12026 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12027 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12028 +#else
12029 #define VO_INIT_SIZE (VO__end - VO__text)
12030 +#endif
12031 #if ZO_INIT_SIZE > VO_INIT_SIZE
12032 #define INIT_SIZE ZO_INIT_SIZE
12033 #else
12034 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12035 index db75d07..8e6d0af 100644
12036 --- a/arch/x86/boot/memory.c
12037 +++ b/arch/x86/boot/memory.c
12038 @@ -19,7 +19,7 @@
12039
12040 static int detect_memory_e820(void)
12041 {
12042 - int count = 0;
12043 + unsigned int count = 0;
12044 struct biosregs ireg, oreg;
12045 struct e820entry *desc = boot_params.e820_map;
12046 static struct e820entry buf; /* static so it is zeroed */
12047 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12048 index 11e8c6e..fdbb1ed 100644
12049 --- a/arch/x86/boot/video-vesa.c
12050 +++ b/arch/x86/boot/video-vesa.c
12051 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12052
12053 boot_params.screen_info.vesapm_seg = oreg.es;
12054 boot_params.screen_info.vesapm_off = oreg.di;
12055 + boot_params.screen_info.vesapm_size = oreg.cx;
12056 }
12057
12058 /*
12059 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12060 index 43eda28..5ab5fdb 100644
12061 --- a/arch/x86/boot/video.c
12062 +++ b/arch/x86/boot/video.c
12063 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12064 static unsigned int get_entry(void)
12065 {
12066 char entry_buf[4];
12067 - int i, len = 0;
12068 + unsigned int i, len = 0;
12069 int key;
12070 unsigned int v;
12071
12072 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12073 index 9105655..5e37f27 100644
12074 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12075 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12076 @@ -8,6 +8,8 @@
12077 * including this sentence is retained in full.
12078 */
12079
12080 +#include <asm/alternative-asm.h>
12081 +
12082 .extern crypto_ft_tab
12083 .extern crypto_it_tab
12084 .extern crypto_fl_tab
12085 @@ -70,6 +72,8 @@
12086 je B192; \
12087 leaq 32(r9),r9;
12088
12089 +#define ret pax_force_retaddr 0, 1; ret
12090 +
12091 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12092 movq r1,r2; \
12093 movq r3,r4; \
12094 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12095 index 477e9d7..3ab339f 100644
12096 --- a/arch/x86/crypto/aesni-intel_asm.S
12097 +++ b/arch/x86/crypto/aesni-intel_asm.S
12098 @@ -31,6 +31,7 @@
12099
12100 #include <linux/linkage.h>
12101 #include <asm/inst.h>
12102 +#include <asm/alternative-asm.h>
12103
12104 #ifdef __x86_64__
12105 .data
12106 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12107 pop %r14
12108 pop %r13
12109 pop %r12
12110 + pax_force_retaddr 0, 1
12111 ret
12112 ENDPROC(aesni_gcm_dec)
12113
12114 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12115 pop %r14
12116 pop %r13
12117 pop %r12
12118 + pax_force_retaddr 0, 1
12119 ret
12120 ENDPROC(aesni_gcm_enc)
12121
12122 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12123 pxor %xmm1, %xmm0
12124 movaps %xmm0, (TKEYP)
12125 add $0x10, TKEYP
12126 + pax_force_retaddr_bts
12127 ret
12128 ENDPROC(_key_expansion_128)
12129 ENDPROC(_key_expansion_256a)
12130 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12131 shufps $0b01001110, %xmm2, %xmm1
12132 movaps %xmm1, 0x10(TKEYP)
12133 add $0x20, TKEYP
12134 + pax_force_retaddr_bts
12135 ret
12136 ENDPROC(_key_expansion_192a)
12137
12138 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12139
12140 movaps %xmm0, (TKEYP)
12141 add $0x10, TKEYP
12142 + pax_force_retaddr_bts
12143 ret
12144 ENDPROC(_key_expansion_192b)
12145
12146 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12147 pxor %xmm1, %xmm2
12148 movaps %xmm2, (TKEYP)
12149 add $0x10, TKEYP
12150 + pax_force_retaddr_bts
12151 ret
12152 ENDPROC(_key_expansion_256b)
12153
12154 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12155 #ifndef __x86_64__
12156 popl KEYP
12157 #endif
12158 + pax_force_retaddr 0, 1
12159 ret
12160 ENDPROC(aesni_set_key)
12161
12162 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12163 popl KLEN
12164 popl KEYP
12165 #endif
12166 + pax_force_retaddr 0, 1
12167 ret
12168 ENDPROC(aesni_enc)
12169
12170 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12171 AESENC KEY STATE
12172 movaps 0x70(TKEYP), KEY
12173 AESENCLAST KEY STATE
12174 + pax_force_retaddr_bts
12175 ret
12176 ENDPROC(_aesni_enc1)
12177
12178 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12179 AESENCLAST KEY STATE2
12180 AESENCLAST KEY STATE3
12181 AESENCLAST KEY STATE4
12182 + pax_force_retaddr_bts
12183 ret
12184 ENDPROC(_aesni_enc4)
12185
12186 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12187 popl KLEN
12188 popl KEYP
12189 #endif
12190 + pax_force_retaddr 0, 1
12191 ret
12192 ENDPROC(aesni_dec)
12193
12194 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12195 AESDEC KEY STATE
12196 movaps 0x70(TKEYP), KEY
12197 AESDECLAST KEY STATE
12198 + pax_force_retaddr_bts
12199 ret
12200 ENDPROC(_aesni_dec1)
12201
12202 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12203 AESDECLAST KEY STATE2
12204 AESDECLAST KEY STATE3
12205 AESDECLAST KEY STATE4
12206 + pax_force_retaddr_bts
12207 ret
12208 ENDPROC(_aesni_dec4)
12209
12210 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12211 popl KEYP
12212 popl LEN
12213 #endif
12214 + pax_force_retaddr 0, 1
12215 ret
12216 ENDPROC(aesni_ecb_enc)
12217
12218 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12219 popl KEYP
12220 popl LEN
12221 #endif
12222 + pax_force_retaddr 0, 1
12223 ret
12224 ENDPROC(aesni_ecb_dec)
12225
12226 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12227 popl LEN
12228 popl IVP
12229 #endif
12230 + pax_force_retaddr 0, 1
12231 ret
12232 ENDPROC(aesni_cbc_enc)
12233
12234 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12235 popl LEN
12236 popl IVP
12237 #endif
12238 + pax_force_retaddr 0, 1
12239 ret
12240 ENDPROC(aesni_cbc_dec)
12241
12242 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12243 mov $1, TCTR_LOW
12244 MOVQ_R64_XMM TCTR_LOW INC
12245 MOVQ_R64_XMM CTR TCTR_LOW
12246 + pax_force_retaddr_bts
12247 ret
12248 ENDPROC(_aesni_inc_init)
12249
12250 @@ -2579,6 +2598,7 @@ _aesni_inc:
12251 .Linc_low:
12252 movaps CTR, IV
12253 PSHUFB_XMM BSWAP_MASK IV
12254 + pax_force_retaddr_bts
12255 ret
12256 ENDPROC(_aesni_inc)
12257
12258 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12259 .Lctr_enc_ret:
12260 movups IV, (IVP)
12261 .Lctr_enc_just_ret:
12262 + pax_force_retaddr 0, 1
12263 ret
12264 ENDPROC(aesni_ctr_enc)
12265
12266 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12267 pxor INC, STATE4
12268 movdqu STATE4, 0x70(OUTP)
12269
12270 + pax_force_retaddr 0, 1
12271 ret
12272 ENDPROC(aesni_xts_crypt8)
12273
12274 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12275 index 246c670..4d1ed00 100644
12276 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12277 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12278 @@ -21,6 +21,7 @@
12279 */
12280
12281 #include <linux/linkage.h>
12282 +#include <asm/alternative-asm.h>
12283
12284 .file "blowfish-x86_64-asm.S"
12285 .text
12286 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12287 jnz .L__enc_xor;
12288
12289 write_block();
12290 + pax_force_retaddr 0, 1
12291 ret;
12292 .L__enc_xor:
12293 xor_block();
12294 + pax_force_retaddr 0, 1
12295 ret;
12296 ENDPROC(__blowfish_enc_blk)
12297
12298 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12299
12300 movq %r11, %rbp;
12301
12302 + pax_force_retaddr 0, 1
12303 ret;
12304 ENDPROC(blowfish_dec_blk)
12305
12306 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12307
12308 popq %rbx;
12309 popq %rbp;
12310 + pax_force_retaddr 0, 1
12311 ret;
12312
12313 .L__enc_xor4:
12314 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12315
12316 popq %rbx;
12317 popq %rbp;
12318 + pax_force_retaddr 0, 1
12319 ret;
12320 ENDPROC(__blowfish_enc_blk_4way)
12321
12322 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12323 popq %rbx;
12324 popq %rbp;
12325
12326 + pax_force_retaddr 0, 1
12327 ret;
12328 ENDPROC(blowfish_dec_blk_4way)
12329 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12330 index ce71f92..2dd5b1e 100644
12331 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12332 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12333 @@ -16,6 +16,7 @@
12334 */
12335
12336 #include <linux/linkage.h>
12337 +#include <asm/alternative-asm.h>
12338
12339 #define CAMELLIA_TABLE_BYTE_LEN 272
12340
12341 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12342 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12343 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12344 %rcx, (%r9));
12345 + pax_force_retaddr_bts
12346 ret;
12347 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12348
12349 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12350 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12351 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12352 %rax, (%r9));
12353 + pax_force_retaddr_bts
12354 ret;
12355 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12356
12357 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12358 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12359 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12360
12361 + pax_force_retaddr_bts
12362 ret;
12363
12364 .align 8
12365 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12366 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12367 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12368
12369 + pax_force_retaddr_bts
12370 ret;
12371
12372 .align 8
12373 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12374 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12375 %xmm8, %rsi);
12376
12377 + pax_force_retaddr 0, 1
12378 ret;
12379 ENDPROC(camellia_ecb_enc_16way)
12380
12381 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12382 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12383 %xmm8, %rsi);
12384
12385 + pax_force_retaddr 0, 1
12386 ret;
12387 ENDPROC(camellia_ecb_dec_16way)
12388
12389 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12390 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12391 %xmm8, %rsi);
12392
12393 + pax_force_retaddr 0, 1
12394 ret;
12395 ENDPROC(camellia_cbc_dec_16way)
12396
12397 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12398 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12399 %xmm8, %rsi);
12400
12401 + pax_force_retaddr 0, 1
12402 ret;
12403 ENDPROC(camellia_ctr_16way)
12404
12405 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12406 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12407 %xmm8, %rsi);
12408
12409 + pax_force_retaddr 0, 1
12410 ret;
12411 ENDPROC(camellia_xts_crypt_16way)
12412
12413 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12414 index 0e0b886..8fc756a 100644
12415 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12416 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12417 @@ -11,6 +11,7 @@
12418 */
12419
12420 #include <linux/linkage.h>
12421 +#include <asm/alternative-asm.h>
12422
12423 #define CAMELLIA_TABLE_BYTE_LEN 272
12424
12425 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12426 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12427 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12428 %rcx, (%r9));
12429 + pax_force_retaddr_bts
12430 ret;
12431 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12432
12433 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12434 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12435 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12436 %rax, (%r9));
12437 + pax_force_retaddr_bts
12438 ret;
12439 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12440
12441 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12442 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12443 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12444
12445 + pax_force_retaddr_bts
12446 ret;
12447
12448 .align 8
12449 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12450 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12451 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12452
12453 + pax_force_retaddr_bts
12454 ret;
12455
12456 .align 8
12457 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12458
12459 vzeroupper;
12460
12461 + pax_force_retaddr 0, 1
12462 ret;
12463 ENDPROC(camellia_ecb_enc_32way)
12464
12465 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12466
12467 vzeroupper;
12468
12469 + pax_force_retaddr 0, 1
12470 ret;
12471 ENDPROC(camellia_ecb_dec_32way)
12472
12473 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12474
12475 vzeroupper;
12476
12477 + pax_force_retaddr 0, 1
12478 ret;
12479 ENDPROC(camellia_cbc_dec_32way)
12480
12481 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12482
12483 vzeroupper;
12484
12485 + pax_force_retaddr 0, 1
12486 ret;
12487 ENDPROC(camellia_ctr_32way)
12488
12489 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12490
12491 vzeroupper;
12492
12493 + pax_force_retaddr 0, 1
12494 ret;
12495 ENDPROC(camellia_xts_crypt_32way)
12496
12497 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12498 index 310319c..ce174a4 100644
12499 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12500 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12501 @@ -21,6 +21,7 @@
12502 */
12503
12504 #include <linux/linkage.h>
12505 +#include <asm/alternative-asm.h>
12506
12507 .file "camellia-x86_64-asm_64.S"
12508 .text
12509 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12510 enc_outunpack(mov, RT1);
12511
12512 movq RRBP, %rbp;
12513 + pax_force_retaddr 0, 1
12514 ret;
12515
12516 .L__enc_xor:
12517 enc_outunpack(xor, RT1);
12518
12519 movq RRBP, %rbp;
12520 + pax_force_retaddr 0, 1
12521 ret;
12522 ENDPROC(__camellia_enc_blk)
12523
12524 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12525 dec_outunpack();
12526
12527 movq RRBP, %rbp;
12528 + pax_force_retaddr 0, 1
12529 ret;
12530 ENDPROC(camellia_dec_blk)
12531
12532 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12533
12534 movq RRBP, %rbp;
12535 popq %rbx;
12536 + pax_force_retaddr 0, 1
12537 ret;
12538
12539 .L__enc2_xor:
12540 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12541
12542 movq RRBP, %rbp;
12543 popq %rbx;
12544 + pax_force_retaddr 0, 1
12545 ret;
12546 ENDPROC(__camellia_enc_blk_2way)
12547
12548 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12549
12550 movq RRBP, %rbp;
12551 movq RXOR, %rbx;
12552 + pax_force_retaddr 0, 1
12553 ret;
12554 ENDPROC(camellia_dec_blk_2way)
12555 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12556 index c35fd5d..c1ee236 100644
12557 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12558 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12559 @@ -24,6 +24,7 @@
12560 */
12561
12562 #include <linux/linkage.h>
12563 +#include <asm/alternative-asm.h>
12564
12565 .file "cast5-avx-x86_64-asm_64.S"
12566
12567 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12568 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12569 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12570
12571 + pax_force_retaddr 0, 1
12572 ret;
12573 ENDPROC(__cast5_enc_blk16)
12574
12575 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12576 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12577 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12578
12579 + pax_force_retaddr 0, 1
12580 ret;
12581
12582 .L__skip_dec:
12583 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12584 vmovdqu RR4, (6*4*4)(%r11);
12585 vmovdqu RL4, (7*4*4)(%r11);
12586
12587 + pax_force_retaddr
12588 ret;
12589 ENDPROC(cast5_ecb_enc_16way)
12590
12591 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12592 vmovdqu RR4, (6*4*4)(%r11);
12593 vmovdqu RL4, (7*4*4)(%r11);
12594
12595 + pax_force_retaddr
12596 ret;
12597 ENDPROC(cast5_ecb_dec_16way)
12598
12599 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12600
12601 popq %r12;
12602
12603 + pax_force_retaddr
12604 ret;
12605 ENDPROC(cast5_cbc_dec_16way)
12606
12607 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12608
12609 popq %r12;
12610
12611 + pax_force_retaddr
12612 ret;
12613 ENDPROC(cast5_ctr_16way)
12614 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12615 index e3531f8..18ded3a 100644
12616 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12617 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12618 @@ -24,6 +24,7 @@
12619 */
12620
12621 #include <linux/linkage.h>
12622 +#include <asm/alternative-asm.h>
12623 #include "glue_helper-asm-avx.S"
12624
12625 .file "cast6-avx-x86_64-asm_64.S"
12626 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12627 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12628 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12629
12630 + pax_force_retaddr 0, 1
12631 ret;
12632 ENDPROC(__cast6_enc_blk8)
12633
12634 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12635 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12636 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12637
12638 + pax_force_retaddr 0, 1
12639 ret;
12640 ENDPROC(__cast6_dec_blk8)
12641
12642 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12643
12644 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12645
12646 + pax_force_retaddr
12647 ret;
12648 ENDPROC(cast6_ecb_enc_8way)
12649
12650 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12651
12652 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12653
12654 + pax_force_retaddr
12655 ret;
12656 ENDPROC(cast6_ecb_dec_8way)
12657
12658 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12659
12660 popq %r12;
12661
12662 + pax_force_retaddr
12663 ret;
12664 ENDPROC(cast6_cbc_dec_8way)
12665
12666 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12667
12668 popq %r12;
12669
12670 + pax_force_retaddr
12671 ret;
12672 ENDPROC(cast6_ctr_8way)
12673
12674 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12675 /* dst <= regs xor IVs(in dst) */
12676 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12677
12678 + pax_force_retaddr
12679 ret;
12680 ENDPROC(cast6_xts_enc_8way)
12681
12682 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12683 /* dst <= regs xor IVs(in dst) */
12684 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12685
12686 + pax_force_retaddr
12687 ret;
12688 ENDPROC(cast6_xts_dec_8way)
12689 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12690 index dbc4339..3d868c5 100644
12691 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12692 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12693 @@ -45,6 +45,7 @@
12694
12695 #include <asm/inst.h>
12696 #include <linux/linkage.h>
12697 +#include <asm/alternative-asm.h>
12698
12699 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12700
12701 @@ -312,6 +313,7 @@ do_return:
12702 popq %rsi
12703 popq %rdi
12704 popq %rbx
12705 + pax_force_retaddr 0, 1
12706 ret
12707
12708 ################################################################
12709 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12710 index 586f41a..d02851e 100644
12711 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12712 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12713 @@ -18,6 +18,7 @@
12714
12715 #include <linux/linkage.h>
12716 #include <asm/inst.h>
12717 +#include <asm/alternative-asm.h>
12718
12719 .data
12720
12721 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12722 psrlq $1, T2
12723 pxor T2, T1
12724 pxor T1, DATA
12725 + pax_force_retaddr
12726 ret
12727 ENDPROC(__clmul_gf128mul_ble)
12728
12729 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12730 call __clmul_gf128mul_ble
12731 PSHUFB_XMM BSWAP DATA
12732 movups DATA, (%rdi)
12733 + pax_force_retaddr
12734 ret
12735 ENDPROC(clmul_ghash_mul)
12736
12737 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12738 PSHUFB_XMM BSWAP DATA
12739 movups DATA, (%rdi)
12740 .Lupdate_just_ret:
12741 + pax_force_retaddr
12742 ret
12743 ENDPROC(clmul_ghash_update)
12744
12745 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12746 pand .Lpoly, %xmm1
12747 pxor %xmm1, %xmm0
12748 movups %xmm0, (%rdi)
12749 + pax_force_retaddr
12750 ret
12751 ENDPROC(clmul_ghash_setkey)
12752 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12753 index 9279e0b..9270820 100644
12754 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12755 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12756 @@ -1,4 +1,5 @@
12757 #include <linux/linkage.h>
12758 +#include <asm/alternative-asm.h>
12759
12760 # enter salsa20_encrypt_bytes
12761 ENTRY(salsa20_encrypt_bytes)
12762 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12763 add %r11,%rsp
12764 mov %rdi,%rax
12765 mov %rsi,%rdx
12766 + pax_force_retaddr 0, 1
12767 ret
12768 # bytesatleast65:
12769 ._bytesatleast65:
12770 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12771 add %r11,%rsp
12772 mov %rdi,%rax
12773 mov %rsi,%rdx
12774 + pax_force_retaddr
12775 ret
12776 ENDPROC(salsa20_keysetup)
12777
12778 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12779 add %r11,%rsp
12780 mov %rdi,%rax
12781 mov %rsi,%rdx
12782 + pax_force_retaddr
12783 ret
12784 ENDPROC(salsa20_ivsetup)
12785 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12786 index 2f202f4..d9164d6 100644
12787 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12788 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12789 @@ -24,6 +24,7 @@
12790 */
12791
12792 #include <linux/linkage.h>
12793 +#include <asm/alternative-asm.h>
12794 #include "glue_helper-asm-avx.S"
12795
12796 .file "serpent-avx-x86_64-asm_64.S"
12797 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12798 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12799 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12800
12801 + pax_force_retaddr
12802 ret;
12803 ENDPROC(__serpent_enc_blk8_avx)
12804
12805 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12806 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12807 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12808
12809 + pax_force_retaddr
12810 ret;
12811 ENDPROC(__serpent_dec_blk8_avx)
12812
12813 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12814
12815 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12816
12817 + pax_force_retaddr
12818 ret;
12819 ENDPROC(serpent_ecb_enc_8way_avx)
12820
12821 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12822
12823 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12824
12825 + pax_force_retaddr
12826 ret;
12827 ENDPROC(serpent_ecb_dec_8way_avx)
12828
12829 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12830
12831 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12832
12833 + pax_force_retaddr
12834 ret;
12835 ENDPROC(serpent_cbc_dec_8way_avx)
12836
12837 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12838
12839 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12840
12841 + pax_force_retaddr
12842 ret;
12843 ENDPROC(serpent_ctr_8way_avx)
12844
12845 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12846 /* dst <= regs xor IVs(in dst) */
12847 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12848
12849 + pax_force_retaddr
12850 ret;
12851 ENDPROC(serpent_xts_enc_8way_avx)
12852
12853 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12854 /* dst <= regs xor IVs(in dst) */
12855 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12856
12857 + pax_force_retaddr
12858 ret;
12859 ENDPROC(serpent_xts_dec_8way_avx)
12860 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12861 index b222085..abd483c 100644
12862 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12863 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12864 @@ -15,6 +15,7 @@
12865 */
12866
12867 #include <linux/linkage.h>
12868 +#include <asm/alternative-asm.h>
12869 #include "glue_helper-asm-avx2.S"
12870
12871 .file "serpent-avx2-asm_64.S"
12872 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12873 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12874 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12875
12876 + pax_force_retaddr
12877 ret;
12878 ENDPROC(__serpent_enc_blk16)
12879
12880 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12881 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12882 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12883
12884 + pax_force_retaddr
12885 ret;
12886 ENDPROC(__serpent_dec_blk16)
12887
12888 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12889
12890 vzeroupper;
12891
12892 + pax_force_retaddr
12893 ret;
12894 ENDPROC(serpent_ecb_enc_16way)
12895
12896 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12897
12898 vzeroupper;
12899
12900 + pax_force_retaddr
12901 ret;
12902 ENDPROC(serpent_ecb_dec_16way)
12903
12904 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12905
12906 vzeroupper;
12907
12908 + pax_force_retaddr
12909 ret;
12910 ENDPROC(serpent_cbc_dec_16way)
12911
12912 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12913
12914 vzeroupper;
12915
12916 + pax_force_retaddr
12917 ret;
12918 ENDPROC(serpent_ctr_16way)
12919
12920 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12921
12922 vzeroupper;
12923
12924 + pax_force_retaddr
12925 ret;
12926 ENDPROC(serpent_xts_enc_16way)
12927
12928 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12929
12930 vzeroupper;
12931
12932 + pax_force_retaddr
12933 ret;
12934 ENDPROC(serpent_xts_dec_16way)
12935 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12936 index acc066c..1559cc4 100644
12937 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12938 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12939 @@ -25,6 +25,7 @@
12940 */
12941
12942 #include <linux/linkage.h>
12943 +#include <asm/alternative-asm.h>
12944
12945 .file "serpent-sse2-x86_64-asm_64.S"
12946 .text
12947 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12948 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12949 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12950
12951 + pax_force_retaddr
12952 ret;
12953
12954 .L__enc_xor8:
12955 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12956 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12957
12958 + pax_force_retaddr
12959 ret;
12960 ENDPROC(__serpent_enc_blk_8way)
12961
12962 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12963 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12964 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12965
12966 + pax_force_retaddr
12967 ret;
12968 ENDPROC(serpent_dec_blk_8way)
12969 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12970 index a410950..3356d42 100644
12971 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12972 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12973 @@ -29,6 +29,7 @@
12974 */
12975
12976 #include <linux/linkage.h>
12977 +#include <asm/alternative-asm.h>
12978
12979 #define CTX %rdi // arg1
12980 #define BUF %rsi // arg2
12981 @@ -104,6 +105,7 @@
12982 pop %r12
12983 pop %rbp
12984 pop %rbx
12985 + pax_force_retaddr 0, 1
12986 ret
12987
12988 ENDPROC(\name)
12989 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
12990 index 642f156..4ab07b9 100644
12991 --- a/arch/x86/crypto/sha256-avx-asm.S
12992 +++ b/arch/x86/crypto/sha256-avx-asm.S
12993 @@ -49,6 +49,7 @@
12994
12995 #ifdef CONFIG_AS_AVX
12996 #include <linux/linkage.h>
12997 +#include <asm/alternative-asm.h>
12998
12999 ## assume buffers not aligned
13000 #define VMOVDQ vmovdqu
13001 @@ -460,6 +461,7 @@ done_hash:
13002 popq %r13
13003 popq %rbp
13004 popq %rbx
13005 + pax_force_retaddr 0, 1
13006 ret
13007 ENDPROC(sha256_transform_avx)
13008
13009 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13010 index 9e86944..2e7f95a 100644
13011 --- a/arch/x86/crypto/sha256-avx2-asm.S
13012 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13013 @@ -50,6 +50,7 @@
13014
13015 #ifdef CONFIG_AS_AVX2
13016 #include <linux/linkage.h>
13017 +#include <asm/alternative-asm.h>
13018
13019 ## assume buffers not aligned
13020 #define VMOVDQ vmovdqu
13021 @@ -720,6 +721,7 @@ done_hash:
13022 popq %r12
13023 popq %rbp
13024 popq %rbx
13025 + pax_force_retaddr 0, 1
13026 ret
13027 ENDPROC(sha256_transform_rorx)
13028
13029 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13030 index f833b74..c36ed14 100644
13031 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13032 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13033 @@ -47,6 +47,7 @@
13034 ########################################################################
13035
13036 #include <linux/linkage.h>
13037 +#include <asm/alternative-asm.h>
13038
13039 ## assume buffers not aligned
13040 #define MOVDQ movdqu
13041 @@ -471,6 +472,7 @@ done_hash:
13042 popq %rbp
13043 popq %rbx
13044
13045 + pax_force_retaddr 0, 1
13046 ret
13047 ENDPROC(sha256_transform_ssse3)
13048
13049 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13050 index 974dde9..4533d34 100644
13051 --- a/arch/x86/crypto/sha512-avx-asm.S
13052 +++ b/arch/x86/crypto/sha512-avx-asm.S
13053 @@ -49,6 +49,7 @@
13054
13055 #ifdef CONFIG_AS_AVX
13056 #include <linux/linkage.h>
13057 +#include <asm/alternative-asm.h>
13058
13059 .text
13060
13061 @@ -364,6 +365,7 @@ updateblock:
13062 mov frame_RSPSAVE(%rsp), %rsp
13063
13064 nowork:
13065 + pax_force_retaddr 0, 1
13066 ret
13067 ENDPROC(sha512_transform_avx)
13068
13069 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13070 index 568b961..061ef1d 100644
13071 --- a/arch/x86/crypto/sha512-avx2-asm.S
13072 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13073 @@ -51,6 +51,7 @@
13074
13075 #ifdef CONFIG_AS_AVX2
13076 #include <linux/linkage.h>
13077 +#include <asm/alternative-asm.h>
13078
13079 .text
13080
13081 @@ -678,6 +679,7 @@ done_hash:
13082
13083 # Restore Stack Pointer
13084 mov frame_RSPSAVE(%rsp), %rsp
13085 + pax_force_retaddr 0, 1
13086 ret
13087 ENDPROC(sha512_transform_rorx)
13088
13089 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13090 index fb56855..e23914f 100644
13091 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13092 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13093 @@ -48,6 +48,7 @@
13094 ########################################################################
13095
13096 #include <linux/linkage.h>
13097 +#include <asm/alternative-asm.h>
13098
13099 .text
13100
13101 @@ -363,6 +364,7 @@ updateblock:
13102 mov frame_RSPSAVE(%rsp), %rsp
13103
13104 nowork:
13105 + pax_force_retaddr 0, 1
13106 ret
13107 ENDPROC(sha512_transform_ssse3)
13108
13109 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13110 index 0505813..63b1d00 100644
13111 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13112 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13113 @@ -24,6 +24,7 @@
13114 */
13115
13116 #include <linux/linkage.h>
13117 +#include <asm/alternative-asm.h>
13118 #include "glue_helper-asm-avx.S"
13119
13120 .file "twofish-avx-x86_64-asm_64.S"
13121 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13122 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13123 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13124
13125 + pax_force_retaddr 0, 1
13126 ret;
13127 ENDPROC(__twofish_enc_blk8)
13128
13129 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13130 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13131 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13132
13133 + pax_force_retaddr 0, 1
13134 ret;
13135 ENDPROC(__twofish_dec_blk8)
13136
13137 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13138
13139 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13140
13141 + pax_force_retaddr 0, 1
13142 ret;
13143 ENDPROC(twofish_ecb_enc_8way)
13144
13145 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13146
13147 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13148
13149 + pax_force_retaddr 0, 1
13150 ret;
13151 ENDPROC(twofish_ecb_dec_8way)
13152
13153 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13154
13155 popq %r12;
13156
13157 + pax_force_retaddr 0, 1
13158 ret;
13159 ENDPROC(twofish_cbc_dec_8way)
13160
13161 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13162
13163 popq %r12;
13164
13165 + pax_force_retaddr 0, 1
13166 ret;
13167 ENDPROC(twofish_ctr_8way)
13168
13169 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13170 /* dst <= regs xor IVs(in dst) */
13171 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13172
13173 + pax_force_retaddr 0, 1
13174 ret;
13175 ENDPROC(twofish_xts_enc_8way)
13176
13177 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13178 /* dst <= regs xor IVs(in dst) */
13179 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13180
13181 + pax_force_retaddr 0, 1
13182 ret;
13183 ENDPROC(twofish_xts_dec_8way)
13184 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13185 index 1c3b7ce..b365c5e 100644
13186 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13187 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13188 @@ -21,6 +21,7 @@
13189 */
13190
13191 #include <linux/linkage.h>
13192 +#include <asm/alternative-asm.h>
13193
13194 .file "twofish-x86_64-asm-3way.S"
13195 .text
13196 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13197 popq %r13;
13198 popq %r14;
13199 popq %r15;
13200 + pax_force_retaddr 0, 1
13201 ret;
13202
13203 .L__enc_xor3:
13204 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13205 popq %r13;
13206 popq %r14;
13207 popq %r15;
13208 + pax_force_retaddr 0, 1
13209 ret;
13210 ENDPROC(__twofish_enc_blk_3way)
13211
13212 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13213 popq %r13;
13214 popq %r14;
13215 popq %r15;
13216 + pax_force_retaddr 0, 1
13217 ret;
13218 ENDPROC(twofish_dec_blk_3way)
13219 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13220 index a039d21..29e7615 100644
13221 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13222 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13223 @@ -22,6 +22,7 @@
13224
13225 #include <linux/linkage.h>
13226 #include <asm/asm-offsets.h>
13227 +#include <asm/alternative-asm.h>
13228
13229 #define a_offset 0
13230 #define b_offset 4
13231 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13232
13233 popq R1
13234 movq $1,%rax
13235 + pax_force_retaddr 0, 1
13236 ret
13237 ENDPROC(twofish_enc_blk)
13238
13239 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13240
13241 popq R1
13242 movq $1,%rax
13243 + pax_force_retaddr 0, 1
13244 ret
13245 ENDPROC(twofish_dec_blk)
13246 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13247 index bae3aba..c1788c1 100644
13248 --- a/arch/x86/ia32/ia32_aout.c
13249 +++ b/arch/x86/ia32/ia32_aout.c
13250 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13251 unsigned long dump_start, dump_size;
13252 struct user32 dump;
13253
13254 + memset(&dump, 0, sizeof(dump));
13255 +
13256 fs = get_fs();
13257 set_fs(KERNEL_DS);
13258 has_dumped = 1;
13259 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13260 index 665a730..8e7a67a 100644
13261 --- a/arch/x86/ia32/ia32_signal.c
13262 +++ b/arch/x86/ia32/ia32_signal.c
13263 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13264 sp -= frame_size;
13265 /* Align the stack pointer according to the i386 ABI,
13266 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13267 - sp = ((sp + 4) & -16ul) - 4;
13268 + sp = ((sp - 12) & -16ul) - 4;
13269 return (void __user *) sp;
13270 }
13271
13272 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13273 * These are actually not used anymore, but left because some
13274 * gdb versions depend on them as a marker.
13275 */
13276 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13277 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13278 } put_user_catch(err);
13279
13280 if (err)
13281 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13282 0xb8,
13283 __NR_ia32_rt_sigreturn,
13284 0x80cd,
13285 - 0,
13286 + 0
13287 };
13288
13289 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13290 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13291
13292 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13293 restorer = ksig->ka.sa.sa_restorer;
13294 + else if (current->mm->context.vdso)
13295 + /* Return stub is in 32bit vsyscall page */
13296 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13297 else
13298 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13299 - rt_sigreturn);
13300 + restorer = &frame->retcode;
13301 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13302
13303 /*
13304 * Not actually used anymore, but left because some gdb
13305 * versions need it.
13306 */
13307 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13308 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13309 } put_user_catch(err);
13310
13311 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13312 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13313 index 474dc1b..9297c58 100644
13314 --- a/arch/x86/ia32/ia32entry.S
13315 +++ b/arch/x86/ia32/ia32entry.S
13316 @@ -15,8 +15,10 @@
13317 #include <asm/irqflags.h>
13318 #include <asm/asm.h>
13319 #include <asm/smap.h>
13320 +#include <asm/pgtable.h>
13321 #include <linux/linkage.h>
13322 #include <linux/err.h>
13323 +#include <asm/alternative-asm.h>
13324
13325 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13326 #include <linux/elf-em.h>
13327 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13328 ENDPROC(native_irq_enable_sysexit)
13329 #endif
13330
13331 + .macro pax_enter_kernel_user
13332 + pax_set_fptr_mask
13333 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13334 + call pax_enter_kernel_user
13335 +#endif
13336 + .endm
13337 +
13338 + .macro pax_exit_kernel_user
13339 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13340 + call pax_exit_kernel_user
13341 +#endif
13342 +#ifdef CONFIG_PAX_RANDKSTACK
13343 + pushq %rax
13344 + pushq %r11
13345 + call pax_randomize_kstack
13346 + popq %r11
13347 + popq %rax
13348 +#endif
13349 + .endm
13350 +
13351 + .macro pax_erase_kstack
13352 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13353 + call pax_erase_kstack
13354 +#endif
13355 + .endm
13356 +
13357 /*
13358 * 32bit SYSENTER instruction entry.
13359 *
13360 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13361 CFI_REGISTER rsp,rbp
13362 SWAPGS_UNSAFE_STACK
13363 movq PER_CPU_VAR(kernel_stack), %rsp
13364 - addq $(KERNEL_STACK_OFFSET),%rsp
13365 - /*
13366 - * No need to follow this irqs on/off section: the syscall
13367 - * disabled irqs, here we enable it straight after entry:
13368 - */
13369 - ENABLE_INTERRUPTS(CLBR_NONE)
13370 movl %ebp,%ebp /* zero extension */
13371 pushq_cfi $__USER32_DS
13372 /*CFI_REL_OFFSET ss,0*/
13373 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13374 CFI_REL_OFFSET rsp,0
13375 pushfq_cfi
13376 /*CFI_REL_OFFSET rflags,0*/
13377 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13378 - CFI_REGISTER rip,r10
13379 + orl $X86_EFLAGS_IF,(%rsp)
13380 + GET_THREAD_INFO(%r11)
13381 + movl TI_sysenter_return(%r11), %r11d
13382 + CFI_REGISTER rip,r11
13383 pushq_cfi $__USER32_CS
13384 /*CFI_REL_OFFSET cs,0*/
13385 movl %eax, %eax
13386 - pushq_cfi %r10
13387 + pushq_cfi %r11
13388 CFI_REL_OFFSET rip,0
13389 pushq_cfi %rax
13390 cld
13391 SAVE_ARGS 0,1,0
13392 + pax_enter_kernel_user
13393 +
13394 +#ifdef CONFIG_PAX_RANDKSTACK
13395 + pax_erase_kstack
13396 +#endif
13397 +
13398 + /*
13399 + * No need to follow this irqs on/off section: the syscall
13400 + * disabled irqs, here we enable it straight after entry:
13401 + */
13402 + ENABLE_INTERRUPTS(CLBR_NONE)
13403 /* no need to do an access_ok check here because rbp has been
13404 32bit zero extended */
13405 +
13406 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13407 + addq pax_user_shadow_base,%rbp
13408 + ASM_PAX_OPEN_USERLAND
13409 +#endif
13410 +
13411 ASM_STAC
13412 1: movl (%rbp),%ebp
13413 _ASM_EXTABLE(1b,ia32_badarg)
13414 ASM_CLAC
13415 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13416 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13417 +
13418 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13419 + ASM_PAX_CLOSE_USERLAND
13420 +#endif
13421 +
13422 + GET_THREAD_INFO(%r11)
13423 + orl $TS_COMPAT,TI_status(%r11)
13424 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13425 CFI_REMEMBER_STATE
13426 jnz sysenter_tracesys
13427 cmpq $(IA32_NR_syscalls-1),%rax
13428 @@ -162,12 +209,15 @@ sysenter_do_call:
13429 sysenter_dispatch:
13430 call *ia32_sys_call_table(,%rax,8)
13431 movq %rax,RAX-ARGOFFSET(%rsp)
13432 + GET_THREAD_INFO(%r11)
13433 DISABLE_INTERRUPTS(CLBR_NONE)
13434 TRACE_IRQS_OFF
13435 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13436 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13437 jnz sysexit_audit
13438 sysexit_from_sys_call:
13439 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13440 + pax_exit_kernel_user
13441 + pax_erase_kstack
13442 + andl $~TS_COMPAT,TI_status(%r11)
13443 /* clear IF, that popfq doesn't enable interrupts early */
13444 andl $~0x200,EFLAGS-R11(%rsp)
13445 movl RIP-R11(%rsp),%edx /* User %eip */
13446 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13447 movl %eax,%esi /* 2nd arg: syscall number */
13448 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13449 call __audit_syscall_entry
13450 +
13451 + pax_erase_kstack
13452 +
13453 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13454 cmpq $(IA32_NR_syscalls-1),%rax
13455 ja ia32_badsys
13456 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13457 .endm
13458
13459 .macro auditsys_exit exit
13460 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13461 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13462 jnz ia32_ret_from_sys_call
13463 TRACE_IRQS_ON
13464 ENABLE_INTERRUPTS(CLBR_NONE)
13465 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13466 1: setbe %al /* 1 if error, 0 if not */
13467 movzbl %al,%edi /* zero-extend that into %edi */
13468 call __audit_syscall_exit
13469 + GET_THREAD_INFO(%r11)
13470 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13471 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13472 DISABLE_INTERRUPTS(CLBR_NONE)
13473 TRACE_IRQS_OFF
13474 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13475 + testl %edi,TI_flags(%r11)
13476 jz \exit
13477 CLEAR_RREGS -ARGOFFSET
13478 jmp int_with_check
13479 @@ -237,7 +291,7 @@ sysexit_audit:
13480
13481 sysenter_tracesys:
13482 #ifdef CONFIG_AUDITSYSCALL
13483 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13484 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13485 jz sysenter_auditsys
13486 #endif
13487 SAVE_REST
13488 @@ -249,6 +303,9 @@ sysenter_tracesys:
13489 RESTORE_REST
13490 cmpq $(IA32_NR_syscalls-1),%rax
13491 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13492 +
13493 + pax_erase_kstack
13494 +
13495 jmp sysenter_do_call
13496 CFI_ENDPROC
13497 ENDPROC(ia32_sysenter_target)
13498 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13499 ENTRY(ia32_cstar_target)
13500 CFI_STARTPROC32 simple
13501 CFI_SIGNAL_FRAME
13502 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13503 + CFI_DEF_CFA rsp,0
13504 CFI_REGISTER rip,rcx
13505 /*CFI_REGISTER rflags,r11*/
13506 SWAPGS_UNSAFE_STACK
13507 movl %esp,%r8d
13508 CFI_REGISTER rsp,r8
13509 movq PER_CPU_VAR(kernel_stack),%rsp
13510 + SAVE_ARGS 8*6,0,0
13511 + pax_enter_kernel_user
13512 +
13513 +#ifdef CONFIG_PAX_RANDKSTACK
13514 + pax_erase_kstack
13515 +#endif
13516 +
13517 /*
13518 * No need to follow this irqs on/off section: the syscall
13519 * disabled irqs and here we enable it straight after entry:
13520 */
13521 ENABLE_INTERRUPTS(CLBR_NONE)
13522 - SAVE_ARGS 8,0,0
13523 movl %eax,%eax /* zero extension */
13524 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13525 movq %rcx,RIP-ARGOFFSET(%rsp)
13526 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13527 /* no need to do an access_ok check here because r8 has been
13528 32bit zero extended */
13529 /* hardware stack frame is complete now */
13530 +
13531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13532 + ASM_PAX_OPEN_USERLAND
13533 + movq pax_user_shadow_base,%r8
13534 + addq RSP-ARGOFFSET(%rsp),%r8
13535 +#endif
13536 +
13537 ASM_STAC
13538 1: movl (%r8),%r9d
13539 _ASM_EXTABLE(1b,ia32_badarg)
13540 ASM_CLAC
13541 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13542 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13543 +
13544 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13545 + ASM_PAX_CLOSE_USERLAND
13546 +#endif
13547 +
13548 + GET_THREAD_INFO(%r11)
13549 + orl $TS_COMPAT,TI_status(%r11)
13550 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13551 CFI_REMEMBER_STATE
13552 jnz cstar_tracesys
13553 cmpq $IA32_NR_syscalls-1,%rax
13554 @@ -319,12 +395,15 @@ cstar_do_call:
13555 cstar_dispatch:
13556 call *ia32_sys_call_table(,%rax,8)
13557 movq %rax,RAX-ARGOFFSET(%rsp)
13558 + GET_THREAD_INFO(%r11)
13559 DISABLE_INTERRUPTS(CLBR_NONE)
13560 TRACE_IRQS_OFF
13561 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13562 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13563 jnz sysretl_audit
13564 sysretl_from_sys_call:
13565 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13566 + pax_exit_kernel_user
13567 + pax_erase_kstack
13568 + andl $~TS_COMPAT,TI_status(%r11)
13569 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13570 movl RIP-ARGOFFSET(%rsp),%ecx
13571 CFI_REGISTER rip,rcx
13572 @@ -352,7 +431,7 @@ sysretl_audit:
13573
13574 cstar_tracesys:
13575 #ifdef CONFIG_AUDITSYSCALL
13576 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13577 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13578 jz cstar_auditsys
13579 #endif
13580 xchgl %r9d,%ebp
13581 @@ -366,11 +445,19 @@ cstar_tracesys:
13582 xchgl %ebp,%r9d
13583 cmpq $(IA32_NR_syscalls-1),%rax
13584 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13585 +
13586 + pax_erase_kstack
13587 +
13588 jmp cstar_do_call
13589 END(ia32_cstar_target)
13590
13591 ia32_badarg:
13592 ASM_CLAC
13593 +
13594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13595 + ASM_PAX_CLOSE_USERLAND
13596 +#endif
13597 +
13598 movq $-EFAULT,%rax
13599 jmp ia32_sysret
13600 CFI_ENDPROC
13601 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13602 CFI_REL_OFFSET rip,RIP-RIP
13603 PARAVIRT_ADJUST_EXCEPTION_FRAME
13604 SWAPGS
13605 - /*
13606 - * No need to follow this irqs on/off section: the syscall
13607 - * disabled irqs and here we enable it straight after entry:
13608 - */
13609 - ENABLE_INTERRUPTS(CLBR_NONE)
13610 movl %eax,%eax
13611 pushq_cfi %rax
13612 cld
13613 /* note the registers are not zero extended to the sf.
13614 this could be a problem. */
13615 SAVE_ARGS 0,1,0
13616 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13617 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13618 + pax_enter_kernel_user
13619 +
13620 +#ifdef CONFIG_PAX_RANDKSTACK
13621 + pax_erase_kstack
13622 +#endif
13623 +
13624 + /*
13625 + * No need to follow this irqs on/off section: the syscall
13626 + * disabled irqs and here we enable it straight after entry:
13627 + */
13628 + ENABLE_INTERRUPTS(CLBR_NONE)
13629 + GET_THREAD_INFO(%r11)
13630 + orl $TS_COMPAT,TI_status(%r11)
13631 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13632 jnz ia32_tracesys
13633 cmpq $(IA32_NR_syscalls-1),%rax
13634 ja ia32_badsys
13635 @@ -442,6 +536,9 @@ ia32_tracesys:
13636 RESTORE_REST
13637 cmpq $(IA32_NR_syscalls-1),%rax
13638 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13639 +
13640 + pax_erase_kstack
13641 +
13642 jmp ia32_do_call
13643 END(ia32_syscall)
13644
13645 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13646 index 8e0ceec..af13504 100644
13647 --- a/arch/x86/ia32/sys_ia32.c
13648 +++ b/arch/x86/ia32/sys_ia32.c
13649 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13650 */
13651 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13652 {
13653 - typeof(ubuf->st_uid) uid = 0;
13654 - typeof(ubuf->st_gid) gid = 0;
13655 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13656 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13657 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13658 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13659 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13660 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13661 index 372231c..a5aa1a1 100644
13662 --- a/arch/x86/include/asm/alternative-asm.h
13663 +++ b/arch/x86/include/asm/alternative-asm.h
13664 @@ -18,6 +18,45 @@
13665 .endm
13666 #endif
13667
13668 +#ifdef KERNEXEC_PLUGIN
13669 + .macro pax_force_retaddr_bts rip=0
13670 + btsq $63,\rip(%rsp)
13671 + .endm
13672 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13673 + .macro pax_force_retaddr rip=0, reload=0
13674 + btsq $63,\rip(%rsp)
13675 + .endm
13676 + .macro pax_force_fptr ptr
13677 + btsq $63,\ptr
13678 + .endm
13679 + .macro pax_set_fptr_mask
13680 + .endm
13681 +#endif
13682 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13683 + .macro pax_force_retaddr rip=0, reload=0
13684 + .if \reload
13685 + pax_set_fptr_mask
13686 + .endif
13687 + orq %r10,\rip(%rsp)
13688 + .endm
13689 + .macro pax_force_fptr ptr
13690 + orq %r10,\ptr
13691 + .endm
13692 + .macro pax_set_fptr_mask
13693 + movabs $0x8000000000000000,%r10
13694 + .endm
13695 +#endif
13696 +#else
13697 + .macro pax_force_retaddr rip=0, reload=0
13698 + .endm
13699 + .macro pax_force_fptr ptr
13700 + .endm
13701 + .macro pax_force_retaddr_bts rip=0
13702 + .endm
13703 + .macro pax_set_fptr_mask
13704 + .endm
13705 +#endif
13706 +
13707 .macro altinstruction_entry orig alt feature orig_len alt_len
13708 .long \orig - .
13709 .long \alt - .
13710 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13711 index 58ed6d9..f1cbe58 100644
13712 --- a/arch/x86/include/asm/alternative.h
13713 +++ b/arch/x86/include/asm/alternative.h
13714 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13715 ".pushsection .discard,\"aw\",@progbits\n" \
13716 DISCARD_ENTRY(1) \
13717 ".popsection\n" \
13718 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13719 + ".pushsection .altinstr_replacement, \"a\"\n" \
13720 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13721 ".popsection"
13722
13723 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13724 DISCARD_ENTRY(1) \
13725 DISCARD_ENTRY(2) \
13726 ".popsection\n" \
13727 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13728 + ".pushsection .altinstr_replacement, \"a\"\n" \
13729 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13730 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13731 ".popsection"
13732 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13733 index f8119b5..7209d5b 100644
13734 --- a/arch/x86/include/asm/apic.h
13735 +++ b/arch/x86/include/asm/apic.h
13736 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13737
13738 #ifdef CONFIG_X86_LOCAL_APIC
13739
13740 -extern unsigned int apic_verbosity;
13741 +extern int apic_verbosity;
13742 extern int local_apic_timer_c2_ok;
13743
13744 extern int disable_apic;
13745 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13746 index 20370c6..a2eb9b0 100644
13747 --- a/arch/x86/include/asm/apm.h
13748 +++ b/arch/x86/include/asm/apm.h
13749 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13750 __asm__ __volatile__(APM_DO_ZERO_SEGS
13751 "pushl %%edi\n\t"
13752 "pushl %%ebp\n\t"
13753 - "lcall *%%cs:apm_bios_entry\n\t"
13754 + "lcall *%%ss:apm_bios_entry\n\t"
13755 "setc %%al\n\t"
13756 "popl %%ebp\n\t"
13757 "popl %%edi\n\t"
13758 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13759 __asm__ __volatile__(APM_DO_ZERO_SEGS
13760 "pushl %%edi\n\t"
13761 "pushl %%ebp\n\t"
13762 - "lcall *%%cs:apm_bios_entry\n\t"
13763 + "lcall *%%ss:apm_bios_entry\n\t"
13764 "setc %%bl\n\t"
13765 "popl %%ebp\n\t"
13766 "popl %%edi\n\t"
13767 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13768 index 722aa3b..3a0bb27 100644
13769 --- a/arch/x86/include/asm/atomic.h
13770 +++ b/arch/x86/include/asm/atomic.h
13771 @@ -22,7 +22,18 @@
13772 */
13773 static inline int atomic_read(const atomic_t *v)
13774 {
13775 - return (*(volatile int *)&(v)->counter);
13776 + return (*(volatile const int *)&(v)->counter);
13777 +}
13778 +
13779 +/**
13780 + * atomic_read_unchecked - read atomic variable
13781 + * @v: pointer of type atomic_unchecked_t
13782 + *
13783 + * Atomically reads the value of @v.
13784 + */
13785 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13786 +{
13787 + return (*(volatile const int *)&(v)->counter);
13788 }
13789
13790 /**
13791 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13792 }
13793
13794 /**
13795 + * atomic_set_unchecked - set atomic variable
13796 + * @v: pointer of type atomic_unchecked_t
13797 + * @i: required value
13798 + *
13799 + * Atomically sets the value of @v to @i.
13800 + */
13801 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13802 +{
13803 + v->counter = i;
13804 +}
13805 +
13806 +/**
13807 * atomic_add - add integer to atomic variable
13808 * @i: integer value to add
13809 * @v: pointer of type atomic_t
13810 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13811 */
13812 static inline void atomic_add(int i, atomic_t *v)
13813 {
13814 - asm volatile(LOCK_PREFIX "addl %1,%0"
13815 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13816 +
13817 +#ifdef CONFIG_PAX_REFCOUNT
13818 + "jno 0f\n"
13819 + LOCK_PREFIX "subl %1,%0\n"
13820 + "int $4\n0:\n"
13821 + _ASM_EXTABLE(0b, 0b)
13822 +#endif
13823 +
13824 + : "+m" (v->counter)
13825 + : "ir" (i));
13826 +}
13827 +
13828 +/**
13829 + * atomic_add_unchecked - add integer to atomic variable
13830 + * @i: integer value to add
13831 + * @v: pointer of type atomic_unchecked_t
13832 + *
13833 + * Atomically adds @i to @v.
13834 + */
13835 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13836 +{
13837 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13838 : "+m" (v->counter)
13839 : "ir" (i));
13840 }
13841 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13842 */
13843 static inline void atomic_sub(int i, atomic_t *v)
13844 {
13845 - asm volatile(LOCK_PREFIX "subl %1,%0"
13846 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13847 +
13848 +#ifdef CONFIG_PAX_REFCOUNT
13849 + "jno 0f\n"
13850 + LOCK_PREFIX "addl %1,%0\n"
13851 + "int $4\n0:\n"
13852 + _ASM_EXTABLE(0b, 0b)
13853 +#endif
13854 +
13855 + : "+m" (v->counter)
13856 + : "ir" (i));
13857 +}
13858 +
13859 +/**
13860 + * atomic_sub_unchecked - subtract integer from atomic variable
13861 + * @i: integer value to subtract
13862 + * @v: pointer of type atomic_unchecked_t
13863 + *
13864 + * Atomically subtracts @i from @v.
13865 + */
13866 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13867 +{
13868 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13869 : "+m" (v->counter)
13870 : "ir" (i));
13871 }
13872 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13873 {
13874 unsigned char c;
13875
13876 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13877 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13878 +
13879 +#ifdef CONFIG_PAX_REFCOUNT
13880 + "jno 0f\n"
13881 + LOCK_PREFIX "addl %2,%0\n"
13882 + "int $4\n0:\n"
13883 + _ASM_EXTABLE(0b, 0b)
13884 +#endif
13885 +
13886 + "sete %1\n"
13887 : "+m" (v->counter), "=qm" (c)
13888 : "ir" (i) : "memory");
13889 return c;
13890 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13891 */
13892 static inline void atomic_inc(atomic_t *v)
13893 {
13894 - asm volatile(LOCK_PREFIX "incl %0"
13895 + asm volatile(LOCK_PREFIX "incl %0\n"
13896 +
13897 +#ifdef CONFIG_PAX_REFCOUNT
13898 + "jno 0f\n"
13899 + LOCK_PREFIX "decl %0\n"
13900 + "int $4\n0:\n"
13901 + _ASM_EXTABLE(0b, 0b)
13902 +#endif
13903 +
13904 + : "+m" (v->counter));
13905 +}
13906 +
13907 +/**
13908 + * atomic_inc_unchecked - increment atomic variable
13909 + * @v: pointer of type atomic_unchecked_t
13910 + *
13911 + * Atomically increments @v by 1.
13912 + */
13913 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13914 +{
13915 + asm volatile(LOCK_PREFIX "incl %0\n"
13916 : "+m" (v->counter));
13917 }
13918
13919 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13920 */
13921 static inline void atomic_dec(atomic_t *v)
13922 {
13923 - asm volatile(LOCK_PREFIX "decl %0"
13924 + asm volatile(LOCK_PREFIX "decl %0\n"
13925 +
13926 +#ifdef CONFIG_PAX_REFCOUNT
13927 + "jno 0f\n"
13928 + LOCK_PREFIX "incl %0\n"
13929 + "int $4\n0:\n"
13930 + _ASM_EXTABLE(0b, 0b)
13931 +#endif
13932 +
13933 + : "+m" (v->counter));
13934 +}
13935 +
13936 +/**
13937 + * atomic_dec_unchecked - decrement atomic variable
13938 + * @v: pointer of type atomic_unchecked_t
13939 + *
13940 + * Atomically decrements @v by 1.
13941 + */
13942 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13943 +{
13944 + asm volatile(LOCK_PREFIX "decl %0\n"
13945 : "+m" (v->counter));
13946 }
13947
13948 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13949 {
13950 unsigned char c;
13951
13952 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13953 + asm volatile(LOCK_PREFIX "decl %0\n"
13954 +
13955 +#ifdef CONFIG_PAX_REFCOUNT
13956 + "jno 0f\n"
13957 + LOCK_PREFIX "incl %0\n"
13958 + "int $4\n0:\n"
13959 + _ASM_EXTABLE(0b, 0b)
13960 +#endif
13961 +
13962 + "sete %1\n"
13963 : "+m" (v->counter), "=qm" (c)
13964 : : "memory");
13965 return c != 0;
13966 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13967 {
13968 unsigned char c;
13969
13970 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13971 + asm volatile(LOCK_PREFIX "incl %0\n"
13972 +
13973 +#ifdef CONFIG_PAX_REFCOUNT
13974 + "jno 0f\n"
13975 + LOCK_PREFIX "decl %0\n"
13976 + "int $4\n0:\n"
13977 + _ASM_EXTABLE(0b, 0b)
13978 +#endif
13979 +
13980 + "sete %1\n"
13981 + : "+m" (v->counter), "=qm" (c)
13982 + : : "memory");
13983 + return c != 0;
13984 +}
13985 +
13986 +/**
13987 + * atomic_inc_and_test_unchecked - increment and test
13988 + * @v: pointer of type atomic_unchecked_t
13989 + *
13990 + * Atomically increments @v by 1
13991 + * and returns true if the result is zero, or false for all
13992 + * other cases.
13993 + */
13994 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
13995 +{
13996 + unsigned char c;
13997 +
13998 + asm volatile(LOCK_PREFIX "incl %0\n"
13999 + "sete %1\n"
14000 : "+m" (v->counter), "=qm" (c)
14001 : : "memory");
14002 return c != 0;
14003 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14004 {
14005 unsigned char c;
14006
14007 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14008 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14009 +
14010 +#ifdef CONFIG_PAX_REFCOUNT
14011 + "jno 0f\n"
14012 + LOCK_PREFIX "subl %2,%0\n"
14013 + "int $4\n0:\n"
14014 + _ASM_EXTABLE(0b, 0b)
14015 +#endif
14016 +
14017 + "sets %1\n"
14018 : "+m" (v->counter), "=qm" (c)
14019 : "ir" (i) : "memory");
14020 return c;
14021 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14022 */
14023 static inline int atomic_add_return(int i, atomic_t *v)
14024 {
14025 + return i + xadd_check_overflow(&v->counter, i);
14026 +}
14027 +
14028 +/**
14029 + * atomic_add_return_unchecked - add integer and return
14030 + * @i: integer value to add
14031 + * @v: pointer of type atomic_unchecked_t
14032 + *
14033 + * Atomically adds @i to @v and returns @i + @v
14034 + */
14035 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14036 +{
14037 return i + xadd(&v->counter, i);
14038 }
14039
14040 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14041 }
14042
14043 #define atomic_inc_return(v) (atomic_add_return(1, v))
14044 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14045 +{
14046 + return atomic_add_return_unchecked(1, v);
14047 +}
14048 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14049
14050 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14051 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14052 return cmpxchg(&v->counter, old, new);
14053 }
14054
14055 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14056 +{
14057 + return cmpxchg(&v->counter, old, new);
14058 +}
14059 +
14060 static inline int atomic_xchg(atomic_t *v, int new)
14061 {
14062 return xchg(&v->counter, new);
14063 }
14064
14065 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14066 +{
14067 + return xchg(&v->counter, new);
14068 +}
14069 +
14070 /**
14071 * __atomic_add_unless - add unless the number is already a given value
14072 * @v: pointer of type atomic_t
14073 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14074 */
14075 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14076 {
14077 - int c, old;
14078 + int c, old, new;
14079 c = atomic_read(v);
14080 for (;;) {
14081 - if (unlikely(c == (u)))
14082 + if (unlikely(c == u))
14083 break;
14084 - old = atomic_cmpxchg((v), c, c + (a));
14085 +
14086 + asm volatile("addl %2,%0\n"
14087 +
14088 +#ifdef CONFIG_PAX_REFCOUNT
14089 + "jno 0f\n"
14090 + "subl %2,%0\n"
14091 + "int $4\n0:\n"
14092 + _ASM_EXTABLE(0b, 0b)
14093 +#endif
14094 +
14095 + : "=r" (new)
14096 + : "0" (c), "ir" (a));
14097 +
14098 + old = atomic_cmpxchg(v, c, new);
14099 if (likely(old == c))
14100 break;
14101 c = old;
14102 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14103 }
14104
14105 /**
14106 + * atomic_inc_not_zero_hint - increment if not null
14107 + * @v: pointer of type atomic_t
14108 + * @hint: probable value of the atomic before the increment
14109 + *
14110 + * This version of atomic_inc_not_zero() gives a hint of probable
14111 + * value of the atomic. This helps processor to not read the memory
14112 + * before doing the atomic read/modify/write cycle, lowering
14113 + * number of bus transactions on some arches.
14114 + *
14115 + * Returns: 0 if increment was not done, 1 otherwise.
14116 + */
14117 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14118 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14119 +{
14120 + int val, c = hint, new;
14121 +
14122 + /* sanity test, should be removed by compiler if hint is a constant */
14123 + if (!hint)
14124 + return __atomic_add_unless(v, 1, 0);
14125 +
14126 + do {
14127 + asm volatile("incl %0\n"
14128 +
14129 +#ifdef CONFIG_PAX_REFCOUNT
14130 + "jno 0f\n"
14131 + "decl %0\n"
14132 + "int $4\n0:\n"
14133 + _ASM_EXTABLE(0b, 0b)
14134 +#endif
14135 +
14136 + : "=r" (new)
14137 + : "0" (c));
14138 +
14139 + val = atomic_cmpxchg(v, c, new);
14140 + if (val == c)
14141 + return 1;
14142 + c = val;
14143 + } while (c);
14144 +
14145 + return 0;
14146 +}
14147 +
14148 +/**
14149 * atomic_inc_short - increment of a short integer
14150 * @v: pointer to type int
14151 *
14152 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14153 #endif
14154
14155 /* These are x86-specific, used by some header files */
14156 -#define atomic_clear_mask(mask, addr) \
14157 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14158 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14159 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14160 +{
14161 + asm volatile(LOCK_PREFIX "andl %1,%0"
14162 + : "+m" (v->counter)
14163 + : "r" (~(mask))
14164 + : "memory");
14165 +}
14166
14167 -#define atomic_set_mask(mask, addr) \
14168 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14169 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14170 - : "memory")
14171 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14172 +{
14173 + asm volatile(LOCK_PREFIX "andl %1,%0"
14174 + : "+m" (v->counter)
14175 + : "r" (~(mask))
14176 + : "memory");
14177 +}
14178 +
14179 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14180 +{
14181 + asm volatile(LOCK_PREFIX "orl %1,%0"
14182 + : "+m" (v->counter)
14183 + : "r" (mask)
14184 + : "memory");
14185 +}
14186 +
14187 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14188 +{
14189 + asm volatile(LOCK_PREFIX "orl %1,%0"
14190 + : "+m" (v->counter)
14191 + : "r" (mask)
14192 + : "memory");
14193 +}
14194
14195 /* Atomic operations are already serializing on x86 */
14196 #define smp_mb__before_atomic_dec() barrier()
14197 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14198 index b154de7..aadebd8 100644
14199 --- a/arch/x86/include/asm/atomic64_32.h
14200 +++ b/arch/x86/include/asm/atomic64_32.h
14201 @@ -12,6 +12,14 @@ typedef struct {
14202 u64 __aligned(8) counter;
14203 } atomic64_t;
14204
14205 +#ifdef CONFIG_PAX_REFCOUNT
14206 +typedef struct {
14207 + u64 __aligned(8) counter;
14208 +} atomic64_unchecked_t;
14209 +#else
14210 +typedef atomic64_t atomic64_unchecked_t;
14211 +#endif
14212 +
14213 #define ATOMIC64_INIT(val) { (val) }
14214
14215 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14216 @@ -37,21 +45,31 @@ typedef struct {
14217 ATOMIC64_DECL_ONE(sym##_386)
14218
14219 ATOMIC64_DECL_ONE(add_386);
14220 +ATOMIC64_DECL_ONE(add_unchecked_386);
14221 ATOMIC64_DECL_ONE(sub_386);
14222 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14223 ATOMIC64_DECL_ONE(inc_386);
14224 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14225 ATOMIC64_DECL_ONE(dec_386);
14226 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14227 #endif
14228
14229 #define alternative_atomic64(f, out, in...) \
14230 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14231
14232 ATOMIC64_DECL(read);
14233 +ATOMIC64_DECL(read_unchecked);
14234 ATOMIC64_DECL(set);
14235 +ATOMIC64_DECL(set_unchecked);
14236 ATOMIC64_DECL(xchg);
14237 ATOMIC64_DECL(add_return);
14238 +ATOMIC64_DECL(add_return_unchecked);
14239 ATOMIC64_DECL(sub_return);
14240 +ATOMIC64_DECL(sub_return_unchecked);
14241 ATOMIC64_DECL(inc_return);
14242 +ATOMIC64_DECL(inc_return_unchecked);
14243 ATOMIC64_DECL(dec_return);
14244 +ATOMIC64_DECL(dec_return_unchecked);
14245 ATOMIC64_DECL(dec_if_positive);
14246 ATOMIC64_DECL(inc_not_zero);
14247 ATOMIC64_DECL(add_unless);
14248 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14249 }
14250
14251 /**
14252 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14253 + * @p: pointer to type atomic64_unchecked_t
14254 + * @o: expected value
14255 + * @n: new value
14256 + *
14257 + * Atomically sets @v to @n if it was equal to @o and returns
14258 + * the old value.
14259 + */
14260 +
14261 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14262 +{
14263 + return cmpxchg64(&v->counter, o, n);
14264 +}
14265 +
14266 +/**
14267 * atomic64_xchg - xchg atomic64 variable
14268 * @v: pointer to type atomic64_t
14269 * @n: value to assign
14270 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14271 }
14272
14273 /**
14274 + * atomic64_set_unchecked - set atomic64 variable
14275 + * @v: pointer to type atomic64_unchecked_t
14276 + * @n: value to assign
14277 + *
14278 + * Atomically sets the value of @v to @n.
14279 + */
14280 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14281 +{
14282 + unsigned high = (unsigned)(i >> 32);
14283 + unsigned low = (unsigned)i;
14284 + alternative_atomic64(set, /* no output */,
14285 + "S" (v), "b" (low), "c" (high)
14286 + : "eax", "edx", "memory");
14287 +}
14288 +
14289 +/**
14290 * atomic64_read - read atomic64 variable
14291 * @v: pointer to type atomic64_t
14292 *
14293 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14294 }
14295
14296 /**
14297 + * atomic64_read_unchecked - read atomic64 variable
14298 + * @v: pointer to type atomic64_unchecked_t
14299 + *
14300 + * Atomically reads the value of @v and returns it.
14301 + */
14302 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14303 +{
14304 + long long r;
14305 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14306 + return r;
14307 + }
14308 +
14309 +/**
14310 * atomic64_add_return - add and return
14311 * @i: integer value to add
14312 * @v: pointer to type atomic64_t
14313 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14314 return i;
14315 }
14316
14317 +/**
14318 + * atomic64_add_return_unchecked - add and return
14319 + * @i: integer value to add
14320 + * @v: pointer to type atomic64_unchecked_t
14321 + *
14322 + * Atomically adds @i to @v and returns @i + *@v
14323 + */
14324 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14325 +{
14326 + alternative_atomic64(add_return_unchecked,
14327 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14328 + ASM_NO_INPUT_CLOBBER("memory"));
14329 + return i;
14330 +}
14331 +
14332 /*
14333 * Other variants with different arithmetic operators:
14334 */
14335 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14336 return a;
14337 }
14338
14339 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14340 +{
14341 + long long a;
14342 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14343 + "S" (v) : "memory", "ecx");
14344 + return a;
14345 +}
14346 +
14347 static inline long long atomic64_dec_return(atomic64_t *v)
14348 {
14349 long long a;
14350 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14351 }
14352
14353 /**
14354 + * atomic64_add_unchecked - add integer to atomic64 variable
14355 + * @i: integer value to add
14356 + * @v: pointer to type atomic64_unchecked_t
14357 + *
14358 + * Atomically adds @i to @v.
14359 + */
14360 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14361 +{
14362 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14363 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14364 + ASM_NO_INPUT_CLOBBER("memory"));
14365 + return i;
14366 +}
14367 +
14368 +/**
14369 * atomic64_sub - subtract the atomic64 variable
14370 * @i: integer value to subtract
14371 * @v: pointer to type atomic64_t
14372 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14373 index 0e1cbfc..5623683 100644
14374 --- a/arch/x86/include/asm/atomic64_64.h
14375 +++ b/arch/x86/include/asm/atomic64_64.h
14376 @@ -18,7 +18,19 @@
14377 */
14378 static inline long atomic64_read(const atomic64_t *v)
14379 {
14380 - return (*(volatile long *)&(v)->counter);
14381 + return (*(volatile const long *)&(v)->counter);
14382 +}
14383 +
14384 +/**
14385 + * atomic64_read_unchecked - read atomic64 variable
14386 + * @v: pointer of type atomic64_unchecked_t
14387 + *
14388 + * Atomically reads the value of @v.
14389 + * Doesn't imply a read memory barrier.
14390 + */
14391 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14392 +{
14393 + return (*(volatile const long *)&(v)->counter);
14394 }
14395
14396 /**
14397 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14398 }
14399
14400 /**
14401 + * atomic64_set_unchecked - set atomic64 variable
14402 + * @v: pointer to type atomic64_unchecked_t
14403 + * @i: required value
14404 + *
14405 + * Atomically sets the value of @v to @i.
14406 + */
14407 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14408 +{
14409 + v->counter = i;
14410 +}
14411 +
14412 +/**
14413 * atomic64_add - add integer to atomic64 variable
14414 * @i: integer value to add
14415 * @v: pointer to type atomic64_t
14416 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14417 */
14418 static inline void atomic64_add(long i, atomic64_t *v)
14419 {
14420 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14421 +
14422 +#ifdef CONFIG_PAX_REFCOUNT
14423 + "jno 0f\n"
14424 + LOCK_PREFIX "subq %1,%0\n"
14425 + "int $4\n0:\n"
14426 + _ASM_EXTABLE(0b, 0b)
14427 +#endif
14428 +
14429 + : "=m" (v->counter)
14430 + : "er" (i), "m" (v->counter));
14431 +}
14432 +
14433 +/**
14434 + * atomic64_add_unchecked - add integer to atomic64 variable
14435 + * @i: integer value to add
14436 + * @v: pointer to type atomic64_unchecked_t
14437 + *
14438 + * Atomically adds @i to @v.
14439 + */
14440 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14441 +{
14442 asm volatile(LOCK_PREFIX "addq %1,%0"
14443 : "=m" (v->counter)
14444 : "er" (i), "m" (v->counter));
14445 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14446 */
14447 static inline void atomic64_sub(long i, atomic64_t *v)
14448 {
14449 - asm volatile(LOCK_PREFIX "subq %1,%0"
14450 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14451 +
14452 +#ifdef CONFIG_PAX_REFCOUNT
14453 + "jno 0f\n"
14454 + LOCK_PREFIX "addq %1,%0\n"
14455 + "int $4\n0:\n"
14456 + _ASM_EXTABLE(0b, 0b)
14457 +#endif
14458 +
14459 + : "=m" (v->counter)
14460 + : "er" (i), "m" (v->counter));
14461 +}
14462 +
14463 +/**
14464 + * atomic64_sub_unchecked - subtract the atomic64 variable
14465 + * @i: integer value to subtract
14466 + * @v: pointer to type atomic64_unchecked_t
14467 + *
14468 + * Atomically subtracts @i from @v.
14469 + */
14470 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14471 +{
14472 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14473 : "=m" (v->counter)
14474 : "er" (i), "m" (v->counter));
14475 }
14476 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14477 {
14478 unsigned char c;
14479
14480 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14481 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14482 +
14483 +#ifdef CONFIG_PAX_REFCOUNT
14484 + "jno 0f\n"
14485 + LOCK_PREFIX "addq %2,%0\n"
14486 + "int $4\n0:\n"
14487 + _ASM_EXTABLE(0b, 0b)
14488 +#endif
14489 +
14490 + "sete %1\n"
14491 : "=m" (v->counter), "=qm" (c)
14492 : "er" (i), "m" (v->counter) : "memory");
14493 return c;
14494 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14495 */
14496 static inline void atomic64_inc(atomic64_t *v)
14497 {
14498 + asm volatile(LOCK_PREFIX "incq %0\n"
14499 +
14500 +#ifdef CONFIG_PAX_REFCOUNT
14501 + "jno 0f\n"
14502 + LOCK_PREFIX "decq %0\n"
14503 + "int $4\n0:\n"
14504 + _ASM_EXTABLE(0b, 0b)
14505 +#endif
14506 +
14507 + : "=m" (v->counter)
14508 + : "m" (v->counter));
14509 +}
14510 +
14511 +/**
14512 + * atomic64_inc_unchecked - increment atomic64 variable
14513 + * @v: pointer to type atomic64_unchecked_t
14514 + *
14515 + * Atomically increments @v by 1.
14516 + */
14517 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14518 +{
14519 asm volatile(LOCK_PREFIX "incq %0"
14520 : "=m" (v->counter)
14521 : "m" (v->counter));
14522 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14523 */
14524 static inline void atomic64_dec(atomic64_t *v)
14525 {
14526 - asm volatile(LOCK_PREFIX "decq %0"
14527 + asm volatile(LOCK_PREFIX "decq %0\n"
14528 +
14529 +#ifdef CONFIG_PAX_REFCOUNT
14530 + "jno 0f\n"
14531 + LOCK_PREFIX "incq %0\n"
14532 + "int $4\n0:\n"
14533 + _ASM_EXTABLE(0b, 0b)
14534 +#endif
14535 +
14536 + : "=m" (v->counter)
14537 + : "m" (v->counter));
14538 +}
14539 +
14540 +/**
14541 + * atomic64_dec_unchecked - decrement atomic64 variable
14542 + * @v: pointer to type atomic64_t
14543 + *
14544 + * Atomically decrements @v by 1.
14545 + */
14546 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14547 +{
14548 + asm volatile(LOCK_PREFIX "decq %0\n"
14549 : "=m" (v->counter)
14550 : "m" (v->counter));
14551 }
14552 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14553 {
14554 unsigned char c;
14555
14556 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14557 + asm volatile(LOCK_PREFIX "decq %0\n"
14558 +
14559 +#ifdef CONFIG_PAX_REFCOUNT
14560 + "jno 0f\n"
14561 + LOCK_PREFIX "incq %0\n"
14562 + "int $4\n0:\n"
14563 + _ASM_EXTABLE(0b, 0b)
14564 +#endif
14565 +
14566 + "sete %1\n"
14567 : "=m" (v->counter), "=qm" (c)
14568 : "m" (v->counter) : "memory");
14569 return c != 0;
14570 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14571 {
14572 unsigned char c;
14573
14574 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14575 + asm volatile(LOCK_PREFIX "incq %0\n"
14576 +
14577 +#ifdef CONFIG_PAX_REFCOUNT
14578 + "jno 0f\n"
14579 + LOCK_PREFIX "decq %0\n"
14580 + "int $4\n0:\n"
14581 + _ASM_EXTABLE(0b, 0b)
14582 +#endif
14583 +
14584 + "sete %1\n"
14585 : "=m" (v->counter), "=qm" (c)
14586 : "m" (v->counter) : "memory");
14587 return c != 0;
14588 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14589 {
14590 unsigned char c;
14591
14592 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14593 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14594 +
14595 +#ifdef CONFIG_PAX_REFCOUNT
14596 + "jno 0f\n"
14597 + LOCK_PREFIX "subq %2,%0\n"
14598 + "int $4\n0:\n"
14599 + _ASM_EXTABLE(0b, 0b)
14600 +#endif
14601 +
14602 + "sets %1\n"
14603 : "=m" (v->counter), "=qm" (c)
14604 : "er" (i), "m" (v->counter) : "memory");
14605 return c;
14606 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14607 */
14608 static inline long atomic64_add_return(long i, atomic64_t *v)
14609 {
14610 + return i + xadd_check_overflow(&v->counter, i);
14611 +}
14612 +
14613 +/**
14614 + * atomic64_add_return_unchecked - add and return
14615 + * @i: integer value to add
14616 + * @v: pointer to type atomic64_unchecked_t
14617 + *
14618 + * Atomically adds @i to @v and returns @i + @v
14619 + */
14620 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14621 +{
14622 return i + xadd(&v->counter, i);
14623 }
14624
14625 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14626 }
14627
14628 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14629 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14630 +{
14631 + return atomic64_add_return_unchecked(1, v);
14632 +}
14633 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14634
14635 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14636 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14637 return cmpxchg(&v->counter, old, new);
14638 }
14639
14640 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14641 +{
14642 + return cmpxchg(&v->counter, old, new);
14643 +}
14644 +
14645 static inline long atomic64_xchg(atomic64_t *v, long new)
14646 {
14647 return xchg(&v->counter, new);
14648 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14649 */
14650 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14651 {
14652 - long c, old;
14653 + long c, old, new;
14654 c = atomic64_read(v);
14655 for (;;) {
14656 - if (unlikely(c == (u)))
14657 + if (unlikely(c == u))
14658 break;
14659 - old = atomic64_cmpxchg((v), c, c + (a));
14660 +
14661 + asm volatile("add %2,%0\n"
14662 +
14663 +#ifdef CONFIG_PAX_REFCOUNT
14664 + "jno 0f\n"
14665 + "sub %2,%0\n"
14666 + "int $4\n0:\n"
14667 + _ASM_EXTABLE(0b, 0b)
14668 +#endif
14669 +
14670 + : "=r" (new)
14671 + : "0" (c), "ir" (a));
14672 +
14673 + old = atomic64_cmpxchg(v, c, new);
14674 if (likely(old == c))
14675 break;
14676 c = old;
14677 }
14678 - return c != (u);
14679 + return c != u;
14680 }
14681
14682 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14683 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14684 index 6dfd019..28e188d 100644
14685 --- a/arch/x86/include/asm/bitops.h
14686 +++ b/arch/x86/include/asm/bitops.h
14687 @@ -40,7 +40,7 @@
14688 * a mask operation on a byte.
14689 */
14690 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14691 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14692 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14693 #define CONST_MASK(nr) (1 << ((nr) & 7))
14694
14695 /**
14696 @@ -486,7 +486,7 @@ static inline int fls(int x)
14697 * at position 64.
14698 */
14699 #ifdef CONFIG_X86_64
14700 -static __always_inline int fls64(__u64 x)
14701 +static __always_inline long fls64(__u64 x)
14702 {
14703 int bitpos = -1;
14704 /*
14705 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14706 index 4fa687a..60f2d39 100644
14707 --- a/arch/x86/include/asm/boot.h
14708 +++ b/arch/x86/include/asm/boot.h
14709 @@ -6,10 +6,15 @@
14710 #include <uapi/asm/boot.h>
14711
14712 /* Physical address where kernel should be loaded. */
14713 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14714 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14715 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14716 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14717
14718 +#ifndef __ASSEMBLY__
14719 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14720 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14721 +#endif
14722 +
14723 /* Minimum kernel alignment, as a power of two */
14724 #ifdef CONFIG_X86_64
14725 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14726 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14727 index 48f99f1..d78ebf9 100644
14728 --- a/arch/x86/include/asm/cache.h
14729 +++ b/arch/x86/include/asm/cache.h
14730 @@ -5,12 +5,13 @@
14731
14732 /* L1 cache line size */
14733 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14734 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14735 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14736
14737 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14738 +#define __read_only __attribute__((__section__(".data..read_only")))
14739
14740 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14741 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14742 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14743
14744 #ifdef CONFIG_X86_VSMP
14745 #ifdef CONFIG_SMP
14746 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14747 index 9863ee3..4a1f8e1 100644
14748 --- a/arch/x86/include/asm/cacheflush.h
14749 +++ b/arch/x86/include/asm/cacheflush.h
14750 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14751 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14752
14753 if (pg_flags == _PGMT_DEFAULT)
14754 - return -1;
14755 + return ~0UL;
14756 else if (pg_flags == _PGMT_WC)
14757 return _PAGE_CACHE_WC;
14758 else if (pg_flags == _PGMT_UC_MINUS)
14759 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14760 index f50de69..2b0a458 100644
14761 --- a/arch/x86/include/asm/checksum_32.h
14762 +++ b/arch/x86/include/asm/checksum_32.h
14763 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14764 int len, __wsum sum,
14765 int *src_err_ptr, int *dst_err_ptr);
14766
14767 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14768 + int len, __wsum sum,
14769 + int *src_err_ptr, int *dst_err_ptr);
14770 +
14771 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14772 + int len, __wsum sum,
14773 + int *src_err_ptr, int *dst_err_ptr);
14774 +
14775 /*
14776 * Note: when you get a NULL pointer exception here this means someone
14777 * passed in an incorrect kernel address to one of these functions.
14778 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14779
14780 might_sleep();
14781 stac();
14782 - ret = csum_partial_copy_generic((__force void *)src, dst,
14783 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14784 len, sum, err_ptr, NULL);
14785 clac();
14786
14787 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14788 might_sleep();
14789 if (access_ok(VERIFY_WRITE, dst, len)) {
14790 stac();
14791 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14792 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14793 len, sum, NULL, err_ptr);
14794 clac();
14795 return ret;
14796 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14797 index d47786a..ce1b05d 100644
14798 --- a/arch/x86/include/asm/cmpxchg.h
14799 +++ b/arch/x86/include/asm/cmpxchg.h
14800 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14801 __compiletime_error("Bad argument size for cmpxchg");
14802 extern void __xadd_wrong_size(void)
14803 __compiletime_error("Bad argument size for xadd");
14804 +extern void __xadd_check_overflow_wrong_size(void)
14805 + __compiletime_error("Bad argument size for xadd_check_overflow");
14806 extern void __add_wrong_size(void)
14807 __compiletime_error("Bad argument size for add");
14808 +extern void __add_check_overflow_wrong_size(void)
14809 + __compiletime_error("Bad argument size for add_check_overflow");
14810
14811 /*
14812 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14813 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14814 __ret; \
14815 })
14816
14817 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14818 + ({ \
14819 + __typeof__ (*(ptr)) __ret = (arg); \
14820 + switch (sizeof(*(ptr))) { \
14821 + case __X86_CASE_L: \
14822 + asm volatile (lock #op "l %0, %1\n" \
14823 + "jno 0f\n" \
14824 + "mov %0,%1\n" \
14825 + "int $4\n0:\n" \
14826 + _ASM_EXTABLE(0b, 0b) \
14827 + : "+r" (__ret), "+m" (*(ptr)) \
14828 + : : "memory", "cc"); \
14829 + break; \
14830 + case __X86_CASE_Q: \
14831 + asm volatile (lock #op "q %q0, %1\n" \
14832 + "jno 0f\n" \
14833 + "mov %0,%1\n" \
14834 + "int $4\n0:\n" \
14835 + _ASM_EXTABLE(0b, 0b) \
14836 + : "+r" (__ret), "+m" (*(ptr)) \
14837 + : : "memory", "cc"); \
14838 + break; \
14839 + default: \
14840 + __ ## op ## _check_overflow_wrong_size(); \
14841 + } \
14842 + __ret; \
14843 + })
14844 +
14845 /*
14846 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14847 * Since this is generally used to protect other memory information, we
14848 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14849 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14850 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14851
14852 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14853 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14854 +
14855 #define __add(ptr, inc, lock) \
14856 ({ \
14857 __typeof__ (*(ptr)) __ret = (inc); \
14858 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14859 index 59c6c40..5e0b22c 100644
14860 --- a/arch/x86/include/asm/compat.h
14861 +++ b/arch/x86/include/asm/compat.h
14862 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14863 typedef u32 compat_uint_t;
14864 typedef u32 compat_ulong_t;
14865 typedef u64 __attribute__((aligned(4))) compat_u64;
14866 -typedef u32 compat_uptr_t;
14867 +typedef u32 __user compat_uptr_t;
14868
14869 struct compat_timespec {
14870 compat_time_t tv_sec;
14871 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14872 index 47538a6..44902d1 100644
14873 --- a/arch/x86/include/asm/cpufeature.h
14874 +++ b/arch/x86/include/asm/cpufeature.h
14875 @@ -203,7 +203,7 @@
14876 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14877 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14878 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14879 -
14880 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14881
14882 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14883 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14884 @@ -211,7 +211,7 @@
14885 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14886 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14887 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14888 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14889 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14890 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14891 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14892 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14893 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14894 #undef cpu_has_centaur_mcr
14895 #define cpu_has_centaur_mcr 0
14896
14897 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14898 #endif /* CONFIG_X86_64 */
14899
14900 #if __GNUC__ >= 4
14901 @@ -403,7 +404,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14902
14903 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14904 t_warn:
14905 - warn_pre_alternatives();
14906 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14907 + warn_pre_alternatives();
14908 return false;
14909 #endif
14910 #else /* GCC_VERSION >= 40500 */
14911 @@ -421,7 +423,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14912 ".section .discard,\"aw\",@progbits\n"
14913 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14914 ".previous\n"
14915 - ".section .altinstr_replacement,\"ax\"\n"
14916 + ".section .altinstr_replacement,\"a\"\n"
14917 "3: movb $1,%0\n"
14918 "4:\n"
14919 ".previous\n"
14920 @@ -457,7 +459,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14921 " .byte 2b - 1b\n" /* src len */
14922 " .byte 4f - 3f\n" /* repl len */
14923 ".previous\n"
14924 - ".section .altinstr_replacement,\"ax\"\n"
14925 + ".section .altinstr_replacement,\"a\"\n"
14926 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14927 "4:\n"
14928 ".previous\n"
14929 @@ -490,7 +492,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14930 ".section .discard,\"aw\",@progbits\n"
14931 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14932 ".previous\n"
14933 - ".section .altinstr_replacement,\"ax\"\n"
14934 + ".section .altinstr_replacement,\"a\"\n"
14935 "3: movb $0,%0\n"
14936 "4:\n"
14937 ".previous\n"
14938 @@ -504,7 +506,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14939 ".section .discard,\"aw\",@progbits\n"
14940 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14941 ".previous\n"
14942 - ".section .altinstr_replacement,\"ax\"\n"
14943 + ".section .altinstr_replacement,\"a\"\n"
14944 "5: movb $1,%0\n"
14945 "6:\n"
14946 ".previous\n"
14947 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14948 index b90e5df..b462c91 100644
14949 --- a/arch/x86/include/asm/desc.h
14950 +++ b/arch/x86/include/asm/desc.h
14951 @@ -4,6 +4,7 @@
14952 #include <asm/desc_defs.h>
14953 #include <asm/ldt.h>
14954 #include <asm/mmu.h>
14955 +#include <asm/pgtable.h>
14956
14957 #include <linux/smp.h>
14958 #include <linux/percpu.h>
14959 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14960
14961 desc->type = (info->read_exec_only ^ 1) << 1;
14962 desc->type |= info->contents << 2;
14963 + desc->type |= info->seg_not_present ^ 1;
14964
14965 desc->s = 1;
14966 desc->dpl = 0x3;
14967 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14968 }
14969
14970 extern struct desc_ptr idt_descr;
14971 -extern gate_desc idt_table[];
14972 -extern struct desc_ptr debug_idt_descr;
14973 -extern gate_desc debug_idt_table[];
14974 -
14975 -struct gdt_page {
14976 - struct desc_struct gdt[GDT_ENTRIES];
14977 -} __attribute__((aligned(PAGE_SIZE)));
14978 -
14979 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
14980 +extern gate_desc idt_table[IDT_ENTRIES];
14981 +extern const struct desc_ptr debug_idt_descr;
14982 +extern gate_desc debug_idt_table[IDT_ENTRIES];
14983
14984 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
14985 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
14986 {
14987 - return per_cpu(gdt_page, cpu).gdt;
14988 + return cpu_gdt_table[cpu];
14989 }
14990
14991 #ifdef CONFIG_X86_64
14992 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
14993 unsigned long base, unsigned dpl, unsigned flags,
14994 unsigned short seg)
14995 {
14996 - gate->a = (seg << 16) | (base & 0xffff);
14997 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
14998 + gate->gate.offset_low = base;
14999 + gate->gate.seg = seg;
15000 + gate->gate.reserved = 0;
15001 + gate->gate.type = type;
15002 + gate->gate.s = 0;
15003 + gate->gate.dpl = dpl;
15004 + gate->gate.p = 1;
15005 + gate->gate.offset_high = base >> 16;
15006 }
15007
15008 #endif
15009 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15010
15011 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15012 {
15013 + pax_open_kernel();
15014 memcpy(&idt[entry], gate, sizeof(*gate));
15015 + pax_close_kernel();
15016 }
15017
15018 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15019 {
15020 + pax_open_kernel();
15021 memcpy(&ldt[entry], desc, 8);
15022 + pax_close_kernel();
15023 }
15024
15025 static inline void
15026 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15027 default: size = sizeof(*gdt); break;
15028 }
15029
15030 + pax_open_kernel();
15031 memcpy(&gdt[entry], desc, size);
15032 + pax_close_kernel();
15033 }
15034
15035 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15036 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15037
15038 static inline void native_load_tr_desc(void)
15039 {
15040 + pax_open_kernel();
15041 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15042 + pax_close_kernel();
15043 }
15044
15045 static inline void native_load_gdt(const struct desc_ptr *dtr)
15046 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15047 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15048 unsigned int i;
15049
15050 + pax_open_kernel();
15051 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15052 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15053 + pax_close_kernel();
15054 }
15055
15056 #define _LDT_empty(info) \
15057 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15058 preempt_enable();
15059 }
15060
15061 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15062 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15063 {
15064 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15065 }
15066 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15067 }
15068
15069 #ifdef CONFIG_X86_64
15070 -static inline void set_nmi_gate(int gate, void *addr)
15071 +static inline void set_nmi_gate(int gate, const void *addr)
15072 {
15073 gate_desc s;
15074
15075 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15076 #endif
15077
15078 #ifdef CONFIG_TRACING
15079 -extern struct desc_ptr trace_idt_descr;
15080 -extern gate_desc trace_idt_table[];
15081 +extern const struct desc_ptr trace_idt_descr;
15082 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15083 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15084 {
15085 write_idt_entry(trace_idt_table, entry, gate);
15086 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15087 }
15088 #endif
15089
15090 -static inline void _set_gate(int gate, unsigned type, void *addr,
15091 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15092 unsigned dpl, unsigned ist, unsigned seg)
15093 {
15094 gate_desc s;
15095 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15096 * Pentium F0 0F bugfix can have resulted in the mapped
15097 * IDT being write-protected.
15098 */
15099 -static inline void set_intr_gate(unsigned int n, void *addr)
15100 +static inline void set_intr_gate(unsigned int n, const void *addr)
15101 {
15102 BUG_ON((unsigned)n > 0xFF);
15103 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15104 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15105 /*
15106 * This routine sets up an interrupt gate at directory privilege level 3.
15107 */
15108 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15109 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15110 {
15111 BUG_ON((unsigned)n > 0xFF);
15112 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15113 }
15114
15115 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15116 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15117 {
15118 BUG_ON((unsigned)n > 0xFF);
15119 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15120 }
15121
15122 -static inline void set_trap_gate(unsigned int n, void *addr)
15123 +static inline void set_trap_gate(unsigned int n, const void *addr)
15124 {
15125 BUG_ON((unsigned)n > 0xFF);
15126 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15127 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15128 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15129 {
15130 BUG_ON((unsigned)n > 0xFF);
15131 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15132 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15133 }
15134
15135 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15136 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15137 {
15138 BUG_ON((unsigned)n > 0xFF);
15139 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15140 }
15141
15142 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15143 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15144 {
15145 BUG_ON((unsigned)n > 0xFF);
15146 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15147 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15148 else
15149 load_idt((const struct desc_ptr *)&idt_descr);
15150 }
15151 +
15152 +#ifdef CONFIG_X86_32
15153 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15154 +{
15155 + struct desc_struct d;
15156 +
15157 + if (likely(limit))
15158 + limit = (limit - 1UL) >> PAGE_SHIFT;
15159 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15160 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15161 +}
15162 +#endif
15163 +
15164 #endif /* _ASM_X86_DESC_H */
15165 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15166 index 278441f..b95a174 100644
15167 --- a/arch/x86/include/asm/desc_defs.h
15168 +++ b/arch/x86/include/asm/desc_defs.h
15169 @@ -31,6 +31,12 @@ struct desc_struct {
15170 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15171 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15172 };
15173 + struct {
15174 + u16 offset_low;
15175 + u16 seg;
15176 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15177 + unsigned offset_high: 16;
15178 + } gate;
15179 };
15180 } __attribute__((packed));
15181
15182 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15183 index ced283a..ffe04cc 100644
15184 --- a/arch/x86/include/asm/div64.h
15185 +++ b/arch/x86/include/asm/div64.h
15186 @@ -39,7 +39,7 @@
15187 __mod; \
15188 })
15189
15190 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15191 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15192 {
15193 union {
15194 u64 v64;
15195 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15196 index 9c999c1..3860cb8 100644
15197 --- a/arch/x86/include/asm/elf.h
15198 +++ b/arch/x86/include/asm/elf.h
15199 @@ -243,7 +243,25 @@ extern int force_personality32;
15200 the loader. We need to make sure that it is out of the way of the program
15201 that it will "exec", and that there is sufficient room for the brk. */
15202
15203 +#ifdef CONFIG_PAX_SEGMEXEC
15204 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15205 +#else
15206 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15207 +#endif
15208 +
15209 +#ifdef CONFIG_PAX_ASLR
15210 +#ifdef CONFIG_X86_32
15211 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15212 +
15213 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15214 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15215 +#else
15216 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15217 +
15218 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15219 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15220 +#endif
15221 +#endif
15222
15223 /* This yields a mask that user programs can use to figure out what
15224 instruction set this CPU supports. This could be done in user space,
15225 @@ -296,16 +314,12 @@ do { \
15226
15227 #define ARCH_DLINFO \
15228 do { \
15229 - if (vdso_enabled) \
15230 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15231 - (unsigned long)current->mm->context.vdso); \
15232 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15233 } while (0)
15234
15235 #define ARCH_DLINFO_X32 \
15236 do { \
15237 - if (vdso_enabled) \
15238 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15239 - (unsigned long)current->mm->context.vdso); \
15240 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15241 } while (0)
15242
15243 #define AT_SYSINFO 32
15244 @@ -320,7 +334,7 @@ else \
15245
15246 #endif /* !CONFIG_X86_32 */
15247
15248 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15249 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15250
15251 #define VDSO_ENTRY \
15252 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15253 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15254 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15255 #define compat_arch_setup_additional_pages syscall32_setup_pages
15256
15257 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15258 -#define arch_randomize_brk arch_randomize_brk
15259 -
15260 /*
15261 * True on X86_32 or when emulating IA32 on X86_64
15262 */
15263 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15264 index 77a99ac..39ff7f5 100644
15265 --- a/arch/x86/include/asm/emergency-restart.h
15266 +++ b/arch/x86/include/asm/emergency-restart.h
15267 @@ -1,6 +1,6 @@
15268 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15269 #define _ASM_X86_EMERGENCY_RESTART_H
15270
15271 -extern void machine_emergency_restart(void);
15272 +extern void machine_emergency_restart(void) __noreturn;
15273
15274 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15275 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15276 index 4d0bda7..221da4d 100644
15277 --- a/arch/x86/include/asm/fpu-internal.h
15278 +++ b/arch/x86/include/asm/fpu-internal.h
15279 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15280 #define user_insn(insn, output, input...) \
15281 ({ \
15282 int err; \
15283 + pax_open_userland(); \
15284 asm volatile(ASM_STAC "\n" \
15285 - "1:" #insn "\n\t" \
15286 + "1:" \
15287 + __copyuser_seg \
15288 + #insn "\n\t" \
15289 "2: " ASM_CLAC "\n" \
15290 ".section .fixup,\"ax\"\n" \
15291 "3: movl $-1,%[err]\n" \
15292 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15293 _ASM_EXTABLE(1b, 3b) \
15294 : [err] "=r" (err), output \
15295 : "0"(0), input); \
15296 + pax_close_userland(); \
15297 err; \
15298 })
15299
15300 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15301 "emms\n\t" /* clear stack tags */
15302 "fildl %P[addr]", /* set F?P to defined value */
15303 X86_FEATURE_FXSAVE_LEAK,
15304 - [addr] "m" (tsk->thread.fpu.has_fpu));
15305 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15306
15307 return fpu_restore_checking(&tsk->thread.fpu);
15308 }
15309 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15310 index be27ba1..04a8801 100644
15311 --- a/arch/x86/include/asm/futex.h
15312 +++ b/arch/x86/include/asm/futex.h
15313 @@ -12,6 +12,7 @@
15314 #include <asm/smap.h>
15315
15316 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15317 + typecheck(u32 __user *, uaddr); \
15318 asm volatile("\t" ASM_STAC "\n" \
15319 "1:\t" insn "\n" \
15320 "2:\t" ASM_CLAC "\n" \
15321 @@ -20,15 +21,16 @@
15322 "\tjmp\t2b\n" \
15323 "\t.previous\n" \
15324 _ASM_EXTABLE(1b, 3b) \
15325 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15326 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15327 : "i" (-EFAULT), "0" (oparg), "1" (0))
15328
15329 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15330 + typecheck(u32 __user *, uaddr); \
15331 asm volatile("\t" ASM_STAC "\n" \
15332 "1:\tmovl %2, %0\n" \
15333 "\tmovl\t%0, %3\n" \
15334 "\t" insn "\n" \
15335 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15336 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15337 "\tjnz\t1b\n" \
15338 "3:\t" ASM_CLAC "\n" \
15339 "\t.section .fixup,\"ax\"\n" \
15340 @@ -38,7 +40,7 @@
15341 _ASM_EXTABLE(1b, 4b) \
15342 _ASM_EXTABLE(2b, 4b) \
15343 : "=&a" (oldval), "=&r" (ret), \
15344 - "+m" (*uaddr), "=&r" (tem) \
15345 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15346 : "r" (oparg), "i" (-EFAULT), "1" (0))
15347
15348 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15349 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15350
15351 pagefault_disable();
15352
15353 + pax_open_userland();
15354 switch (op) {
15355 case FUTEX_OP_SET:
15356 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15357 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15358 break;
15359 case FUTEX_OP_ADD:
15360 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15361 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15362 uaddr, oparg);
15363 break;
15364 case FUTEX_OP_OR:
15365 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15366 default:
15367 ret = -ENOSYS;
15368 }
15369 + pax_close_userland();
15370
15371 pagefault_enable();
15372
15373 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15374 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15375 return -EFAULT;
15376
15377 + pax_open_userland();
15378 asm volatile("\t" ASM_STAC "\n"
15379 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15380 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15381 "2:\t" ASM_CLAC "\n"
15382 "\t.section .fixup, \"ax\"\n"
15383 "3:\tmov %3, %0\n"
15384 "\tjmp 2b\n"
15385 "\t.previous\n"
15386 _ASM_EXTABLE(1b, 3b)
15387 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15388 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15389 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15390 : "memory"
15391 );
15392 + pax_close_userland();
15393
15394 *uval = oldval;
15395 return ret;
15396 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15397 index e4ac559..c1c0c87 100644
15398 --- a/arch/x86/include/asm/hw_irq.h
15399 +++ b/arch/x86/include/asm/hw_irq.h
15400 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15401 extern void enable_IO_APIC(void);
15402
15403 /* Statistics */
15404 -extern atomic_t irq_err_count;
15405 -extern atomic_t irq_mis_count;
15406 +extern atomic_unchecked_t irq_err_count;
15407 +extern atomic_unchecked_t irq_mis_count;
15408
15409 /* EISA */
15410 extern void eisa_set_level_irq(unsigned int irq);
15411 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15412 index a203659..9889f1c 100644
15413 --- a/arch/x86/include/asm/i8259.h
15414 +++ b/arch/x86/include/asm/i8259.h
15415 @@ -62,7 +62,7 @@ struct legacy_pic {
15416 void (*init)(int auto_eoi);
15417 int (*irq_pending)(unsigned int irq);
15418 void (*make_irq)(unsigned int irq);
15419 -};
15420 +} __do_const;
15421
15422 extern struct legacy_pic *legacy_pic;
15423 extern struct legacy_pic null_legacy_pic;
15424 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15425 index 34f69cb..6d95446 100644
15426 --- a/arch/x86/include/asm/io.h
15427 +++ b/arch/x86/include/asm/io.h
15428 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15429 "m" (*(volatile type __force *)addr) barrier); }
15430
15431 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15432 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15433 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15434 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15435 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15436
15437 build_mmio_read(__readb, "b", unsigned char, "=q", )
15438 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15439 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15440 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15441 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15442
15443 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15444 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15445 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15446 return ioremap_nocache(offset, size);
15447 }
15448
15449 -extern void iounmap(volatile void __iomem *addr);
15450 +extern void iounmap(const volatile void __iomem *addr);
15451
15452 extern void set_iounmap_nonlazy(void);
15453
15454 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15455
15456 #include <linux/vmalloc.h>
15457
15458 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15459 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15460 +{
15461 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15462 +}
15463 +
15464 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15465 +{
15466 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15467 +}
15468 +
15469 /*
15470 * Convert a virtual cached pointer to an uncached pointer
15471 */
15472 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15473 index bba3cf8..06bc8da 100644
15474 --- a/arch/x86/include/asm/irqflags.h
15475 +++ b/arch/x86/include/asm/irqflags.h
15476 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15477 sti; \
15478 sysexit
15479
15480 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15481 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15482 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15483 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15484 +
15485 #else
15486 #define INTERRUPT_RETURN iret
15487 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15488 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15489 index 5a6d287..f815789 100644
15490 --- a/arch/x86/include/asm/kprobes.h
15491 +++ b/arch/x86/include/asm/kprobes.h
15492 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15493 #define RELATIVEJUMP_SIZE 5
15494 #define RELATIVECALL_OPCODE 0xe8
15495 #define RELATIVE_ADDR_SIZE 4
15496 -#define MAX_STACK_SIZE 64
15497 -#define MIN_STACK_SIZE(ADDR) \
15498 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15499 - THREAD_SIZE - (unsigned long)(ADDR))) \
15500 - ? (MAX_STACK_SIZE) \
15501 - : (((unsigned long)current_thread_info()) + \
15502 - THREAD_SIZE - (unsigned long)(ADDR)))
15503 +#define MAX_STACK_SIZE 64UL
15504 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15505
15506 #define flush_insn_slot(p) do { } while (0)
15507
15508 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15509 index 2d89e39..baee879 100644
15510 --- a/arch/x86/include/asm/local.h
15511 +++ b/arch/x86/include/asm/local.h
15512 @@ -10,33 +10,97 @@ typedef struct {
15513 atomic_long_t a;
15514 } local_t;
15515
15516 +typedef struct {
15517 + atomic_long_unchecked_t a;
15518 +} local_unchecked_t;
15519 +
15520 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15521
15522 #define local_read(l) atomic_long_read(&(l)->a)
15523 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15524 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15525 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15526
15527 static inline void local_inc(local_t *l)
15528 {
15529 - asm volatile(_ASM_INC "%0"
15530 + asm volatile(_ASM_INC "%0\n"
15531 +
15532 +#ifdef CONFIG_PAX_REFCOUNT
15533 + "jno 0f\n"
15534 + _ASM_DEC "%0\n"
15535 + "int $4\n0:\n"
15536 + _ASM_EXTABLE(0b, 0b)
15537 +#endif
15538 +
15539 + : "+m" (l->a.counter));
15540 +}
15541 +
15542 +static inline void local_inc_unchecked(local_unchecked_t *l)
15543 +{
15544 + asm volatile(_ASM_INC "%0\n"
15545 : "+m" (l->a.counter));
15546 }
15547
15548 static inline void local_dec(local_t *l)
15549 {
15550 - asm volatile(_ASM_DEC "%0"
15551 + asm volatile(_ASM_DEC "%0\n"
15552 +
15553 +#ifdef CONFIG_PAX_REFCOUNT
15554 + "jno 0f\n"
15555 + _ASM_INC "%0\n"
15556 + "int $4\n0:\n"
15557 + _ASM_EXTABLE(0b, 0b)
15558 +#endif
15559 +
15560 + : "+m" (l->a.counter));
15561 +}
15562 +
15563 +static inline void local_dec_unchecked(local_unchecked_t *l)
15564 +{
15565 + asm volatile(_ASM_DEC "%0\n"
15566 : "+m" (l->a.counter));
15567 }
15568
15569 static inline void local_add(long i, local_t *l)
15570 {
15571 - asm volatile(_ASM_ADD "%1,%0"
15572 + asm volatile(_ASM_ADD "%1,%0\n"
15573 +
15574 +#ifdef CONFIG_PAX_REFCOUNT
15575 + "jno 0f\n"
15576 + _ASM_SUB "%1,%0\n"
15577 + "int $4\n0:\n"
15578 + _ASM_EXTABLE(0b, 0b)
15579 +#endif
15580 +
15581 + : "+m" (l->a.counter)
15582 + : "ir" (i));
15583 +}
15584 +
15585 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15586 +{
15587 + asm volatile(_ASM_ADD "%1,%0\n"
15588 : "+m" (l->a.counter)
15589 : "ir" (i));
15590 }
15591
15592 static inline void local_sub(long i, local_t *l)
15593 {
15594 - asm volatile(_ASM_SUB "%1,%0"
15595 + asm volatile(_ASM_SUB "%1,%0\n"
15596 +
15597 +#ifdef CONFIG_PAX_REFCOUNT
15598 + "jno 0f\n"
15599 + _ASM_ADD "%1,%0\n"
15600 + "int $4\n0:\n"
15601 + _ASM_EXTABLE(0b, 0b)
15602 +#endif
15603 +
15604 + : "+m" (l->a.counter)
15605 + : "ir" (i));
15606 +}
15607 +
15608 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15609 +{
15610 + asm volatile(_ASM_SUB "%1,%0\n"
15611 : "+m" (l->a.counter)
15612 : "ir" (i));
15613 }
15614 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15615 {
15616 unsigned char c;
15617
15618 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15619 + asm volatile(_ASM_SUB "%2,%0\n"
15620 +
15621 +#ifdef CONFIG_PAX_REFCOUNT
15622 + "jno 0f\n"
15623 + _ASM_ADD "%2,%0\n"
15624 + "int $4\n0:\n"
15625 + _ASM_EXTABLE(0b, 0b)
15626 +#endif
15627 +
15628 + "sete %1\n"
15629 : "+m" (l->a.counter), "=qm" (c)
15630 : "ir" (i) : "memory");
15631 return c;
15632 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15633 {
15634 unsigned char c;
15635
15636 - asm volatile(_ASM_DEC "%0; sete %1"
15637 + asm volatile(_ASM_DEC "%0\n"
15638 +
15639 +#ifdef CONFIG_PAX_REFCOUNT
15640 + "jno 0f\n"
15641 + _ASM_INC "%0\n"
15642 + "int $4\n0:\n"
15643 + _ASM_EXTABLE(0b, 0b)
15644 +#endif
15645 +
15646 + "sete %1\n"
15647 : "+m" (l->a.counter), "=qm" (c)
15648 : : "memory");
15649 return c != 0;
15650 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15651 {
15652 unsigned char c;
15653
15654 - asm volatile(_ASM_INC "%0; sete %1"
15655 + asm volatile(_ASM_INC "%0\n"
15656 +
15657 +#ifdef CONFIG_PAX_REFCOUNT
15658 + "jno 0f\n"
15659 + _ASM_DEC "%0\n"
15660 + "int $4\n0:\n"
15661 + _ASM_EXTABLE(0b, 0b)
15662 +#endif
15663 +
15664 + "sete %1\n"
15665 : "+m" (l->a.counter), "=qm" (c)
15666 : : "memory");
15667 return c != 0;
15668 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15669 {
15670 unsigned char c;
15671
15672 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15673 + asm volatile(_ASM_ADD "%2,%0\n"
15674 +
15675 +#ifdef CONFIG_PAX_REFCOUNT
15676 + "jno 0f\n"
15677 + _ASM_SUB "%2,%0\n"
15678 + "int $4\n0:\n"
15679 + _ASM_EXTABLE(0b, 0b)
15680 +#endif
15681 +
15682 + "sets %1\n"
15683 : "+m" (l->a.counter), "=qm" (c)
15684 : "ir" (i) : "memory");
15685 return c;
15686 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15687 static inline long local_add_return(long i, local_t *l)
15688 {
15689 long __i = i;
15690 + asm volatile(_ASM_XADD "%0, %1\n"
15691 +
15692 +#ifdef CONFIG_PAX_REFCOUNT
15693 + "jno 0f\n"
15694 + _ASM_MOV "%0,%1\n"
15695 + "int $4\n0:\n"
15696 + _ASM_EXTABLE(0b, 0b)
15697 +#endif
15698 +
15699 + : "+r" (i), "+m" (l->a.counter)
15700 + : : "memory");
15701 + return i + __i;
15702 +}
15703 +
15704 +/**
15705 + * local_add_return_unchecked - add and return
15706 + * @i: integer value to add
15707 + * @l: pointer to type local_unchecked_t
15708 + *
15709 + * Atomically adds @i to @l and returns @i + @l
15710 + */
15711 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15712 +{
15713 + long __i = i;
15714 asm volatile(_ASM_XADD "%0, %1;"
15715 : "+r" (i), "+m" (l->a.counter)
15716 : : "memory");
15717 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15718
15719 #define local_cmpxchg(l, o, n) \
15720 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15721 +#define local_cmpxchg_unchecked(l, o, n) \
15722 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15723 /* Always has a lock prefix */
15724 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15725
15726 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15727 new file mode 100644
15728 index 0000000..2bfd3ba
15729 --- /dev/null
15730 +++ b/arch/x86/include/asm/mman.h
15731 @@ -0,0 +1,15 @@
15732 +#ifndef _X86_MMAN_H
15733 +#define _X86_MMAN_H
15734 +
15735 +#include <uapi/asm/mman.h>
15736 +
15737 +#ifdef __KERNEL__
15738 +#ifndef __ASSEMBLY__
15739 +#ifdef CONFIG_X86_32
15740 +#define arch_mmap_check i386_mmap_check
15741 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15742 +#endif
15743 +#endif
15744 +#endif
15745 +
15746 +#endif /* X86_MMAN_H */
15747 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15748 index 5f55e69..e20bfb1 100644
15749 --- a/arch/x86/include/asm/mmu.h
15750 +++ b/arch/x86/include/asm/mmu.h
15751 @@ -9,7 +9,7 @@
15752 * we put the segment information here.
15753 */
15754 typedef struct {
15755 - void *ldt;
15756 + struct desc_struct *ldt;
15757 int size;
15758
15759 #ifdef CONFIG_X86_64
15760 @@ -18,7 +18,19 @@ typedef struct {
15761 #endif
15762
15763 struct mutex lock;
15764 - void *vdso;
15765 + unsigned long vdso;
15766 +
15767 +#ifdef CONFIG_X86_32
15768 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15769 + unsigned long user_cs_base;
15770 + unsigned long user_cs_limit;
15771 +
15772 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15773 + cpumask_t cpu_user_cs_mask;
15774 +#endif
15775 +
15776 +#endif
15777 +#endif
15778 } mm_context_t;
15779
15780 #ifdef CONFIG_SMP
15781 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15782 index be12c53..2124e35 100644
15783 --- a/arch/x86/include/asm/mmu_context.h
15784 +++ b/arch/x86/include/asm/mmu_context.h
15785 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15786
15787 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15788 {
15789 +
15790 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15791 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15792 + unsigned int i;
15793 + pgd_t *pgd;
15794 +
15795 + pax_open_kernel();
15796 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15797 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15798 + set_pgd_batched(pgd+i, native_make_pgd(0));
15799 + pax_close_kernel();
15800 + }
15801 +#endif
15802 +
15803 #ifdef CONFIG_SMP
15804 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15805 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15806 @@ -34,16 +48,55 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15807 struct task_struct *tsk)
15808 {
15809 unsigned cpu = smp_processor_id();
15810 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15811 + int tlbstate = TLBSTATE_OK;
15812 +#endif
15813
15814 if (likely(prev != next)) {
15815 #ifdef CONFIG_SMP
15816 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15817 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15818 +#endif
15819 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15820 this_cpu_write(cpu_tlbstate.active_mm, next);
15821 #endif
15822 cpumask_set_cpu(cpu, mm_cpumask(next));
15823
15824 /* Re-load page tables */
15825 +#ifdef CONFIG_PAX_PER_CPU_PGD
15826 + pax_open_kernel();
15827 +
15828 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15829 + if (static_cpu_has(X86_FEATURE_PCID))
15830 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15831 + else
15832 +#endif
15833 +
15834 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15835 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15836 + pax_close_kernel();
15837 + 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));
15838 +
15839 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15840 + if (static_cpu_has(X86_FEATURE_PCID)) {
15841 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15842 + u64 descriptor[2];
15843 + descriptor[0] = PCID_USER;
15844 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15845 + } else {
15846 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15847 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15848 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15849 + else
15850 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15851 + }
15852 + } else
15853 +#endif
15854 +
15855 + load_cr3(get_cpu_pgd(cpu, kernel));
15856 +#else
15857 load_cr3(next->pgd);
15858 +#endif
15859
15860 /* Stop flush ipis for the previous mm */
15861 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15862 @@ -51,9 +104,63 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15863 /* Load the LDT, if the LDT is different: */
15864 if (unlikely(prev->context.ldt != next->context.ldt))
15865 load_LDT_nolock(&next->context);
15866 +
15867 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15868 + if (!(__supported_pte_mask & _PAGE_NX)) {
15869 + smp_mb__before_clear_bit();
15870 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15871 + smp_mb__after_clear_bit();
15872 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15873 + }
15874 +#endif
15875 +
15876 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15877 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15878 + prev->context.user_cs_limit != next->context.user_cs_limit))
15879 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15880 +#ifdef CONFIG_SMP
15881 + else if (unlikely(tlbstate != TLBSTATE_OK))
15882 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15883 +#endif
15884 +#endif
15885 +
15886 }
15887 + else {
15888 +
15889 +#ifdef CONFIG_PAX_PER_CPU_PGD
15890 + pax_open_kernel();
15891 +
15892 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15893 + if (static_cpu_has(X86_FEATURE_PCID))
15894 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15895 + else
15896 +#endif
15897 +
15898 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15899 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15900 + pax_close_kernel();
15901 + 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));
15902 +
15903 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15904 + if (static_cpu_has(X86_FEATURE_PCID)) {
15905 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15906 + u64 descriptor[2];
15907 + descriptor[0] = PCID_USER;
15908 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15909 + } else {
15910 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15911 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15912 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15913 + else
15914 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15915 + }
15916 + } else
15917 +#endif
15918 +
15919 + load_cr3(get_cpu_pgd(cpu, kernel));
15920 +#endif
15921 +
15922 #ifdef CONFIG_SMP
15923 - else {
15924 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15925 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15926
15927 @@ -70,11 +177,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15928 * tlb flush IPI delivery. We must reload CR3
15929 * to make sure to use no freed page tables.
15930 */
15931 +
15932 +#ifndef CONFIG_PAX_PER_CPU_PGD
15933 load_cr3(next->pgd);
15934 +#endif
15935 +
15936 load_LDT_nolock(&next->context);
15937 +
15938 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15939 + if (!(__supported_pte_mask & _PAGE_NX))
15940 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15941 +#endif
15942 +
15943 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15944 +#ifdef CONFIG_PAX_PAGEEXEC
15945 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15946 +#endif
15947 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15948 +#endif
15949 +
15950 }
15951 +#endif
15952 }
15953 -#endif
15954 }
15955
15956 #define activate_mm(prev, next) \
15957 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15958 index e3b7819..b257c64 100644
15959 --- a/arch/x86/include/asm/module.h
15960 +++ b/arch/x86/include/asm/module.h
15961 @@ -5,6 +5,7 @@
15962
15963 #ifdef CONFIG_X86_64
15964 /* X86_64 does not define MODULE_PROC_FAMILY */
15965 +#define MODULE_PROC_FAMILY ""
15966 #elif defined CONFIG_M486
15967 #define MODULE_PROC_FAMILY "486 "
15968 #elif defined CONFIG_M586
15969 @@ -57,8 +58,20 @@
15970 #error unknown processor family
15971 #endif
15972
15973 -#ifdef CONFIG_X86_32
15974 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
15975 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
15976 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
15977 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
15978 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
15979 +#else
15980 +#define MODULE_PAX_KERNEXEC ""
15981 #endif
15982
15983 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15984 +#define MODULE_PAX_UDEREF "UDEREF "
15985 +#else
15986 +#define MODULE_PAX_UDEREF ""
15987 +#endif
15988 +
15989 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
15990 +
15991 #endif /* _ASM_X86_MODULE_H */
15992 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
15993 index 86f9301..b365cda 100644
15994 --- a/arch/x86/include/asm/nmi.h
15995 +++ b/arch/x86/include/asm/nmi.h
15996 @@ -40,11 +40,11 @@ struct nmiaction {
15997 nmi_handler_t handler;
15998 unsigned long flags;
15999 const char *name;
16000 -};
16001 +} __do_const;
16002
16003 #define register_nmi_handler(t, fn, fg, n, init...) \
16004 ({ \
16005 - static struct nmiaction init fn##_na = { \
16006 + static const struct nmiaction init fn##_na = { \
16007 .handler = (fn), \
16008 .name = (n), \
16009 .flags = (fg), \
16010 @@ -52,7 +52,7 @@ struct nmiaction {
16011 __register_nmi_handler((t), &fn##_na); \
16012 })
16013
16014 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16015 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16016
16017 void unregister_nmi_handler(unsigned int, const char *);
16018
16019 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16020 index c878924..21f4889 100644
16021 --- a/arch/x86/include/asm/page.h
16022 +++ b/arch/x86/include/asm/page.h
16023 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16024 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16025
16026 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16027 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16028
16029 #define __boot_va(x) __va(x)
16030 #define __boot_pa(x) __pa(x)
16031 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16032 index 0f1ddee..e2fc3d1 100644
16033 --- a/arch/x86/include/asm/page_64.h
16034 +++ b/arch/x86/include/asm/page_64.h
16035 @@ -7,9 +7,9 @@
16036
16037 /* duplicated to the one in bootmem.h */
16038 extern unsigned long max_pfn;
16039 -extern unsigned long phys_base;
16040 +extern const unsigned long phys_base;
16041
16042 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16043 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16044 {
16045 unsigned long y = x - __START_KERNEL_map;
16046
16047 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16048 index cfdc9ee..3f7b5d6 100644
16049 --- a/arch/x86/include/asm/paravirt.h
16050 +++ b/arch/x86/include/asm/paravirt.h
16051 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16052 return (pmd_t) { ret };
16053 }
16054
16055 -static inline pmdval_t pmd_val(pmd_t pmd)
16056 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16057 {
16058 pmdval_t ret;
16059
16060 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16061 val);
16062 }
16063
16064 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16065 +{
16066 + pgdval_t val = native_pgd_val(pgd);
16067 +
16068 + if (sizeof(pgdval_t) > sizeof(long))
16069 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16070 + val, (u64)val >> 32);
16071 + else
16072 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16073 + val);
16074 +}
16075 +
16076 static inline void pgd_clear(pgd_t *pgdp)
16077 {
16078 set_pgd(pgdp, __pgd(0));
16079 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16080 pv_mmu_ops.set_fixmap(idx, phys, flags);
16081 }
16082
16083 +#ifdef CONFIG_PAX_KERNEXEC
16084 +static inline unsigned long pax_open_kernel(void)
16085 +{
16086 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16087 +}
16088 +
16089 +static inline unsigned long pax_close_kernel(void)
16090 +{
16091 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16092 +}
16093 +#else
16094 +static inline unsigned long pax_open_kernel(void) { return 0; }
16095 +static inline unsigned long pax_close_kernel(void) { return 0; }
16096 +#endif
16097 +
16098 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16099
16100 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
16101 @@ -926,7 +953,7 @@ extern void default_banner(void);
16102
16103 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16104 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16105 -#define PARA_INDIRECT(addr) *%cs:addr
16106 +#define PARA_INDIRECT(addr) *%ss:addr
16107 #endif
16108
16109 #define INTERRUPT_RETURN \
16110 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
16111 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16112 CLBR_NONE, \
16113 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16114 +
16115 +#define GET_CR0_INTO_RDI \
16116 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16117 + mov %rax,%rdi
16118 +
16119 +#define SET_RDI_INTO_CR0 \
16120 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16121 +
16122 +#define GET_CR3_INTO_RDI \
16123 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16124 + mov %rax,%rdi
16125 +
16126 +#define SET_RDI_INTO_CR3 \
16127 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16128 +
16129 #endif /* CONFIG_X86_32 */
16130
16131 #endif /* __ASSEMBLY__ */
16132 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16133 index 0db1fca..52310cc 100644
16134 --- a/arch/x86/include/asm/paravirt_types.h
16135 +++ b/arch/x86/include/asm/paravirt_types.h
16136 @@ -84,7 +84,7 @@ struct pv_init_ops {
16137 */
16138 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16139 unsigned long addr, unsigned len);
16140 -};
16141 +} __no_const;
16142
16143
16144 struct pv_lazy_ops {
16145 @@ -98,7 +98,7 @@ struct pv_time_ops {
16146 unsigned long long (*sched_clock)(void);
16147 unsigned long long (*steal_clock)(int cpu);
16148 unsigned long (*get_tsc_khz)(void);
16149 -};
16150 +} __no_const;
16151
16152 struct pv_cpu_ops {
16153 /* hooks for various privileged instructions */
16154 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16155
16156 void (*start_context_switch)(struct task_struct *prev);
16157 void (*end_context_switch)(struct task_struct *next);
16158 -};
16159 +} __no_const;
16160
16161 struct pv_irq_ops {
16162 /*
16163 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16164 unsigned long start_eip,
16165 unsigned long start_esp);
16166 #endif
16167 -};
16168 +} __no_const;
16169
16170 struct pv_mmu_ops {
16171 unsigned long (*read_cr2)(void);
16172 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16173 struct paravirt_callee_save make_pud;
16174
16175 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16176 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16177 #endif /* PAGETABLE_LEVELS == 4 */
16178 #endif /* PAGETABLE_LEVELS >= 3 */
16179
16180 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16181 an mfn. We can tell which is which from the index. */
16182 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16183 phys_addr_t phys, pgprot_t flags);
16184 +
16185 +#ifdef CONFIG_PAX_KERNEXEC
16186 + unsigned long (*pax_open_kernel)(void);
16187 + unsigned long (*pax_close_kernel)(void);
16188 +#endif
16189 +
16190 };
16191
16192 struct arch_spinlock;
16193 @@ -334,7 +341,7 @@ struct pv_lock_ops {
16194 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
16195 int (*spin_trylock)(struct arch_spinlock *lock);
16196 void (*spin_unlock)(struct arch_spinlock *lock);
16197 -};
16198 +} __no_const;
16199
16200 /* This contains all the paravirt structures: we get a convenient
16201 * number for each function using the offset which we use to indicate
16202 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16203 index b4389a4..7024269 100644
16204 --- a/arch/x86/include/asm/pgalloc.h
16205 +++ b/arch/x86/include/asm/pgalloc.h
16206 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16207 pmd_t *pmd, pte_t *pte)
16208 {
16209 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16210 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16211 +}
16212 +
16213 +static inline void pmd_populate_user(struct mm_struct *mm,
16214 + pmd_t *pmd, pte_t *pte)
16215 +{
16216 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16217 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16218 }
16219
16220 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16221
16222 #ifdef CONFIG_X86_PAE
16223 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16224 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16225 +{
16226 + pud_populate(mm, pudp, pmd);
16227 +}
16228 #else /* !CONFIG_X86_PAE */
16229 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16230 {
16231 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16232 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16233 }
16234 +
16235 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16236 +{
16237 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16238 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16239 +}
16240 #endif /* CONFIG_X86_PAE */
16241
16242 #if PAGETABLE_LEVELS > 3
16243 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16244 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16245 }
16246
16247 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16248 +{
16249 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16250 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16251 +}
16252 +
16253 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16254 {
16255 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16256 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16257 index 3bf2dd0..23d2a9f 100644
16258 --- a/arch/x86/include/asm/pgtable-2level.h
16259 +++ b/arch/x86/include/asm/pgtable-2level.h
16260 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16261
16262 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16263 {
16264 + pax_open_kernel();
16265 *pmdp = pmd;
16266 + pax_close_kernel();
16267 }
16268
16269 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16270 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16271 index 81bb91b..9392125 100644
16272 --- a/arch/x86/include/asm/pgtable-3level.h
16273 +++ b/arch/x86/include/asm/pgtable-3level.h
16274 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16275
16276 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16277 {
16278 + pax_open_kernel();
16279 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16280 + pax_close_kernel();
16281 }
16282
16283 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16284 {
16285 + pax_open_kernel();
16286 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16287 + pax_close_kernel();
16288 }
16289
16290 /*
16291 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16292 index 1c00631..845f898 100644
16293 --- a/arch/x86/include/asm/pgtable.h
16294 +++ b/arch/x86/include/asm/pgtable.h
16295 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16296
16297 #ifndef __PAGETABLE_PUD_FOLDED
16298 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16299 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16300 #define pgd_clear(pgd) native_pgd_clear(pgd)
16301 #endif
16302
16303 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16304
16305 #define arch_end_context_switch(prev) do {} while(0)
16306
16307 +#define pax_open_kernel() native_pax_open_kernel()
16308 +#define pax_close_kernel() native_pax_close_kernel()
16309 #endif /* CONFIG_PARAVIRT */
16310
16311 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16312 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16313 +
16314 +#ifdef CONFIG_PAX_KERNEXEC
16315 +static inline unsigned long native_pax_open_kernel(void)
16316 +{
16317 + unsigned long cr0;
16318 +
16319 + preempt_disable();
16320 + barrier();
16321 + cr0 = read_cr0() ^ X86_CR0_WP;
16322 + BUG_ON(cr0 & X86_CR0_WP);
16323 + write_cr0(cr0);
16324 + return cr0 ^ X86_CR0_WP;
16325 +}
16326 +
16327 +static inline unsigned long native_pax_close_kernel(void)
16328 +{
16329 + unsigned long cr0;
16330 +
16331 + cr0 = read_cr0() ^ X86_CR0_WP;
16332 + BUG_ON(!(cr0 & X86_CR0_WP));
16333 + write_cr0(cr0);
16334 + barrier();
16335 + preempt_enable_no_resched();
16336 + return cr0 ^ X86_CR0_WP;
16337 +}
16338 +#else
16339 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16340 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16341 +#endif
16342 +
16343 /*
16344 * The following only work if pte_present() is true.
16345 * Undefined behaviour if not..
16346 */
16347 +static inline int pte_user(pte_t pte)
16348 +{
16349 + return pte_val(pte) & _PAGE_USER;
16350 +}
16351 +
16352 static inline int pte_dirty(pte_t pte)
16353 {
16354 return pte_flags(pte) & _PAGE_DIRTY;
16355 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16356 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16357 }
16358
16359 +static inline unsigned long pgd_pfn(pgd_t pgd)
16360 +{
16361 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16362 +}
16363 +
16364 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16365
16366 static inline int pmd_large(pmd_t pte)
16367 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16368 return pte_clear_flags(pte, _PAGE_RW);
16369 }
16370
16371 +static inline pte_t pte_mkread(pte_t pte)
16372 +{
16373 + return __pte(pte_val(pte) | _PAGE_USER);
16374 +}
16375 +
16376 static inline pte_t pte_mkexec(pte_t pte)
16377 {
16378 - return pte_clear_flags(pte, _PAGE_NX);
16379 +#ifdef CONFIG_X86_PAE
16380 + if (__supported_pte_mask & _PAGE_NX)
16381 + return pte_clear_flags(pte, _PAGE_NX);
16382 + else
16383 +#endif
16384 + return pte_set_flags(pte, _PAGE_USER);
16385 +}
16386 +
16387 +static inline pte_t pte_exprotect(pte_t pte)
16388 +{
16389 +#ifdef CONFIG_X86_PAE
16390 + if (__supported_pte_mask & _PAGE_NX)
16391 + return pte_set_flags(pte, _PAGE_NX);
16392 + else
16393 +#endif
16394 + return pte_clear_flags(pte, _PAGE_USER);
16395 }
16396
16397 static inline pte_t pte_mkdirty(pte_t pte)
16398 @@ -444,6 +509,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16399 #endif
16400
16401 #ifndef __ASSEMBLY__
16402 +
16403 +#ifdef CONFIG_PAX_PER_CPU_PGD
16404 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16405 +enum cpu_pgd_type {kernel = 0, user = 1};
16406 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16407 +{
16408 + return cpu_pgd[cpu][type];
16409 +}
16410 +#endif
16411 +
16412 #include <linux/mm_types.h>
16413 #include <linux/log2.h>
16414
16415 @@ -576,7 +651,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16416 * Currently stuck as a macro due to indirect forward reference to
16417 * linux/mmzone.h's __section_mem_map_addr() definition:
16418 */
16419 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16420 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16421
16422 /* Find an entry in the second-level page table.. */
16423 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16424 @@ -616,7 +691,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16425 * Currently stuck as a macro due to indirect forward reference to
16426 * linux/mmzone.h's __section_mem_map_addr() definition:
16427 */
16428 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16429 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16430
16431 /* to find an entry in a page-table-directory. */
16432 static inline unsigned long pud_index(unsigned long address)
16433 @@ -631,7 +706,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16434
16435 static inline int pgd_bad(pgd_t pgd)
16436 {
16437 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16438 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16439 }
16440
16441 static inline int pgd_none(pgd_t pgd)
16442 @@ -654,7 +729,12 @@ static inline int pgd_none(pgd_t pgd)
16443 * pgd_offset() returns a (pgd_t *)
16444 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16445 */
16446 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16447 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16448 +
16449 +#ifdef CONFIG_PAX_PER_CPU_PGD
16450 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16451 +#endif
16452 +
16453 /*
16454 * a shortcut which implies the use of the kernel's pgd, instead
16455 * of a process's
16456 @@ -665,6 +745,23 @@ static inline int pgd_none(pgd_t pgd)
16457 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16458 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16459
16460 +#ifdef CONFIG_X86_32
16461 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16462 +#else
16463 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16464 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16465 +
16466 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16467 +#ifdef __ASSEMBLY__
16468 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16469 +#else
16470 +extern unsigned long pax_user_shadow_base;
16471 +extern pgdval_t clone_pgd_mask;
16472 +#endif
16473 +#endif
16474 +
16475 +#endif
16476 +
16477 #ifndef __ASSEMBLY__
16478
16479 extern int direct_gbpages;
16480 @@ -831,11 +928,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16481 * dst and src can be on the same page, but the range must not overlap,
16482 * and must not cross a page boundary.
16483 */
16484 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16485 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16486 {
16487 - memcpy(dst, src, count * sizeof(pgd_t));
16488 + pax_open_kernel();
16489 + while (count--)
16490 + *dst++ = *src++;
16491 + pax_close_kernel();
16492 }
16493
16494 +#ifdef CONFIG_PAX_PER_CPU_PGD
16495 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16496 +#endif
16497 +
16498 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16499 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16500 +#else
16501 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16502 +#endif
16503 +
16504 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16505 static inline int page_level_shift(enum pg_level level)
16506 {
16507 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16508 index 9ee3221..b979c6b 100644
16509 --- a/arch/x86/include/asm/pgtable_32.h
16510 +++ b/arch/x86/include/asm/pgtable_32.h
16511 @@ -25,9 +25,6 @@
16512 struct mm_struct;
16513 struct vm_area_struct;
16514
16515 -extern pgd_t swapper_pg_dir[1024];
16516 -extern pgd_t initial_page_table[1024];
16517 -
16518 static inline void pgtable_cache_init(void) { }
16519 static inline void check_pgt_cache(void) { }
16520 void paging_init(void);
16521 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16522 # include <asm/pgtable-2level.h>
16523 #endif
16524
16525 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16526 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16527 +#ifdef CONFIG_X86_PAE
16528 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16529 +#endif
16530 +
16531 #if defined(CONFIG_HIGHPTE)
16532 #define pte_offset_map(dir, address) \
16533 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16534 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16535 /* Clear a kernel PTE and flush it from the TLB */
16536 #define kpte_clear_flush(ptep, vaddr) \
16537 do { \
16538 + pax_open_kernel(); \
16539 pte_clear(&init_mm, (vaddr), (ptep)); \
16540 + pax_close_kernel(); \
16541 __flush_tlb_one((vaddr)); \
16542 } while (0)
16543
16544 #endif /* !__ASSEMBLY__ */
16545
16546 +#define HAVE_ARCH_UNMAPPED_AREA
16547 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16548 +
16549 /*
16550 * kern_addr_valid() is (1) for FLATMEM and (0) for
16551 * SPARSEMEM and DISCONTIGMEM
16552 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16553 index ed5903b..c7fe163 100644
16554 --- a/arch/x86/include/asm/pgtable_32_types.h
16555 +++ b/arch/x86/include/asm/pgtable_32_types.h
16556 @@ -8,7 +8,7 @@
16557 */
16558 #ifdef CONFIG_X86_PAE
16559 # include <asm/pgtable-3level_types.h>
16560 -# define PMD_SIZE (1UL << PMD_SHIFT)
16561 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16562 # define PMD_MASK (~(PMD_SIZE - 1))
16563 #else
16564 # include <asm/pgtable-2level_types.h>
16565 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16566 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16567 #endif
16568
16569 +#ifdef CONFIG_PAX_KERNEXEC
16570 +#ifndef __ASSEMBLY__
16571 +extern unsigned char MODULES_EXEC_VADDR[];
16572 +extern unsigned char MODULES_EXEC_END[];
16573 +#endif
16574 +#include <asm/boot.h>
16575 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16576 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16577 +#else
16578 +#define ktla_ktva(addr) (addr)
16579 +#define ktva_ktla(addr) (addr)
16580 +#endif
16581 +
16582 #define MODULES_VADDR VMALLOC_START
16583 #define MODULES_END VMALLOC_END
16584 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16585 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16586 index e22c1db..23a625a 100644
16587 --- a/arch/x86/include/asm/pgtable_64.h
16588 +++ b/arch/x86/include/asm/pgtable_64.h
16589 @@ -16,10 +16,14 @@
16590
16591 extern pud_t level3_kernel_pgt[512];
16592 extern pud_t level3_ident_pgt[512];
16593 +extern pud_t level3_vmalloc_start_pgt[512];
16594 +extern pud_t level3_vmalloc_end_pgt[512];
16595 +extern pud_t level3_vmemmap_pgt[512];
16596 +extern pud_t level2_vmemmap_pgt[512];
16597 extern pmd_t level2_kernel_pgt[512];
16598 extern pmd_t level2_fixmap_pgt[512];
16599 -extern pmd_t level2_ident_pgt[512];
16600 -extern pgd_t init_level4_pgt[];
16601 +extern pmd_t level2_ident_pgt[512*2];
16602 +extern pgd_t init_level4_pgt[512];
16603
16604 #define swapper_pg_dir init_level4_pgt
16605
16606 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16607
16608 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16609 {
16610 + pax_open_kernel();
16611 *pmdp = pmd;
16612 + pax_close_kernel();
16613 }
16614
16615 static inline void native_pmd_clear(pmd_t *pmd)
16616 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16617
16618 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16619 {
16620 + pax_open_kernel();
16621 *pudp = pud;
16622 + pax_close_kernel();
16623 }
16624
16625 static inline void native_pud_clear(pud_t *pud)
16626 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16627
16628 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16629 {
16630 + pax_open_kernel();
16631 + *pgdp = pgd;
16632 + pax_close_kernel();
16633 +}
16634 +
16635 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16636 +{
16637 *pgdp = pgd;
16638 }
16639
16640 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16641 index 2d88344..4679fc3 100644
16642 --- a/arch/x86/include/asm/pgtable_64_types.h
16643 +++ b/arch/x86/include/asm/pgtable_64_types.h
16644 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16645 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16646 #define MODULES_END _AC(0xffffffffff000000, UL)
16647 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16648 +#define MODULES_EXEC_VADDR MODULES_VADDR
16649 +#define MODULES_EXEC_END MODULES_END
16650 +
16651 +#define ktla_ktva(addr) (addr)
16652 +#define ktva_ktla(addr) (addr)
16653
16654 #define EARLY_DYNAMIC_PAGE_TABLES 64
16655
16656 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16657 index f4843e0..a2526f8 100644
16658 --- a/arch/x86/include/asm/pgtable_types.h
16659 +++ b/arch/x86/include/asm/pgtable_types.h
16660 @@ -16,13 +16,12 @@
16661 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16662 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16663 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16664 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16665 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16666 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16667 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16668 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16669 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16670 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16671 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16672 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16673 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16674 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16675
16676 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16677 @@ -40,7 +39,6 @@
16678 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16679 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16680 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16681 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16682 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16683 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16684 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16685 @@ -84,8 +82,10 @@
16686
16687 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16688 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16689 -#else
16690 +#elif defined(CONFIG_KMEMCHECK)
16691 #define _PAGE_NX (_AT(pteval_t, 0))
16692 +#else
16693 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16694 #endif
16695
16696 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16697 @@ -143,6 +143,9 @@
16698 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16699 _PAGE_ACCESSED)
16700
16701 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16702 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16703 +
16704 #define __PAGE_KERNEL_EXEC \
16705 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16706 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16707 @@ -153,7 +156,7 @@
16708 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16709 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16710 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16711 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16712 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16713 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16714 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16715 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16716 @@ -215,8 +218,8 @@
16717 * bits are combined, this will alow user to access the high address mapped
16718 * VDSO in the presence of CONFIG_COMPAT_VDSO
16719 */
16720 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16721 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16722 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16723 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16724 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16725 #endif
16726
16727 @@ -254,7 +257,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16728 {
16729 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16730 }
16731 +#endif
16732
16733 +#if PAGETABLE_LEVELS == 3
16734 +#include <asm-generic/pgtable-nopud.h>
16735 +#endif
16736 +
16737 +#if PAGETABLE_LEVELS == 2
16738 +#include <asm-generic/pgtable-nopmd.h>
16739 +#endif
16740 +
16741 +#ifndef __ASSEMBLY__
16742 #if PAGETABLE_LEVELS > 3
16743 typedef struct { pudval_t pud; } pud_t;
16744
16745 @@ -268,8 +281,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16746 return pud.pud;
16747 }
16748 #else
16749 -#include <asm-generic/pgtable-nopud.h>
16750 -
16751 static inline pudval_t native_pud_val(pud_t pud)
16752 {
16753 return native_pgd_val(pud.pgd);
16754 @@ -289,8 +300,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16755 return pmd.pmd;
16756 }
16757 #else
16758 -#include <asm-generic/pgtable-nopmd.h>
16759 -
16760 static inline pmdval_t native_pmd_val(pmd_t pmd)
16761 {
16762 return native_pgd_val(pmd.pud.pgd);
16763 @@ -330,7 +339,6 @@ typedef struct page *pgtable_t;
16764
16765 extern pteval_t __supported_pte_mask;
16766 extern void set_nx(void);
16767 -extern int nx_enabled;
16768
16769 #define pgprot_writecombine pgprot_writecombine
16770 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16771 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16772 index 24cf5ae..4d9fa2d 100644
16773 --- a/arch/x86/include/asm/processor.h
16774 +++ b/arch/x86/include/asm/processor.h
16775 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16776 : "memory");
16777 }
16778
16779 +/* invpcid (%rdx),%rax */
16780 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16781 +
16782 +#define INVPCID_SINGLE_ADDRESS 0UL
16783 +#define INVPCID_SINGLE_CONTEXT 1UL
16784 +#define INVPCID_ALL_GLOBAL 2UL
16785 +#define INVPCID_ALL_MONGLOBAL 3UL
16786 +
16787 +#define PCID_KERNEL 0UL
16788 +#define PCID_USER 1UL
16789 +#define PCID_NOFLUSH (1UL << 63)
16790 +
16791 static inline void load_cr3(pgd_t *pgdir)
16792 {
16793 - write_cr3(__pa(pgdir));
16794 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16795 }
16796
16797 #ifdef CONFIG_X86_32
16798 @@ -283,7 +295,7 @@ struct tss_struct {
16799
16800 } ____cacheline_aligned;
16801
16802 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16803 +extern struct tss_struct init_tss[NR_CPUS];
16804
16805 /*
16806 * Save the original ist values for checking stack pointers during debugging
16807 @@ -453,6 +465,7 @@ struct thread_struct {
16808 unsigned short ds;
16809 unsigned short fsindex;
16810 unsigned short gsindex;
16811 + unsigned short ss;
16812 #endif
16813 #ifdef CONFIG_X86_32
16814 unsigned long ip;
16815 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16816 extern unsigned long mmu_cr4_features;
16817 extern u32 *trampoline_cr4_features;
16818
16819 -static inline void set_in_cr4(unsigned long mask)
16820 -{
16821 - unsigned long cr4;
16822 -
16823 - mmu_cr4_features |= mask;
16824 - if (trampoline_cr4_features)
16825 - *trampoline_cr4_features = mmu_cr4_features;
16826 - cr4 = read_cr4();
16827 - cr4 |= mask;
16828 - write_cr4(cr4);
16829 -}
16830 -
16831 -static inline void clear_in_cr4(unsigned long mask)
16832 -{
16833 - unsigned long cr4;
16834 -
16835 - mmu_cr4_features &= ~mask;
16836 - if (trampoline_cr4_features)
16837 - *trampoline_cr4_features = mmu_cr4_features;
16838 - cr4 = read_cr4();
16839 - cr4 &= ~mask;
16840 - write_cr4(cr4);
16841 -}
16842 +extern void set_in_cr4(unsigned long mask);
16843 +extern void clear_in_cr4(unsigned long mask);
16844
16845 typedef struct {
16846 unsigned long seg;
16847 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16848 */
16849 #define TASK_SIZE PAGE_OFFSET
16850 #define TASK_SIZE_MAX TASK_SIZE
16851 +
16852 +#ifdef CONFIG_PAX_SEGMEXEC
16853 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16854 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16855 +#else
16856 #define STACK_TOP TASK_SIZE
16857 -#define STACK_TOP_MAX STACK_TOP
16858 +#endif
16859 +
16860 +#define STACK_TOP_MAX TASK_SIZE
16861
16862 #define INIT_THREAD { \
16863 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16864 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16865 .vm86_info = NULL, \
16866 .sysenter_cs = __KERNEL_CS, \
16867 .io_bitmap_ptr = NULL, \
16868 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16869 */
16870 #define INIT_TSS { \
16871 .x86_tss = { \
16872 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16873 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16874 .ss0 = __KERNEL_DS, \
16875 .ss1 = __KERNEL_CS, \
16876 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16877 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16878 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16879
16880 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16881 -#define KSTK_TOP(info) \
16882 -({ \
16883 - unsigned long *__ptr = (unsigned long *)(info); \
16884 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16885 -})
16886 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16887
16888 /*
16889 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16890 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16891 #define task_pt_regs(task) \
16892 ({ \
16893 struct pt_regs *__regs__; \
16894 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16895 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16896 __regs__ - 1; \
16897 })
16898
16899 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16900 /*
16901 * User space process size. 47bits minus one guard page.
16902 */
16903 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16904 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16905
16906 /* This decides where the kernel will search for a free chunk of vm
16907 * space during mmap's.
16908 */
16909 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16910 - 0xc0000000 : 0xFFFFe000)
16911 + 0xc0000000 : 0xFFFFf000)
16912
16913 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16914 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16915 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16916 #define STACK_TOP_MAX TASK_SIZE_MAX
16917
16918 #define INIT_THREAD { \
16919 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16920 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16921 }
16922
16923 #define INIT_TSS { \
16924 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16925 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16926 }
16927
16928 /*
16929 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16930 */
16931 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16932
16933 +#ifdef CONFIG_PAX_SEGMEXEC
16934 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16935 +#endif
16936 +
16937 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16938
16939 /* Get/set a process' ability to use the timestamp counter instruction */
16940 @@ -943,7 +942,8 @@ extern int set_tsc_mode(unsigned int val);
16941 extern u16 amd_get_nb_id(int cpu);
16942
16943 struct aperfmperf {
16944 - u64 aperf, mperf;
16945 + u64 aperf __intentional_overflow(0);
16946 + u64 mperf __intentional_overflow(0);
16947 };
16948
16949 static inline void get_aperfmperf(struct aperfmperf *am)
16950 @@ -971,7 +971,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
16951 return ratio;
16952 }
16953
16954 -extern unsigned long arch_align_stack(unsigned long sp);
16955 +#define arch_align_stack(x) ((x) & ~0xfUL)
16956 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16957
16958 void default_idle(void);
16959 @@ -981,6 +981,6 @@ bool xen_set_default_idle(void);
16960 #define xen_set_default_idle 0
16961 #endif
16962
16963 -void stop_this_cpu(void *dummy);
16964 +void stop_this_cpu(void *dummy) __noreturn;
16965 void df_debug(struct pt_regs *regs, long error_code);
16966 #endif /* _ASM_X86_PROCESSOR_H */
16967 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16968 index 942a086..6c26446 100644
16969 --- a/arch/x86/include/asm/ptrace.h
16970 +++ b/arch/x86/include/asm/ptrace.h
16971 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16972 }
16973
16974 /*
16975 - * user_mode_vm(regs) determines whether a register set came from user mode.
16976 + * user_mode(regs) determines whether a register set came from user mode.
16977 * This is true if V8086 mode was enabled OR if the register set was from
16978 * protected mode with RPL-3 CS value. This tricky test checks that with
16979 * one comparison. Many places in the kernel can bypass this full check
16980 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
16981 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
16982 + * be used.
16983 */
16984 -static inline int user_mode(struct pt_regs *regs)
16985 +static inline int user_mode_novm(struct pt_regs *regs)
16986 {
16987 #ifdef CONFIG_X86_32
16988 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
16989 #else
16990 - return !!(regs->cs & 3);
16991 + return !!(regs->cs & SEGMENT_RPL_MASK);
16992 #endif
16993 }
16994
16995 -static inline int user_mode_vm(struct pt_regs *regs)
16996 +static inline int user_mode(struct pt_regs *regs)
16997 {
16998 #ifdef CONFIG_X86_32
16999 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17000 USER_RPL;
17001 #else
17002 - return user_mode(regs);
17003 + return user_mode_novm(regs);
17004 #endif
17005 }
17006
17007 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17008 #ifdef CONFIG_X86_64
17009 static inline bool user_64bit_mode(struct pt_regs *regs)
17010 {
17011 + unsigned long cs = regs->cs & 0xffff;
17012 #ifndef CONFIG_PARAVIRT
17013 /*
17014 * On non-paravirt systems, this is the only long mode CPL 3
17015 * selector. We do not allow long mode selectors in the LDT.
17016 */
17017 - return regs->cs == __USER_CS;
17018 + return cs == __USER_CS;
17019 #else
17020 /* Headers are too twisted for this to go in paravirt.h. */
17021 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17022 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17023 #endif
17024 }
17025
17026 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17027 * Traps from the kernel do not save sp and ss.
17028 * Use the helper function to retrieve sp.
17029 */
17030 - if (offset == offsetof(struct pt_regs, sp) &&
17031 - regs->cs == __KERNEL_CS)
17032 - return kernel_stack_pointer(regs);
17033 + if (offset == offsetof(struct pt_regs, sp)) {
17034 + unsigned long cs = regs->cs & 0xffff;
17035 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17036 + return kernel_stack_pointer(regs);
17037 + }
17038 #endif
17039 return *(unsigned long *)((unsigned long)regs + offset);
17040 }
17041 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17042 index 9c6b890..5305f53 100644
17043 --- a/arch/x86/include/asm/realmode.h
17044 +++ b/arch/x86/include/asm/realmode.h
17045 @@ -22,16 +22,14 @@ struct real_mode_header {
17046 #endif
17047 /* APM/BIOS reboot */
17048 u32 machine_real_restart_asm;
17049 -#ifdef CONFIG_X86_64
17050 u32 machine_real_restart_seg;
17051 -#endif
17052 };
17053
17054 /* This must match data at trampoline_32/64.S */
17055 struct trampoline_header {
17056 #ifdef CONFIG_X86_32
17057 u32 start;
17058 - u16 gdt_pad;
17059 + u16 boot_cs;
17060 u16 gdt_limit;
17061 u32 gdt_base;
17062 #else
17063 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17064 index a82c4f1..ac45053 100644
17065 --- a/arch/x86/include/asm/reboot.h
17066 +++ b/arch/x86/include/asm/reboot.h
17067 @@ -6,13 +6,13 @@
17068 struct pt_regs;
17069
17070 struct machine_ops {
17071 - void (*restart)(char *cmd);
17072 - void (*halt)(void);
17073 - void (*power_off)(void);
17074 + void (* __noreturn restart)(char *cmd);
17075 + void (* __noreturn halt)(void);
17076 + void (* __noreturn power_off)(void);
17077 void (*shutdown)(void);
17078 void (*crash_shutdown)(struct pt_regs *);
17079 - void (*emergency_restart)(void);
17080 -};
17081 + void (* __noreturn emergency_restart)(void);
17082 +} __no_const;
17083
17084 extern struct machine_ops machine_ops;
17085
17086 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17087 index cad82c9..2e5c5c1 100644
17088 --- a/arch/x86/include/asm/rwsem.h
17089 +++ b/arch/x86/include/asm/rwsem.h
17090 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17091 {
17092 asm volatile("# beginning down_read\n\t"
17093 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17094 +
17095 +#ifdef CONFIG_PAX_REFCOUNT
17096 + "jno 0f\n"
17097 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17098 + "int $4\n0:\n"
17099 + _ASM_EXTABLE(0b, 0b)
17100 +#endif
17101 +
17102 /* adds 0x00000001 */
17103 " jns 1f\n"
17104 " call call_rwsem_down_read_failed\n"
17105 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17106 "1:\n\t"
17107 " mov %1,%2\n\t"
17108 " add %3,%2\n\t"
17109 +
17110 +#ifdef CONFIG_PAX_REFCOUNT
17111 + "jno 0f\n"
17112 + "sub %3,%2\n"
17113 + "int $4\n0:\n"
17114 + _ASM_EXTABLE(0b, 0b)
17115 +#endif
17116 +
17117 " jle 2f\n\t"
17118 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17119 " jnz 1b\n\t"
17120 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17121 long tmp;
17122 asm volatile("# beginning down_write\n\t"
17123 LOCK_PREFIX " xadd %1,(%2)\n\t"
17124 +
17125 +#ifdef CONFIG_PAX_REFCOUNT
17126 + "jno 0f\n"
17127 + "mov %1,(%2)\n"
17128 + "int $4\n0:\n"
17129 + _ASM_EXTABLE(0b, 0b)
17130 +#endif
17131 +
17132 /* adds 0xffff0001, returns the old value */
17133 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17134 /* was the active mask 0 before? */
17135 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17136 long tmp;
17137 asm volatile("# beginning __up_read\n\t"
17138 LOCK_PREFIX " xadd %1,(%2)\n\t"
17139 +
17140 +#ifdef CONFIG_PAX_REFCOUNT
17141 + "jno 0f\n"
17142 + "mov %1,(%2)\n"
17143 + "int $4\n0:\n"
17144 + _ASM_EXTABLE(0b, 0b)
17145 +#endif
17146 +
17147 /* subtracts 1, returns the old value */
17148 " jns 1f\n\t"
17149 " call call_rwsem_wake\n" /* expects old value in %edx */
17150 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17151 long tmp;
17152 asm volatile("# beginning __up_write\n\t"
17153 LOCK_PREFIX " xadd %1,(%2)\n\t"
17154 +
17155 +#ifdef CONFIG_PAX_REFCOUNT
17156 + "jno 0f\n"
17157 + "mov %1,(%2)\n"
17158 + "int $4\n0:\n"
17159 + _ASM_EXTABLE(0b, 0b)
17160 +#endif
17161 +
17162 /* subtracts 0xffff0001, returns the old value */
17163 " jns 1f\n\t"
17164 " call call_rwsem_wake\n" /* expects old value in %edx */
17165 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17166 {
17167 asm volatile("# beginning __downgrade_write\n\t"
17168 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17169 +
17170 +#ifdef CONFIG_PAX_REFCOUNT
17171 + "jno 0f\n"
17172 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17173 + "int $4\n0:\n"
17174 + _ASM_EXTABLE(0b, 0b)
17175 +#endif
17176 +
17177 /*
17178 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17179 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17180 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17181 */
17182 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17183 {
17184 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17185 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17186 +
17187 +#ifdef CONFIG_PAX_REFCOUNT
17188 + "jno 0f\n"
17189 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17190 + "int $4\n0:\n"
17191 + _ASM_EXTABLE(0b, 0b)
17192 +#endif
17193 +
17194 : "+m" (sem->count)
17195 : "er" (delta));
17196 }
17197 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17198 */
17199 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17200 {
17201 - return delta + xadd(&sem->count, delta);
17202 + return delta + xadd_check_overflow(&sem->count, delta);
17203 }
17204
17205 #endif /* __KERNEL__ */
17206 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17207 index c48a950..bc40804 100644
17208 --- a/arch/x86/include/asm/segment.h
17209 +++ b/arch/x86/include/asm/segment.h
17210 @@ -64,10 +64,15 @@
17211 * 26 - ESPFIX small SS
17212 * 27 - per-cpu [ offset to per-cpu data area ]
17213 * 28 - stack_canary-20 [ for stack protector ]
17214 - * 29 - unused
17215 - * 30 - unused
17216 + * 29 - PCI BIOS CS
17217 + * 30 - PCI BIOS DS
17218 * 31 - TSS for double fault handler
17219 */
17220 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17221 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17222 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17223 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17224 +
17225 #define GDT_ENTRY_TLS_MIN 6
17226 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17227
17228 @@ -79,6 +84,8 @@
17229
17230 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17231
17232 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17233 +
17234 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17235
17236 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17237 @@ -104,6 +111,12 @@
17238 #define __KERNEL_STACK_CANARY 0
17239 #endif
17240
17241 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17242 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17243 +
17244 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17245 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17246 +
17247 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17248
17249 /*
17250 @@ -141,7 +154,7 @@
17251 */
17252
17253 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17254 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17255 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17256
17257
17258 #else
17259 @@ -165,6 +178,8 @@
17260 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17261 #define __USER32_DS __USER_DS
17262
17263 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17264 +
17265 #define GDT_ENTRY_TSS 8 /* needs two entries */
17266 #define GDT_ENTRY_LDT 10 /* needs two entries */
17267 #define GDT_ENTRY_TLS_MIN 12
17268 @@ -173,6 +188,8 @@
17269 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17270 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17271
17272 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17273 +
17274 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17275 #define FS_TLS 0
17276 #define GS_TLS 1
17277 @@ -180,12 +197,14 @@
17278 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17279 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17280
17281 -#define GDT_ENTRIES 16
17282 +#define GDT_ENTRIES 17
17283
17284 #endif
17285
17286 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17287 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17288 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17289 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17290 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17291 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17292 #ifndef CONFIG_PARAVIRT
17293 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17294 {
17295 unsigned long __limit;
17296 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17297 - return __limit + 1;
17298 + return __limit;
17299 }
17300
17301 #endif /* !__ASSEMBLY__ */
17302 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17303 index 8d3120f..352b440 100644
17304 --- a/arch/x86/include/asm/smap.h
17305 +++ b/arch/x86/include/asm/smap.h
17306 @@ -25,11 +25,40 @@
17307
17308 #include <asm/alternative-asm.h>
17309
17310 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17311 +#define ASM_PAX_OPEN_USERLAND \
17312 + 661: jmp 663f; \
17313 + .pushsection .altinstr_replacement, "a" ; \
17314 + 662: pushq %rax; nop; \
17315 + .popsection ; \
17316 + .pushsection .altinstructions, "a" ; \
17317 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17318 + .popsection ; \
17319 + call __pax_open_userland; \
17320 + popq %rax; \
17321 + 663:
17322 +
17323 +#define ASM_PAX_CLOSE_USERLAND \
17324 + 661: jmp 663f; \
17325 + .pushsection .altinstr_replacement, "a" ; \
17326 + 662: pushq %rax; nop; \
17327 + .popsection; \
17328 + .pushsection .altinstructions, "a" ; \
17329 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17330 + .popsection; \
17331 + call __pax_close_userland; \
17332 + popq %rax; \
17333 + 663:
17334 +#else
17335 +#define ASM_PAX_OPEN_USERLAND
17336 +#define ASM_PAX_CLOSE_USERLAND
17337 +#endif
17338 +
17339 #ifdef CONFIG_X86_SMAP
17340
17341 #define ASM_CLAC \
17342 661: ASM_NOP3 ; \
17343 - .pushsection .altinstr_replacement, "ax" ; \
17344 + .pushsection .altinstr_replacement, "a" ; \
17345 662: __ASM_CLAC ; \
17346 .popsection ; \
17347 .pushsection .altinstructions, "a" ; \
17348 @@ -38,7 +67,7 @@
17349
17350 #define ASM_STAC \
17351 661: ASM_NOP3 ; \
17352 - .pushsection .altinstr_replacement, "ax" ; \
17353 + .pushsection .altinstr_replacement, "a" ; \
17354 662: __ASM_STAC ; \
17355 .popsection ; \
17356 .pushsection .altinstructions, "a" ; \
17357 @@ -56,6 +85,37 @@
17358
17359 #include <asm/alternative.h>
17360
17361 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17362 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17363 +
17364 +extern void __pax_open_userland(void);
17365 +static __always_inline unsigned long pax_open_userland(void)
17366 +{
17367 +
17368 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17369 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17370 + :
17371 + : [open] "i" (__pax_open_userland)
17372 + : "memory", "rax");
17373 +#endif
17374 +
17375 + return 0;
17376 +}
17377 +
17378 +extern void __pax_close_userland(void);
17379 +static __always_inline unsigned long pax_close_userland(void)
17380 +{
17381 +
17382 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17383 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17384 + :
17385 + : [close] "i" (__pax_close_userland)
17386 + : "memory", "rax");
17387 +#endif
17388 +
17389 + return 0;
17390 +}
17391 +
17392 #ifdef CONFIG_X86_SMAP
17393
17394 static __always_inline void clac(void)
17395 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17396 index 4137890..03fa172 100644
17397 --- a/arch/x86/include/asm/smp.h
17398 +++ b/arch/x86/include/asm/smp.h
17399 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17400 /* cpus sharing the last level cache: */
17401 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17402 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17403 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17404 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17405
17406 static inline struct cpumask *cpu_sibling_mask(int cpu)
17407 {
17408 @@ -79,7 +79,7 @@ struct smp_ops {
17409
17410 void (*send_call_func_ipi)(const struct cpumask *mask);
17411 void (*send_call_func_single_ipi)(int cpu);
17412 -};
17413 +} __no_const;
17414
17415 /* Globals due to paravirt */
17416 extern void set_cpu_sibling_map(int cpu);
17417 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17418 extern int safe_smp_processor_id(void);
17419
17420 #elif defined(CONFIG_X86_64_SMP)
17421 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17422 -
17423 -#define stack_smp_processor_id() \
17424 -({ \
17425 - struct thread_info *ti; \
17426 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17427 - ti->cpu; \
17428 -})
17429 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17430 +#define stack_smp_processor_id() raw_smp_processor_id()
17431 #define safe_smp_processor_id() smp_processor_id()
17432
17433 #endif
17434 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17435 index e3ddd7d..3611fce 100644
17436 --- a/arch/x86/include/asm/spinlock.h
17437 +++ b/arch/x86/include/asm/spinlock.h
17438 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17439 static inline void arch_read_lock(arch_rwlock_t *rw)
17440 {
17441 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17442 +
17443 +#ifdef CONFIG_PAX_REFCOUNT
17444 + "jno 0f\n"
17445 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17446 + "int $4\n0:\n"
17447 + _ASM_EXTABLE(0b, 0b)
17448 +#endif
17449 +
17450 "jns 1f\n"
17451 "call __read_lock_failed\n\t"
17452 "1:\n"
17453 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17454 static inline void arch_write_lock(arch_rwlock_t *rw)
17455 {
17456 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17457 +
17458 +#ifdef CONFIG_PAX_REFCOUNT
17459 + "jno 0f\n"
17460 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17461 + "int $4\n0:\n"
17462 + _ASM_EXTABLE(0b, 0b)
17463 +#endif
17464 +
17465 "jz 1f\n"
17466 "call __write_lock_failed\n\t"
17467 "1:\n"
17468 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17469
17470 static inline void arch_read_unlock(arch_rwlock_t *rw)
17471 {
17472 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17473 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17474 +
17475 +#ifdef CONFIG_PAX_REFCOUNT
17476 + "jno 0f\n"
17477 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17478 + "int $4\n0:\n"
17479 + _ASM_EXTABLE(0b, 0b)
17480 +#endif
17481 +
17482 :"+m" (rw->lock) : : "memory");
17483 }
17484
17485 static inline void arch_write_unlock(arch_rwlock_t *rw)
17486 {
17487 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17488 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17489 +
17490 +#ifdef CONFIG_PAX_REFCOUNT
17491 + "jno 0f\n"
17492 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17493 + "int $4\n0:\n"
17494 + _ASM_EXTABLE(0b, 0b)
17495 +#endif
17496 +
17497 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17498 }
17499
17500 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17501 index 6a99859..03cb807 100644
17502 --- a/arch/x86/include/asm/stackprotector.h
17503 +++ b/arch/x86/include/asm/stackprotector.h
17504 @@ -47,7 +47,7 @@
17505 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17506 */
17507 #define GDT_STACK_CANARY_INIT \
17508 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17509 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17510
17511 /*
17512 * Initialize the stackprotector canary value.
17513 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17514
17515 static inline void load_stack_canary_segment(void)
17516 {
17517 -#ifdef CONFIG_X86_32
17518 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17519 asm volatile ("mov %0, %%gs" : : "r" (0));
17520 #endif
17521 }
17522 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17523 index 70bbe39..4ae2bd4 100644
17524 --- a/arch/x86/include/asm/stacktrace.h
17525 +++ b/arch/x86/include/asm/stacktrace.h
17526 @@ -11,28 +11,20 @@
17527
17528 extern int kstack_depth_to_print;
17529
17530 -struct thread_info;
17531 +struct task_struct;
17532 struct stacktrace_ops;
17533
17534 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17535 - unsigned long *stack,
17536 - unsigned long bp,
17537 - const struct stacktrace_ops *ops,
17538 - void *data,
17539 - unsigned long *end,
17540 - int *graph);
17541 +typedef unsigned long walk_stack_t(struct task_struct *task,
17542 + void *stack_start,
17543 + unsigned long *stack,
17544 + unsigned long bp,
17545 + const struct stacktrace_ops *ops,
17546 + void *data,
17547 + unsigned long *end,
17548 + int *graph);
17549
17550 -extern unsigned long
17551 -print_context_stack(struct thread_info *tinfo,
17552 - unsigned long *stack, unsigned long bp,
17553 - const struct stacktrace_ops *ops, void *data,
17554 - unsigned long *end, int *graph);
17555 -
17556 -extern unsigned long
17557 -print_context_stack_bp(struct thread_info *tinfo,
17558 - unsigned long *stack, unsigned long bp,
17559 - const struct stacktrace_ops *ops, void *data,
17560 - unsigned long *end, int *graph);
17561 +extern walk_stack_t print_context_stack;
17562 +extern walk_stack_t print_context_stack_bp;
17563
17564 /* Generic stack tracer with callbacks */
17565
17566 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17567 void (*address)(void *data, unsigned long address, int reliable);
17568 /* On negative return stop dumping */
17569 int (*stack)(void *data, char *name);
17570 - walk_stack_t walk_stack;
17571 + walk_stack_t *walk_stack;
17572 };
17573
17574 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17575 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17576 index 4ec45b3..a4f0a8a 100644
17577 --- a/arch/x86/include/asm/switch_to.h
17578 +++ b/arch/x86/include/asm/switch_to.h
17579 @@ -108,7 +108,7 @@ do { \
17580 "call __switch_to\n\t" \
17581 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17582 __switch_canary \
17583 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17584 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17585 "movq %%rax,%%rdi\n\t" \
17586 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17587 "jnz ret_from_fork\n\t" \
17588 @@ -119,7 +119,7 @@ do { \
17589 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17590 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17591 [_tif_fork] "i" (_TIF_FORK), \
17592 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17593 + [thread_info] "m" (current_tinfo), \
17594 [current_task] "m" (current_task) \
17595 __switch_canary_iparam \
17596 : "memory", "cc" __EXTRA_CLOBBER)
17597 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17598 index 2781119..618b59b 100644
17599 --- a/arch/x86/include/asm/thread_info.h
17600 +++ b/arch/x86/include/asm/thread_info.h
17601 @@ -10,6 +10,7 @@
17602 #include <linux/compiler.h>
17603 #include <asm/page.h>
17604 #include <asm/types.h>
17605 +#include <asm/percpu.h>
17606
17607 /*
17608 * low level task data that entry.S needs immediate access to
17609 @@ -23,7 +24,6 @@ struct exec_domain;
17610 #include <linux/atomic.h>
17611
17612 struct thread_info {
17613 - struct task_struct *task; /* main task structure */
17614 struct exec_domain *exec_domain; /* execution domain */
17615 __u32 flags; /* low level flags */
17616 __u32 status; /* thread synchronous flags */
17617 @@ -33,19 +33,13 @@ struct thread_info {
17618 mm_segment_t addr_limit;
17619 struct restart_block restart_block;
17620 void __user *sysenter_return;
17621 -#ifdef CONFIG_X86_32
17622 - unsigned long previous_esp; /* ESP of the previous stack in
17623 - case of nested (IRQ) stacks
17624 - */
17625 - __u8 supervisor_stack[0];
17626 -#endif
17627 + unsigned long lowest_stack;
17628 unsigned int sig_on_uaccess_error:1;
17629 unsigned int uaccess_err:1; /* uaccess failed */
17630 };
17631
17632 -#define INIT_THREAD_INFO(tsk) \
17633 +#define INIT_THREAD_INFO \
17634 { \
17635 - .task = &tsk, \
17636 .exec_domain = &default_exec_domain, \
17637 .flags = 0, \
17638 .cpu = 0, \
17639 @@ -56,7 +50,7 @@ struct thread_info {
17640 }, \
17641 }
17642
17643 -#define init_thread_info (init_thread_union.thread_info)
17644 +#define init_thread_info (init_thread_union.stack)
17645 #define init_stack (init_thread_union.stack)
17646
17647 #else /* !__ASSEMBLY__ */
17648 @@ -96,6 +90,7 @@ struct thread_info {
17649 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17650 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17651 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17652 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17653
17654 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17655 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17656 @@ -119,17 +114,18 @@ struct thread_info {
17657 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17658 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17659 #define _TIF_X32 (1 << TIF_X32)
17660 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17661
17662 /* work to do in syscall_trace_enter() */
17663 #define _TIF_WORK_SYSCALL_ENTRY \
17664 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17665 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17666 - _TIF_NOHZ)
17667 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17668
17669 /* work to do in syscall_trace_leave() */
17670 #define _TIF_WORK_SYSCALL_EXIT \
17671 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17672 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17673 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17674
17675 /* work to do on interrupt/exception return */
17676 #define _TIF_WORK_MASK \
17677 @@ -140,7 +136,7 @@ struct thread_info {
17678 /* work to do on any return to user space */
17679 #define _TIF_ALLWORK_MASK \
17680 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17681 - _TIF_NOHZ)
17682 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17683
17684 /* Only used for 64 bit */
17685 #define _TIF_DO_NOTIFY_MASK \
17686 @@ -156,45 +152,40 @@ struct thread_info {
17687
17688 #define PREEMPT_ACTIVE 0x10000000
17689
17690 -#ifdef CONFIG_X86_32
17691 -
17692 -#define STACK_WARN (THREAD_SIZE/8)
17693 -/*
17694 - * macros/functions for gaining access to the thread information structure
17695 - *
17696 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17697 - */
17698 -#ifndef __ASSEMBLY__
17699 -
17700 -
17701 -/* how to get the current stack pointer from C */
17702 -register unsigned long current_stack_pointer asm("esp") __used;
17703 -
17704 -/* how to get the thread information struct from C */
17705 -static inline struct thread_info *current_thread_info(void)
17706 -{
17707 - return (struct thread_info *)
17708 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17709 -}
17710 -
17711 -#else /* !__ASSEMBLY__ */
17712 -
17713 +#ifdef __ASSEMBLY__
17714 /* how to get the thread information struct from ASM */
17715 #define GET_THREAD_INFO(reg) \
17716 - movl $-THREAD_SIZE, reg; \
17717 - andl %esp, reg
17718 + mov PER_CPU_VAR(current_tinfo), reg
17719
17720 /* use this one if reg already contains %esp */
17721 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17722 - andl $-THREAD_SIZE, reg
17723 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17724 +#else
17725 +/* how to get the thread information struct from C */
17726 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17727 +
17728 +static __always_inline struct thread_info *current_thread_info(void)
17729 +{
17730 + return this_cpu_read_stable(current_tinfo);
17731 +}
17732 +#endif
17733 +
17734 +#ifdef CONFIG_X86_32
17735 +
17736 +#define STACK_WARN (THREAD_SIZE/8)
17737 +/*
17738 + * macros/functions for gaining access to the thread information structure
17739 + *
17740 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17741 + */
17742 +#ifndef __ASSEMBLY__
17743 +
17744 +/* how to get the current stack pointer from C */
17745 +register unsigned long current_stack_pointer asm("esp") __used;
17746
17747 #endif
17748
17749 #else /* X86_32 */
17750
17751 -#include <asm/percpu.h>
17752 -#define KERNEL_STACK_OFFSET (5*8)
17753 -
17754 /*
17755 * macros/functions for gaining access to the thread information structure
17756 * preempt_count needs to be 1 initially, until the scheduler is functional.
17757 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17758 #ifndef __ASSEMBLY__
17759 DECLARE_PER_CPU(unsigned long, kernel_stack);
17760
17761 -static inline struct thread_info *current_thread_info(void)
17762 -{
17763 - struct thread_info *ti;
17764 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17765 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17766 - return ti;
17767 -}
17768 -
17769 -#else /* !__ASSEMBLY__ */
17770 -
17771 -/* how to get the thread information struct from ASM */
17772 -#define GET_THREAD_INFO(reg) \
17773 - movq PER_CPU_VAR(kernel_stack),reg ; \
17774 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17775 -
17776 -/*
17777 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17778 - * a certain register (to be used in assembler memory operands).
17779 - */
17780 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17781 -
17782 +/* how to get the current stack pointer from C */
17783 +register unsigned long current_stack_pointer asm("rsp") __used;
17784 #endif
17785
17786 #endif /* !X86_32 */
17787 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17788 extern void arch_task_cache_init(void);
17789 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17790 extern void arch_release_task_struct(struct task_struct *tsk);
17791 +
17792 +#define __HAVE_THREAD_FUNCTIONS
17793 +#define task_thread_info(task) (&(task)->tinfo)
17794 +#define task_stack_page(task) ((task)->stack)
17795 +#define setup_thread_stack(p, org) do {} while (0)
17796 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17797 +
17798 #endif
17799 #endif /* _ASM_X86_THREAD_INFO_H */
17800 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17801 index cf51200..63ff068 100644
17802 --- a/arch/x86/include/asm/tlbflush.h
17803 +++ b/arch/x86/include/asm/tlbflush.h
17804 @@ -17,18 +17,44 @@
17805
17806 static inline void __native_flush_tlb(void)
17807 {
17808 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17809 + u64 descriptor[2];
17810 +
17811 + descriptor[0] = PCID_KERNEL;
17812 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17813 + return;
17814 + }
17815 +
17816 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17817 + if (static_cpu_has(X86_FEATURE_PCID)) {
17818 + unsigned int cpu = raw_get_cpu();
17819 +
17820 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17821 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17822 + raw_put_cpu_no_resched();
17823 + return;
17824 + }
17825 +#endif
17826 +
17827 native_write_cr3(native_read_cr3());
17828 }
17829
17830 static inline void __native_flush_tlb_global_irq_disabled(void)
17831 {
17832 - unsigned long cr4;
17833 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17834 + u64 descriptor[2];
17835
17836 - cr4 = native_read_cr4();
17837 - /* clear PGE */
17838 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17839 - /* write old PGE again and flush TLBs */
17840 - native_write_cr4(cr4);
17841 + descriptor[0] = PCID_KERNEL;
17842 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17843 + } else {
17844 + unsigned long cr4;
17845 +
17846 + cr4 = native_read_cr4();
17847 + /* clear PGE */
17848 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17849 + /* write old PGE again and flush TLBs */
17850 + native_write_cr4(cr4);
17851 + }
17852 }
17853
17854 static inline void __native_flush_tlb_global(void)
17855 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17856
17857 static inline void __native_flush_tlb_single(unsigned long addr)
17858 {
17859 +
17860 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17861 + u64 descriptor[2];
17862 +
17863 + descriptor[0] = PCID_KERNEL;
17864 + descriptor[1] = addr;
17865 +
17866 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17867 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17868 + if (addr < TASK_SIZE_MAX)
17869 + descriptor[1] += pax_user_shadow_base;
17870 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17871 + }
17872 +
17873 + descriptor[0] = PCID_USER;
17874 + descriptor[1] = addr;
17875 +#endif
17876 +
17877 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17878 + return;
17879 + }
17880 +
17881 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17882 + if (static_cpu_has(X86_FEATURE_PCID)) {
17883 + unsigned int cpu = raw_get_cpu();
17884 +
17885 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17886 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17887 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17888 + raw_put_cpu_no_resched();
17889 +
17890 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17891 + addr += pax_user_shadow_base;
17892 + }
17893 +#endif
17894 +
17895 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17896 }
17897
17898 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17899 index 5ee2687..74590b9 100644
17900 --- a/arch/x86/include/asm/uaccess.h
17901 +++ b/arch/x86/include/asm/uaccess.h
17902 @@ -7,6 +7,7 @@
17903 #include <linux/compiler.h>
17904 #include <linux/thread_info.h>
17905 #include <linux/string.h>
17906 +#include <linux/sched.h>
17907 #include <asm/asm.h>
17908 #include <asm/page.h>
17909 #include <asm/smap.h>
17910 @@ -29,7 +30,12 @@
17911
17912 #define get_ds() (KERNEL_DS)
17913 #define get_fs() (current_thread_info()->addr_limit)
17914 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17915 +void __set_fs(mm_segment_t x);
17916 +void set_fs(mm_segment_t x);
17917 +#else
17918 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17919 +#endif
17920
17921 #define segment_eq(a, b) ((a).seg == (b).seg)
17922
17923 @@ -77,8 +83,33 @@
17924 * checks that the pointer is in the user space range - after calling
17925 * this function, memory access functions may still return -EFAULT.
17926 */
17927 -#define access_ok(type, addr, size) \
17928 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17929 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17930 +#define access_ok(type, addr, size) \
17931 +({ \
17932 + long __size = size; \
17933 + unsigned long __addr = (unsigned long)addr; \
17934 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17935 + unsigned long __end_ao = __addr + __size - 1; \
17936 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17937 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17938 + while(__addr_ao <= __end_ao) { \
17939 + char __c_ao; \
17940 + __addr_ao += PAGE_SIZE; \
17941 + if (__size > PAGE_SIZE) \
17942 + cond_resched(); \
17943 + if (__get_user(__c_ao, (char __user *)__addr)) \
17944 + break; \
17945 + if (type != VERIFY_WRITE) { \
17946 + __addr = __addr_ao; \
17947 + continue; \
17948 + } \
17949 + if (__put_user(__c_ao, (char __user *)__addr)) \
17950 + break; \
17951 + __addr = __addr_ao; \
17952 + } \
17953 + } \
17954 + __ret_ao; \
17955 +})
17956
17957 /*
17958 * The exception table consists of pairs of addresses relative to the
17959 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17960 register __inttype(*(ptr)) __val_gu asm("%edx"); \
17961 __chk_user_ptr(ptr); \
17962 might_fault(); \
17963 + pax_open_userland(); \
17964 asm volatile("call __get_user_%P3" \
17965 : "=a" (__ret_gu), "=r" (__val_gu) \
17966 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17967 (x) = (__typeof__(*(ptr))) __val_gu; \
17968 + pax_close_userland(); \
17969 __ret_gu; \
17970 })
17971
17972 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17973 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17974 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17975
17976 -
17977 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17978 +#define __copyuser_seg "gs;"
17979 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17980 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
17981 +#else
17982 +#define __copyuser_seg
17983 +#define __COPYUSER_SET_ES
17984 +#define __COPYUSER_RESTORE_ES
17985 +#endif
17986
17987 #ifdef CONFIG_X86_32
17988 #define __put_user_asm_u64(x, addr, err, errret) \
17989 asm volatile(ASM_STAC "\n" \
17990 - "1: movl %%eax,0(%2)\n" \
17991 - "2: movl %%edx,4(%2)\n" \
17992 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
17993 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
17994 "3: " ASM_CLAC "\n" \
17995 ".section .fixup,\"ax\"\n" \
17996 "4: movl %3,%0\n" \
17997 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17998
17999 #define __put_user_asm_ex_u64(x, addr) \
18000 asm volatile(ASM_STAC "\n" \
18001 - "1: movl %%eax,0(%1)\n" \
18002 - "2: movl %%edx,4(%1)\n" \
18003 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18004 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18005 "3: " ASM_CLAC "\n" \
18006 _ASM_EXTABLE_EX(1b, 2b) \
18007 _ASM_EXTABLE_EX(2b, 3b) \
18008 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
18009 __typeof__(*(ptr)) __pu_val; \
18010 __chk_user_ptr(ptr); \
18011 might_fault(); \
18012 - __pu_val = x; \
18013 + __pu_val = (x); \
18014 + pax_open_userland(); \
18015 switch (sizeof(*(ptr))) { \
18016 case 1: \
18017 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18018 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
18019 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18020 break; \
18021 } \
18022 + pax_close_userland(); \
18023 __ret_pu; \
18024 })
18025
18026 @@ -344,8 +387,10 @@ do { \
18027 } while (0)
18028
18029 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18030 +do { \
18031 + pax_open_userland(); \
18032 asm volatile(ASM_STAC "\n" \
18033 - "1: mov"itype" %2,%"rtype"1\n" \
18034 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18035 "2: " ASM_CLAC "\n" \
18036 ".section .fixup,\"ax\"\n" \
18037 "3: mov %3,%0\n" \
18038 @@ -353,8 +398,10 @@ do { \
18039 " jmp 2b\n" \
18040 ".previous\n" \
18041 _ASM_EXTABLE(1b, 3b) \
18042 - : "=r" (err), ltype(x) \
18043 - : "m" (__m(addr)), "i" (errret), "0" (err))
18044 + : "=r" (err), ltype (x) \
18045 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18046 + pax_close_userland(); \
18047 +} while (0)
18048
18049 #define __get_user_size_ex(x, ptr, size) \
18050 do { \
18051 @@ -378,7 +425,7 @@ do { \
18052 } while (0)
18053
18054 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18055 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18056 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18057 "2:\n" \
18058 _ASM_EXTABLE_EX(1b, 2b) \
18059 : ltype(x) : "m" (__m(addr)))
18060 @@ -395,13 +442,24 @@ do { \
18061 int __gu_err; \
18062 unsigned long __gu_val; \
18063 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18064 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18065 + (x) = (__typeof__(*(ptr)))__gu_val; \
18066 __gu_err; \
18067 })
18068
18069 /* FIXME: this hack is definitely wrong -AK */
18070 struct __large_struct { unsigned long buf[100]; };
18071 -#define __m(x) (*(struct __large_struct __user *)(x))
18072 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18073 +#define ____m(x) \
18074 +({ \
18075 + unsigned long ____x = (unsigned long)(x); \
18076 + if (____x < pax_user_shadow_base) \
18077 + ____x += pax_user_shadow_base; \
18078 + (typeof(x))____x; \
18079 +})
18080 +#else
18081 +#define ____m(x) (x)
18082 +#endif
18083 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18084
18085 /*
18086 * Tell gcc we read from memory instead of writing: this is because
18087 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
18088 * aliasing issues.
18089 */
18090 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18091 +do { \
18092 + pax_open_userland(); \
18093 asm volatile(ASM_STAC "\n" \
18094 - "1: mov"itype" %"rtype"1,%2\n" \
18095 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18096 "2: " ASM_CLAC "\n" \
18097 ".section .fixup,\"ax\"\n" \
18098 "3: mov %3,%0\n" \
18099 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
18100 ".previous\n" \
18101 _ASM_EXTABLE(1b, 3b) \
18102 : "=r"(err) \
18103 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18104 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18105 + pax_close_userland(); \
18106 +} while (0)
18107
18108 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18109 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18110 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18111 "2:\n" \
18112 _ASM_EXTABLE_EX(1b, 2b) \
18113 : : ltype(x), "m" (__m(addr)))
18114 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
18115 */
18116 #define uaccess_try do { \
18117 current_thread_info()->uaccess_err = 0; \
18118 + pax_open_userland(); \
18119 stac(); \
18120 barrier();
18121
18122 #define uaccess_catch(err) \
18123 clac(); \
18124 + pax_close_userland(); \
18125 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18126 } while (0)
18127
18128 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
18129 * On error, the variable @x is set to zero.
18130 */
18131
18132 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18133 +#define __get_user(x, ptr) get_user((x), (ptr))
18134 +#else
18135 #define __get_user(x, ptr) \
18136 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18137 +#endif
18138
18139 /**
18140 * __put_user: - Write a simple value into user space, with less checking.
18141 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
18142 * Returns zero on success, or -EFAULT on error.
18143 */
18144
18145 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18146 +#define __put_user(x, ptr) put_user((x), (ptr))
18147 +#else
18148 #define __put_user(x, ptr) \
18149 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18150 +#endif
18151
18152 #define __get_user_unaligned __get_user
18153 #define __put_user_unaligned __put_user
18154 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
18155 #define get_user_ex(x, ptr) do { \
18156 unsigned long __gue_val; \
18157 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18158 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18159 + (x) = (__typeof__(*(ptr)))__gue_val; \
18160 } while (0)
18161
18162 #define put_user_try uaccess_try
18163 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
18164 extern __must_check long strlen_user(const char __user *str);
18165 extern __must_check long strnlen_user(const char __user *str, long n);
18166
18167 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
18168 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
18169 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18170 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18171
18172 /*
18173 * movsl can be slow when source and dest are not both 8-byte aligned
18174 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18175 index 7f760a9..04b1c65 100644
18176 --- a/arch/x86/include/asm/uaccess_32.h
18177 +++ b/arch/x86/include/asm/uaccess_32.h
18178 @@ -11,15 +11,15 @@
18179 #include <asm/page.h>
18180
18181 unsigned long __must_check __copy_to_user_ll
18182 - (void __user *to, const void *from, unsigned long n);
18183 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
18184 unsigned long __must_check __copy_from_user_ll
18185 - (void *to, const void __user *from, unsigned long n);
18186 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18187 unsigned long __must_check __copy_from_user_ll_nozero
18188 - (void *to, const void __user *from, unsigned long n);
18189 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18190 unsigned long __must_check __copy_from_user_ll_nocache
18191 - (void *to, const void __user *from, unsigned long n);
18192 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18193 unsigned long __must_check __copy_from_user_ll_nocache_nozero
18194 - (void *to, const void __user *from, unsigned long n);
18195 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18196
18197 /**
18198 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
18199 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18200 static __always_inline unsigned long __must_check
18201 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18202 {
18203 + if ((long)n < 0)
18204 + return n;
18205 +
18206 + check_object_size(from, n, true);
18207 +
18208 if (__builtin_constant_p(n)) {
18209 unsigned long ret;
18210
18211 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18212 __copy_to_user(void __user *to, const void *from, unsigned long n)
18213 {
18214 might_fault();
18215 +
18216 return __copy_to_user_inatomic(to, from, n);
18217 }
18218
18219 static __always_inline unsigned long
18220 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18221 {
18222 + if ((long)n < 0)
18223 + return n;
18224 +
18225 /* Avoid zeroing the tail if the copy fails..
18226 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18227 * but as the zeroing behaviour is only significant when n is not
18228 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18229 __copy_from_user(void *to, const void __user *from, unsigned long n)
18230 {
18231 might_fault();
18232 +
18233 + if ((long)n < 0)
18234 + return n;
18235 +
18236 + check_object_size(to, n, false);
18237 +
18238 if (__builtin_constant_p(n)) {
18239 unsigned long ret;
18240
18241 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18242 const void __user *from, unsigned long n)
18243 {
18244 might_fault();
18245 +
18246 + if ((long)n < 0)
18247 + return n;
18248 +
18249 if (__builtin_constant_p(n)) {
18250 unsigned long ret;
18251
18252 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18253 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18254 unsigned long n)
18255 {
18256 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18257 + if ((long)n < 0)
18258 + return n;
18259 +
18260 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18261 }
18262
18263 -unsigned long __must_check copy_to_user(void __user *to,
18264 - const void *from, unsigned long n);
18265 -unsigned long __must_check _copy_from_user(void *to,
18266 - const void __user *from,
18267 - unsigned long n);
18268 -
18269 +extern void copy_to_user_overflow(void)
18270 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18271 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18272 +#else
18273 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18274 +#endif
18275 +;
18276
18277 extern void copy_from_user_overflow(void)
18278 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18279 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18280 #endif
18281 ;
18282
18283 -static inline unsigned long __must_check copy_from_user(void *to,
18284 - const void __user *from,
18285 - unsigned long n)
18286 +/**
18287 + * copy_to_user: - Copy a block of data into user space.
18288 + * @to: Destination address, in user space.
18289 + * @from: Source address, in kernel space.
18290 + * @n: Number of bytes to copy.
18291 + *
18292 + * Context: User context only. This function may sleep.
18293 + *
18294 + * Copy data from kernel space to user space.
18295 + *
18296 + * Returns number of bytes that could not be copied.
18297 + * On success, this will be zero.
18298 + */
18299 +static inline unsigned long __must_check
18300 +copy_to_user(void __user *to, const void *from, unsigned long n)
18301 {
18302 - int sz = __compiletime_object_size(to);
18303 + size_t sz = __compiletime_object_size(from);
18304
18305 - if (likely(sz == -1 || sz >= n))
18306 - n = _copy_from_user(to, from, n);
18307 - else
18308 + if (unlikely(sz != (size_t)-1 && sz < n))
18309 + copy_to_user_overflow();
18310 + else if (access_ok(VERIFY_WRITE, to, n))
18311 + n = __copy_to_user(to, from, n);
18312 + return n;
18313 +}
18314 +
18315 +/**
18316 + * copy_from_user: - Copy a block of data from user space.
18317 + * @to: Destination address, in kernel space.
18318 + * @from: Source address, in user space.
18319 + * @n: Number of bytes to copy.
18320 + *
18321 + * Context: User context only. This function may sleep.
18322 + *
18323 + * Copy data from user space to kernel space.
18324 + *
18325 + * Returns number of bytes that could not be copied.
18326 + * On success, this will be zero.
18327 + *
18328 + * If some data could not be copied, this function will pad the copied
18329 + * data to the requested size using zero bytes.
18330 + */
18331 +static inline unsigned long __must_check
18332 +copy_from_user(void *to, const void __user *from, unsigned long n)
18333 +{
18334 + size_t sz = __compiletime_object_size(to);
18335 +
18336 + check_object_size(to, n, false);
18337 +
18338 + if (unlikely(sz != (size_t)-1 && sz < n))
18339 copy_from_user_overflow();
18340 -
18341 + else if (access_ok(VERIFY_READ, from, n))
18342 + n = __copy_from_user(to, from, n);
18343 + else if ((long)n > 0)
18344 + memset(to, 0, n);
18345 return n;
18346 }
18347
18348 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18349 index 4f7923d..20cb24e 100644
18350 --- a/arch/x86/include/asm/uaccess_64.h
18351 +++ b/arch/x86/include/asm/uaccess_64.h
18352 @@ -10,6 +10,9 @@
18353 #include <asm/alternative.h>
18354 #include <asm/cpufeature.h>
18355 #include <asm/page.h>
18356 +#include <asm/pgtable.h>
18357 +
18358 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18359
18360 /*
18361 * Copy To/From Userspace
18362 @@ -17,13 +20,13 @@
18363
18364 /* Handles exceptions in both to and from, but doesn't do access_ok */
18365 __must_check unsigned long
18366 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18367 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18368 __must_check unsigned long
18369 -copy_user_generic_string(void *to, const void *from, unsigned len);
18370 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18371 __must_check unsigned long
18372 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18373 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18374
18375 -static __always_inline __must_check unsigned long
18376 +static __always_inline __must_check __size_overflow(3) unsigned long
18377 copy_user_generic(void *to, const void *from, unsigned len)
18378 {
18379 unsigned ret;
18380 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
18381 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
18382 "=d" (len)),
18383 "1" (to), "2" (from), "3" (len)
18384 - : "memory", "rcx", "r8", "r9", "r10", "r11");
18385 + : "memory", "rcx", "r8", "r9", "r11");
18386 return ret;
18387 }
18388
18389 +static __always_inline __must_check unsigned long
18390 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18391 +static __always_inline __must_check unsigned long
18392 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18393 __must_check unsigned long
18394 -_copy_to_user(void __user *to, const void *from, unsigned len);
18395 -__must_check unsigned long
18396 -_copy_from_user(void *to, const void __user *from, unsigned len);
18397 -__must_check unsigned long
18398 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18399 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18400 +
18401 +extern void copy_to_user_overflow(void)
18402 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18403 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18404 +#else
18405 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18406 +#endif
18407 +;
18408 +
18409 +extern void copy_from_user_overflow(void)
18410 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18411 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18412 +#else
18413 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18414 +#endif
18415 +;
18416
18417 static inline unsigned long __must_check copy_from_user(void *to,
18418 const void __user *from,
18419 unsigned long n)
18420 {
18421 - int sz = __compiletime_object_size(to);
18422 -
18423 might_fault();
18424 - if (likely(sz == -1 || sz >= n))
18425 - n = _copy_from_user(to, from, n);
18426 -#ifdef CONFIG_DEBUG_VM
18427 - else
18428 - WARN(1, "Buffer overflow detected!\n");
18429 -#endif
18430 +
18431 + check_object_size(to, n, false);
18432 +
18433 + if (access_ok(VERIFY_READ, from, n))
18434 + n = __copy_from_user(to, from, n);
18435 + else if (n < INT_MAX)
18436 + memset(to, 0, n);
18437 return n;
18438 }
18439
18440 static __always_inline __must_check
18441 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18442 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18443 {
18444 might_fault();
18445
18446 - return _copy_to_user(dst, src, size);
18447 + if (access_ok(VERIFY_WRITE, dst, size))
18448 + size = __copy_to_user(dst, src, size);
18449 + return size;
18450 }
18451
18452 static __always_inline __must_check
18453 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18454 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18455 {
18456 - int ret = 0;
18457 + size_t sz = __compiletime_object_size(dst);
18458 + unsigned ret = 0;
18459
18460 might_fault();
18461 +
18462 + if (size > INT_MAX)
18463 + return size;
18464 +
18465 + check_object_size(dst, size, false);
18466 +
18467 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18468 + if (!__access_ok(VERIFY_READ, src, size))
18469 + return size;
18470 +#endif
18471 +
18472 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18473 + copy_from_user_overflow();
18474 + return size;
18475 + }
18476 +
18477 if (!__builtin_constant_p(size))
18478 - return copy_user_generic(dst, (__force void *)src, size);
18479 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18480 switch (size) {
18481 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18482 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18483 ret, "b", "b", "=q", 1);
18484 return ret;
18485 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18486 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18487 ret, "w", "w", "=r", 2);
18488 return ret;
18489 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18490 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18491 ret, "l", "k", "=r", 4);
18492 return ret;
18493 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18494 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18495 ret, "q", "", "=r", 8);
18496 return ret;
18497 case 10:
18498 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18499 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18500 ret, "q", "", "=r", 10);
18501 if (unlikely(ret))
18502 return ret;
18503 __get_user_asm(*(u16 *)(8 + (char *)dst),
18504 - (u16 __user *)(8 + (char __user *)src),
18505 + (const u16 __user *)(8 + (const char __user *)src),
18506 ret, "w", "w", "=r", 2);
18507 return ret;
18508 case 16:
18509 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18510 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18511 ret, "q", "", "=r", 16);
18512 if (unlikely(ret))
18513 return ret;
18514 __get_user_asm(*(u64 *)(8 + (char *)dst),
18515 - (u64 __user *)(8 + (char __user *)src),
18516 + (const u64 __user *)(8 + (const char __user *)src),
18517 ret, "q", "", "=r", 8);
18518 return ret;
18519 default:
18520 - return copy_user_generic(dst, (__force void *)src, size);
18521 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18522 }
18523 }
18524
18525 static __always_inline __must_check
18526 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18527 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18528 {
18529 - int ret = 0;
18530 + size_t sz = __compiletime_object_size(src);
18531 + unsigned ret = 0;
18532
18533 might_fault();
18534 +
18535 + if (size > INT_MAX)
18536 + return size;
18537 +
18538 + check_object_size(src, size, true);
18539 +
18540 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18541 + if (!__access_ok(VERIFY_WRITE, dst, size))
18542 + return size;
18543 +#endif
18544 +
18545 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18546 + copy_to_user_overflow();
18547 + return size;
18548 + }
18549 +
18550 if (!__builtin_constant_p(size))
18551 - return copy_user_generic((__force void *)dst, src, size);
18552 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18553 switch (size) {
18554 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18555 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18556 ret, "b", "b", "iq", 1);
18557 return ret;
18558 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18559 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18560 ret, "w", "w", "ir", 2);
18561 return ret;
18562 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18563 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18564 ret, "l", "k", "ir", 4);
18565 return ret;
18566 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18567 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18568 ret, "q", "", "er", 8);
18569 return ret;
18570 case 10:
18571 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18572 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18573 ret, "q", "", "er", 10);
18574 if (unlikely(ret))
18575 return ret;
18576 asm("":::"memory");
18577 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18578 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18579 ret, "w", "w", "ir", 2);
18580 return ret;
18581 case 16:
18582 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18583 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18584 ret, "q", "", "er", 16);
18585 if (unlikely(ret))
18586 return ret;
18587 asm("":::"memory");
18588 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18589 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18590 ret, "q", "", "er", 8);
18591 return ret;
18592 default:
18593 - return copy_user_generic((__force void *)dst, src, size);
18594 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18595 }
18596 }
18597
18598 static __always_inline __must_check
18599 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18600 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18601 {
18602 - int ret = 0;
18603 + unsigned ret = 0;
18604
18605 might_fault();
18606 +
18607 + if (size > INT_MAX)
18608 + return size;
18609 +
18610 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18611 + if (!__access_ok(VERIFY_READ, src, size))
18612 + return size;
18613 + if (!__access_ok(VERIFY_WRITE, dst, size))
18614 + return size;
18615 +#endif
18616 +
18617 if (!__builtin_constant_p(size))
18618 - return copy_user_generic((__force void *)dst,
18619 - (__force void *)src, size);
18620 + return copy_user_generic((__force_kernel void *)____m(dst),
18621 + (__force_kernel const void *)____m(src), size);
18622 switch (size) {
18623 case 1: {
18624 u8 tmp;
18625 - __get_user_asm(tmp, (u8 __user *)src,
18626 + __get_user_asm(tmp, (const u8 __user *)src,
18627 ret, "b", "b", "=q", 1);
18628 if (likely(!ret))
18629 __put_user_asm(tmp, (u8 __user *)dst,
18630 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18631 }
18632 case 2: {
18633 u16 tmp;
18634 - __get_user_asm(tmp, (u16 __user *)src,
18635 + __get_user_asm(tmp, (const u16 __user *)src,
18636 ret, "w", "w", "=r", 2);
18637 if (likely(!ret))
18638 __put_user_asm(tmp, (u16 __user *)dst,
18639 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18640
18641 case 4: {
18642 u32 tmp;
18643 - __get_user_asm(tmp, (u32 __user *)src,
18644 + __get_user_asm(tmp, (const u32 __user *)src,
18645 ret, "l", "k", "=r", 4);
18646 if (likely(!ret))
18647 __put_user_asm(tmp, (u32 __user *)dst,
18648 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18649 }
18650 case 8: {
18651 u64 tmp;
18652 - __get_user_asm(tmp, (u64 __user *)src,
18653 + __get_user_asm(tmp, (const u64 __user *)src,
18654 ret, "q", "", "=r", 8);
18655 if (likely(!ret))
18656 __put_user_asm(tmp, (u64 __user *)dst,
18657 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18658 return ret;
18659 }
18660 default:
18661 - return copy_user_generic((__force void *)dst,
18662 - (__force void *)src, size);
18663 + return copy_user_generic((__force_kernel void *)____m(dst),
18664 + (__force_kernel const void *)____m(src), size);
18665 }
18666 }
18667
18668 -static __must_check __always_inline int
18669 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18670 +static __must_check __always_inline unsigned long
18671 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18672 {
18673 - return copy_user_generic(dst, (__force const void *)src, size);
18674 + if (size > INT_MAX)
18675 + return size;
18676 +
18677 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18678 + if (!__access_ok(VERIFY_READ, src, size))
18679 + return size;
18680 +#endif
18681 +
18682 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18683 }
18684
18685 -static __must_check __always_inline int
18686 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18687 +static __must_check __always_inline unsigned long
18688 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18689 {
18690 - return copy_user_generic((__force void *)dst, src, size);
18691 + if (size > INT_MAX)
18692 + return size;
18693 +
18694 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18695 + if (!__access_ok(VERIFY_WRITE, dst, size))
18696 + return size;
18697 +#endif
18698 +
18699 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18700 }
18701
18702 -extern long __copy_user_nocache(void *dst, const void __user *src,
18703 - unsigned size, int zerorest);
18704 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18705 + unsigned long size, int zerorest) __size_overflow(3);
18706
18707 -static inline int
18708 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18709 +static inline unsigned long
18710 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18711 {
18712 might_fault();
18713 +
18714 + if (size > INT_MAX)
18715 + return size;
18716 +
18717 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18718 + if (!__access_ok(VERIFY_READ, src, size))
18719 + return size;
18720 +#endif
18721 +
18722 return __copy_user_nocache(dst, src, size, 1);
18723 }
18724
18725 -static inline int
18726 +static inline unsigned long
18727 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18728 - unsigned size)
18729 + unsigned long size)
18730 {
18731 + if (size > INT_MAX)
18732 + return size;
18733 +
18734 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18735 + if (!__access_ok(VERIFY_READ, src, size))
18736 + return size;
18737 +#endif
18738 +
18739 return __copy_user_nocache(dst, src, size, 0);
18740 }
18741
18742 unsigned long
18743 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18744 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18745
18746 #endif /* _ASM_X86_UACCESS_64_H */
18747 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18748 index 5b238981..77fdd78 100644
18749 --- a/arch/x86/include/asm/word-at-a-time.h
18750 +++ b/arch/x86/include/asm/word-at-a-time.h
18751 @@ -11,7 +11,7 @@
18752 * and shift, for example.
18753 */
18754 struct word_at_a_time {
18755 - const unsigned long one_bits, high_bits;
18756 + unsigned long one_bits, high_bits;
18757 };
18758
18759 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18760 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18761 index 828a156..650e625 100644
18762 --- a/arch/x86/include/asm/x86_init.h
18763 +++ b/arch/x86/include/asm/x86_init.h
18764 @@ -129,7 +129,7 @@ struct x86_init_ops {
18765 struct x86_init_timers timers;
18766 struct x86_init_iommu iommu;
18767 struct x86_init_pci pci;
18768 -};
18769 +} __no_const;
18770
18771 /**
18772 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18773 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18774 void (*setup_percpu_clockev)(void);
18775 void (*early_percpu_clock_init)(void);
18776 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18777 -};
18778 +} __no_const;
18779
18780 struct timespec;
18781
18782 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18783 void (*save_sched_clock_state)(void);
18784 void (*restore_sched_clock_state)(void);
18785 void (*apic_post_init)(void);
18786 -};
18787 +} __no_const;
18788
18789 struct pci_dev;
18790 struct msi_msg;
18791 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18792 void (*teardown_msi_irqs)(struct pci_dev *dev);
18793 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18794 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18795 -};
18796 +} __no_const;
18797
18798 struct IO_APIC_route_entry;
18799 struct io_apic_irq_attr;
18800 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18801 unsigned int destination, int vector,
18802 struct io_apic_irq_attr *attr);
18803 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18804 -};
18805 +} __no_const;
18806
18807 extern struct x86_init_ops x86_init;
18808 extern struct x86_cpuinit_ops x86_cpuinit;
18809 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18810 index 0415cda..3b22adc 100644
18811 --- a/arch/x86/include/asm/xsave.h
18812 +++ b/arch/x86/include/asm/xsave.h
18813 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18814 if (unlikely(err))
18815 return -EFAULT;
18816
18817 + pax_open_userland();
18818 __asm__ __volatile__(ASM_STAC "\n"
18819 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18820 + "1:"
18821 + __copyuser_seg
18822 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18823 "2: " ASM_CLAC "\n"
18824 ".section .fixup,\"ax\"\n"
18825 "3: movl $-1,%[err]\n"
18826 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18827 : [err] "=r" (err)
18828 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18829 : "memory");
18830 + pax_close_userland();
18831 return err;
18832 }
18833
18834 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18835 {
18836 int err;
18837 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18838 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18839 u32 lmask = mask;
18840 u32 hmask = mask >> 32;
18841
18842 + pax_open_userland();
18843 __asm__ __volatile__(ASM_STAC "\n"
18844 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18845 + "1:"
18846 + __copyuser_seg
18847 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18848 "2: " ASM_CLAC "\n"
18849 ".section .fixup,\"ax\"\n"
18850 "3: movl $-1,%[err]\n"
18851 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18852 : [err] "=r" (err)
18853 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18854 : "memory"); /* memory required? */
18855 + pax_close_userland();
18856 return err;
18857 }
18858
18859 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18860 index bbae024..e1528f9 100644
18861 --- a/arch/x86/include/uapi/asm/e820.h
18862 +++ b/arch/x86/include/uapi/asm/e820.h
18863 @@ -63,7 +63,7 @@ struct e820map {
18864 #define ISA_START_ADDRESS 0xa0000
18865 #define ISA_END_ADDRESS 0x100000
18866
18867 -#define BIOS_BEGIN 0x000a0000
18868 +#define BIOS_BEGIN 0x000c0000
18869 #define BIOS_END 0x00100000
18870
18871 #define BIOS_ROM_BASE 0xffe00000
18872 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18873 index 88d99ea..9fc7e17 100644
18874 --- a/arch/x86/kernel/Makefile
18875 +++ b/arch/x86/kernel/Makefile
18876 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18877 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18878 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18879 obj-y += probe_roms.o
18880 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18881 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18882 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18883 obj-y += syscall_$(BITS).o
18884 obj-$(CONFIG_X86_64) += vsyscall_64.o
18885 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18886 index 2627a81..cd8325e 100644
18887 --- a/arch/x86/kernel/acpi/boot.c
18888 +++ b/arch/x86/kernel/acpi/boot.c
18889 @@ -1368,7 +1368,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18890 * If your system is blacklisted here, but you find that acpi=force
18891 * works for you, please contact linux-acpi@vger.kernel.org
18892 */
18893 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18894 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18895 /*
18896 * Boxes that need ACPI disabled
18897 */
18898 @@ -1443,7 +1443,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18899 };
18900
18901 /* second table for DMI checks that should run after early-quirks */
18902 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18903 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18904 /*
18905 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18906 * which includes some code which overrides all temperature
18907 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18908 index 3312010..a65ca7b 100644
18909 --- a/arch/x86/kernel/acpi/sleep.c
18910 +++ b/arch/x86/kernel/acpi/sleep.c
18911 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18912 #else /* CONFIG_64BIT */
18913 #ifdef CONFIG_SMP
18914 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18915 +
18916 + pax_open_kernel();
18917 early_gdt_descr.address =
18918 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18919 + pax_close_kernel();
18920 +
18921 initial_gs = per_cpu_offset(smp_processor_id());
18922 #endif
18923 initial_code = (unsigned long)wakeup_long64;
18924 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18925 index d1daa66..59fecba 100644
18926 --- a/arch/x86/kernel/acpi/wakeup_32.S
18927 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18928 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18929 # and restore the stack ... but you need gdt for this to work
18930 movl saved_context_esp, %esp
18931
18932 - movl %cs:saved_magic, %eax
18933 - cmpl $0x12345678, %eax
18934 + cmpl $0x12345678, saved_magic
18935 jne bogus_magic
18936
18937 # jump to place where we left off
18938 - movl saved_eip, %eax
18939 - jmp *%eax
18940 + jmp *(saved_eip)
18941
18942 bogus_magic:
18943 jmp bogus_magic
18944 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18945 index c15cf9a..0e63558 100644
18946 --- a/arch/x86/kernel/alternative.c
18947 +++ b/arch/x86/kernel/alternative.c
18948 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18949 */
18950 for (a = start; a < end; a++) {
18951 instr = (u8 *)&a->instr_offset + a->instr_offset;
18952 +
18953 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18954 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18955 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18956 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18957 +#endif
18958 +
18959 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18960 BUG_ON(a->replacementlen > a->instrlen);
18961 BUG_ON(a->instrlen > sizeof(insnbuf));
18962 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18963 for (poff = start; poff < end; poff++) {
18964 u8 *ptr = (u8 *)poff + *poff;
18965
18966 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18967 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18968 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18969 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18970 +#endif
18971 +
18972 if (!*poff || ptr < text || ptr >= text_end)
18973 continue;
18974 /* turn DS segment override prefix into lock prefix */
18975 - if (*ptr == 0x3e)
18976 + if (*ktla_ktva(ptr) == 0x3e)
18977 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18978 }
18979 mutex_unlock(&text_mutex);
18980 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18981 for (poff = start; poff < end; poff++) {
18982 u8 *ptr = (u8 *)poff + *poff;
18983
18984 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18985 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18986 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18987 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18988 +#endif
18989 +
18990 if (!*poff || ptr < text || ptr >= text_end)
18991 continue;
18992 /* turn lock prefix into DS segment override prefix */
18993 - if (*ptr == 0xf0)
18994 + if (*ktla_ktva(ptr) == 0xf0)
18995 text_poke(ptr, ((unsigned char []){0x3E}), 1);
18996 }
18997 mutex_unlock(&text_mutex);
18998 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
18999
19000 BUG_ON(p->len > MAX_PATCH_LEN);
19001 /* prep the buffer with the original instructions */
19002 - memcpy(insnbuf, p->instr, p->len);
19003 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19004 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19005 (unsigned long)p->instr, p->len);
19006
19007 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
19008 if (!uniproc_patched || num_possible_cpus() == 1)
19009 free_init_pages("SMP alternatives",
19010 (unsigned long)__smp_locks,
19011 - (unsigned long)__smp_locks_end);
19012 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19013 #endif
19014
19015 apply_paravirt(__parainstructions, __parainstructions_end);
19016 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
19017 * instructions. And on the local CPU you need to be protected again NMI or MCE
19018 * handlers seeing an inconsistent instruction while you patch.
19019 */
19020 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19021 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19022 size_t len)
19023 {
19024 unsigned long flags;
19025 local_irq_save(flags);
19026 - memcpy(addr, opcode, len);
19027 +
19028 + pax_open_kernel();
19029 + memcpy(ktla_ktva(addr), opcode, len);
19030 sync_core();
19031 + pax_close_kernel();
19032 +
19033 local_irq_restore(flags);
19034 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19035 that causes hangs on some VIA CPUs. */
19036 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19037 */
19038 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19039 {
19040 - unsigned long flags;
19041 - char *vaddr;
19042 + unsigned char *vaddr = ktla_ktva(addr);
19043 struct page *pages[2];
19044 - int i;
19045 + size_t i;
19046
19047 if (!core_kernel_text((unsigned long)addr)) {
19048 - pages[0] = vmalloc_to_page(addr);
19049 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19050 + pages[0] = vmalloc_to_page(vaddr);
19051 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19052 } else {
19053 - pages[0] = virt_to_page(addr);
19054 + pages[0] = virt_to_page(vaddr);
19055 WARN_ON(!PageReserved(pages[0]));
19056 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19057 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19058 }
19059 BUG_ON(!pages[0]);
19060 - local_irq_save(flags);
19061 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19062 - if (pages[1])
19063 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19064 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19065 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19066 - clear_fixmap(FIX_TEXT_POKE0);
19067 - if (pages[1])
19068 - clear_fixmap(FIX_TEXT_POKE1);
19069 - local_flush_tlb();
19070 - sync_core();
19071 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19072 - that causes hangs on some VIA CPUs. */
19073 + text_poke_early(addr, opcode, len);
19074 for (i = 0; i < len; i++)
19075 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19076 - local_irq_restore(flags);
19077 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19078 return addr;
19079 }
19080
19081 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19082 index eca89c5..d566b78 100644
19083 --- a/arch/x86/kernel/apic/apic.c
19084 +++ b/arch/x86/kernel/apic/apic.c
19085 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19086 /*
19087 * Debug level, exported for io_apic.c
19088 */
19089 -unsigned int apic_verbosity;
19090 +int apic_verbosity;
19091
19092 int pic_mode;
19093
19094 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19095 apic_write(APIC_ESR, 0);
19096 v1 = apic_read(APIC_ESR);
19097 ack_APIC_irq();
19098 - atomic_inc(&irq_err_count);
19099 + atomic_inc_unchecked(&irq_err_count);
19100
19101 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19102 smp_processor_id(), v0 , v1);
19103 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19104 index 00c77cf..2dc6a2d 100644
19105 --- a/arch/x86/kernel/apic/apic_flat_64.c
19106 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19107 @@ -157,7 +157,7 @@ static int flat_probe(void)
19108 return 1;
19109 }
19110
19111 -static struct apic apic_flat = {
19112 +static struct apic apic_flat __read_only = {
19113 .name = "flat",
19114 .probe = flat_probe,
19115 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19116 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19117 return 0;
19118 }
19119
19120 -static struct apic apic_physflat = {
19121 +static struct apic apic_physflat __read_only = {
19122
19123 .name = "physical flat",
19124 .probe = physflat_probe,
19125 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19126 index e145f28..2752888 100644
19127 --- a/arch/x86/kernel/apic/apic_noop.c
19128 +++ b/arch/x86/kernel/apic/apic_noop.c
19129 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19130 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19131 }
19132
19133 -struct apic apic_noop = {
19134 +struct apic apic_noop __read_only = {
19135 .name = "noop",
19136 .probe = noop_probe,
19137 .acpi_madt_oem_check = NULL,
19138 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19139 index d50e364..543bee3 100644
19140 --- a/arch/x86/kernel/apic/bigsmp_32.c
19141 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19142 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19143 return dmi_bigsmp;
19144 }
19145
19146 -static struct apic apic_bigsmp = {
19147 +static struct apic apic_bigsmp __read_only = {
19148
19149 .name = "bigsmp",
19150 .probe = probe_bigsmp,
19151 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19152 index c552247..587a316 100644
19153 --- a/arch/x86/kernel/apic/es7000_32.c
19154 +++ b/arch/x86/kernel/apic/es7000_32.c
19155 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19156 return ret && es7000_apic_is_cluster();
19157 }
19158
19159 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19160 -static struct apic __refdata apic_es7000_cluster = {
19161 +static struct apic apic_es7000_cluster __read_only = {
19162
19163 .name = "es7000",
19164 .probe = probe_es7000,
19165 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19166 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19167 };
19168
19169 -static struct apic __refdata apic_es7000 = {
19170 +static struct apic apic_es7000 __read_only = {
19171
19172 .name = "es7000",
19173 .probe = probe_es7000,
19174 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19175 index 9ed796c..e930fe4 100644
19176 --- a/arch/x86/kernel/apic/io_apic.c
19177 +++ b/arch/x86/kernel/apic/io_apic.c
19178 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19179 }
19180 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19181
19182 -void lock_vector_lock(void)
19183 +void lock_vector_lock(void) __acquires(vector_lock)
19184 {
19185 /* Used to the online set of cpus does not change
19186 * during assign_irq_vector.
19187 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19188 raw_spin_lock(&vector_lock);
19189 }
19190
19191 -void unlock_vector_lock(void)
19192 +void unlock_vector_lock(void) __releases(vector_lock)
19193 {
19194 raw_spin_unlock(&vector_lock);
19195 }
19196 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
19197 ack_APIC_irq();
19198 }
19199
19200 -atomic_t irq_mis_count;
19201 +atomic_unchecked_t irq_mis_count;
19202
19203 #ifdef CONFIG_GENERIC_PENDING_IRQ
19204 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19205 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
19206 * at the cpu.
19207 */
19208 if (!(v & (1 << (i & 0x1f)))) {
19209 - atomic_inc(&irq_mis_count);
19210 + atomic_inc_unchecked(&irq_mis_count);
19211
19212 eoi_ioapic_irq(irq, cfg);
19213 }
19214 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19215 index 1e42e8f..daacf44 100644
19216 --- a/arch/x86/kernel/apic/numaq_32.c
19217 +++ b/arch/x86/kernel/apic/numaq_32.c
19218 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19219 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19220 }
19221
19222 -/* Use __refdata to keep false positive warning calm. */
19223 -static struct apic __refdata apic_numaq = {
19224 +static struct apic apic_numaq __read_only = {
19225
19226 .name = "NUMAQ",
19227 .probe = probe_numaq,
19228 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19229 index eb35ef9..f184a21 100644
19230 --- a/arch/x86/kernel/apic/probe_32.c
19231 +++ b/arch/x86/kernel/apic/probe_32.c
19232 @@ -72,7 +72,7 @@ static int probe_default(void)
19233 return 1;
19234 }
19235
19236 -static struct apic apic_default = {
19237 +static struct apic apic_default __read_only = {
19238
19239 .name = "default",
19240 .probe = probe_default,
19241 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19242 index 77c95c0..434f8a4 100644
19243 --- a/arch/x86/kernel/apic/summit_32.c
19244 +++ b/arch/x86/kernel/apic/summit_32.c
19245 @@ -486,7 +486,7 @@ void setup_summit(void)
19246 }
19247 #endif
19248
19249 -static struct apic apic_summit = {
19250 +static struct apic apic_summit __read_only = {
19251
19252 .name = "summit",
19253 .probe = probe_summit,
19254 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19255 index 140e29d..d88bc95 100644
19256 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19257 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19258 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19259 return notifier_from_errno(err);
19260 }
19261
19262 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19263 +static struct notifier_block x2apic_cpu_notifier = {
19264 .notifier_call = update_clusterinfo,
19265 };
19266
19267 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19268 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19269 }
19270
19271 -static struct apic apic_x2apic_cluster = {
19272 +static struct apic apic_x2apic_cluster __read_only = {
19273
19274 .name = "cluster x2apic",
19275 .probe = x2apic_cluster_probe,
19276 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19277 index 562a76d..a003c0f 100644
19278 --- a/arch/x86/kernel/apic/x2apic_phys.c
19279 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19280 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19281 return apic == &apic_x2apic_phys;
19282 }
19283
19284 -static struct apic apic_x2apic_phys = {
19285 +static struct apic apic_x2apic_phys __read_only = {
19286
19287 .name = "physical x2apic",
19288 .probe = x2apic_phys_probe,
19289 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19290 index 1191ac1..2335fa4 100644
19291 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19292 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19293 @@ -357,7 +357,7 @@ static int uv_probe(void)
19294 return apic == &apic_x2apic_uv_x;
19295 }
19296
19297 -static struct apic __refdata apic_x2apic_uv_x = {
19298 +static struct apic apic_x2apic_uv_x __read_only = {
19299
19300 .name = "UV large system",
19301 .probe = uv_probe,
19302 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19303 index 53a4e27..038760a 100644
19304 --- a/arch/x86/kernel/apm_32.c
19305 +++ b/arch/x86/kernel/apm_32.c
19306 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19307 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19308 * even though they are called in protected mode.
19309 */
19310 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19311 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19312 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19313
19314 static const char driver_version[] = "1.16ac"; /* no spaces */
19315 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19316 BUG_ON(cpu != 0);
19317 gdt = get_cpu_gdt_table(cpu);
19318 save_desc_40 = gdt[0x40 / 8];
19319 +
19320 + pax_open_kernel();
19321 gdt[0x40 / 8] = bad_bios_desc;
19322 + pax_close_kernel();
19323
19324 apm_irq_save(flags);
19325 APM_DO_SAVE_SEGS;
19326 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19327 &call->esi);
19328 APM_DO_RESTORE_SEGS;
19329 apm_irq_restore(flags);
19330 +
19331 + pax_open_kernel();
19332 gdt[0x40 / 8] = save_desc_40;
19333 + pax_close_kernel();
19334 +
19335 put_cpu();
19336
19337 return call->eax & 0xff;
19338 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19339 BUG_ON(cpu != 0);
19340 gdt = get_cpu_gdt_table(cpu);
19341 save_desc_40 = gdt[0x40 / 8];
19342 +
19343 + pax_open_kernel();
19344 gdt[0x40 / 8] = bad_bios_desc;
19345 + pax_close_kernel();
19346
19347 apm_irq_save(flags);
19348 APM_DO_SAVE_SEGS;
19349 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19350 &call->eax);
19351 APM_DO_RESTORE_SEGS;
19352 apm_irq_restore(flags);
19353 +
19354 + pax_open_kernel();
19355 gdt[0x40 / 8] = save_desc_40;
19356 + pax_close_kernel();
19357 +
19358 put_cpu();
19359 return error;
19360 }
19361 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19362 * code to that CPU.
19363 */
19364 gdt = get_cpu_gdt_table(0);
19365 +
19366 + pax_open_kernel();
19367 set_desc_base(&gdt[APM_CS >> 3],
19368 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19369 set_desc_base(&gdt[APM_CS_16 >> 3],
19370 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19371 set_desc_base(&gdt[APM_DS >> 3],
19372 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19373 + pax_close_kernel();
19374
19375 proc_create("apm", 0, NULL, &apm_file_ops);
19376
19377 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19378 index 2861082..6d4718e 100644
19379 --- a/arch/x86/kernel/asm-offsets.c
19380 +++ b/arch/x86/kernel/asm-offsets.c
19381 @@ -33,6 +33,8 @@ void common(void) {
19382 OFFSET(TI_status, thread_info, status);
19383 OFFSET(TI_addr_limit, thread_info, addr_limit);
19384 OFFSET(TI_preempt_count, thread_info, preempt_count);
19385 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19386 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19387
19388 BLANK();
19389 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19390 @@ -53,8 +55,26 @@ void common(void) {
19391 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19392 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19393 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19394 +
19395 +#ifdef CONFIG_PAX_KERNEXEC
19396 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19397 #endif
19398
19399 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19400 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19401 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19402 +#ifdef CONFIG_X86_64
19403 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19404 +#endif
19405 +#endif
19406 +
19407 +#endif
19408 +
19409 + BLANK();
19410 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19411 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19412 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19413 +
19414 #ifdef CONFIG_XEN
19415 BLANK();
19416 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19417 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19418 index e7c798b..2b2019b 100644
19419 --- a/arch/x86/kernel/asm-offsets_64.c
19420 +++ b/arch/x86/kernel/asm-offsets_64.c
19421 @@ -77,6 +77,7 @@ int main(void)
19422 BLANK();
19423 #undef ENTRY
19424
19425 + DEFINE(TSS_size, sizeof(struct tss_struct));
19426 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19427 BLANK();
19428
19429 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19430 index 47b56a7..efc2bc6 100644
19431 --- a/arch/x86/kernel/cpu/Makefile
19432 +++ b/arch/x86/kernel/cpu/Makefile
19433 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19434 CFLAGS_REMOVE_perf_event.o = -pg
19435 endif
19436
19437 -# Make sure load_percpu_segment has no stackprotector
19438 -nostackp := $(call cc-option, -fno-stack-protector)
19439 -CFLAGS_common.o := $(nostackp)
19440 -
19441 obj-y := intel_cacheinfo.o scattered.o topology.o
19442 obj-y += proc.o capflags.o powerflags.o common.o
19443 obj-y += rdrand.o
19444 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19445 index 08a0890..e557865 100644
19446 --- a/arch/x86/kernel/cpu/amd.c
19447 +++ b/arch/x86/kernel/cpu/amd.c
19448 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19449 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19450 {
19451 /* AMD errata T13 (order #21922) */
19452 - if ((c->x86 == 6)) {
19453 + if (c->x86 == 6) {
19454 /* Duron Rev A0 */
19455 if (c->x86_model == 3 && c->x86_mask == 0)
19456 size = 64;
19457 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19458 index 25eb274..3a92d93 100644
19459 --- a/arch/x86/kernel/cpu/common.c
19460 +++ b/arch/x86/kernel/cpu/common.c
19461 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19462
19463 static const struct cpu_dev *this_cpu = &default_cpu;
19464
19465 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19466 -#ifdef CONFIG_X86_64
19467 - /*
19468 - * We need valid kernel segments for data and code in long mode too
19469 - * IRET will check the segment types kkeil 2000/10/28
19470 - * Also sysret mandates a special GDT layout
19471 - *
19472 - * TLS descriptors are currently at a different place compared to i386.
19473 - * Hopefully nobody expects them at a fixed place (Wine?)
19474 - */
19475 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19476 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19477 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19478 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19479 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19480 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19481 -#else
19482 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19483 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19484 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19485 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19486 - /*
19487 - * Segments used for calling PnP BIOS have byte granularity.
19488 - * They code segments and data segments have fixed 64k limits,
19489 - * the transfer segment sizes are set at run time.
19490 - */
19491 - /* 32-bit code */
19492 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19493 - /* 16-bit code */
19494 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19495 - /* 16-bit data */
19496 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19497 - /* 16-bit data */
19498 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19499 - /* 16-bit data */
19500 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19501 - /*
19502 - * The APM segments have byte granularity and their bases
19503 - * are set at run time. All have 64k limits.
19504 - */
19505 - /* 32-bit code */
19506 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19507 - /* 16-bit code */
19508 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19509 - /* data */
19510 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19511 -
19512 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19513 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19514 - GDT_STACK_CANARY_INIT
19515 -#endif
19516 -} };
19517 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19518 -
19519 static int __init x86_xsave_setup(char *s)
19520 {
19521 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19522 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19523 set_in_cr4(X86_CR4_SMAP);
19524 }
19525
19526 +#ifdef CONFIG_X86_64
19527 +static __init int setup_disable_pcid(char *arg)
19528 +{
19529 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19530 +
19531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19532 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19533 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19534 +#endif
19535 +
19536 + return 1;
19537 +}
19538 +__setup("nopcid", setup_disable_pcid);
19539 +
19540 +static void setup_pcid(struct cpuinfo_x86 *c)
19541 +{
19542 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19543 +
19544 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19545 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19546 + pax_open_kernel();
19547 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19548 + pax_close_kernel();
19549 + printk("PAX: slow and weak UDEREF enabled\n");
19550 + } else
19551 + printk("PAX: UDEREF disabled\n");
19552 +#endif
19553 +
19554 + return;
19555 + }
19556 +
19557 + printk("PAX: PCID detected\n");
19558 + set_in_cr4(X86_CR4_PCIDE);
19559 +
19560 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19561 + pax_open_kernel();
19562 + clone_pgd_mask = ~(pgdval_t)0UL;
19563 + pax_close_kernel();
19564 + if (pax_user_shadow_base)
19565 + printk("PAX: weak UDEREF enabled\n");
19566 + else {
19567 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19568 + printk("PAX: strong UDEREF enabled\n");
19569 + }
19570 +#endif
19571 +
19572 + if (cpu_has(c, X86_FEATURE_INVPCID))
19573 + printk("PAX: INVPCID detected\n");
19574 +}
19575 +#endif
19576 +
19577 /*
19578 * Some CPU features depend on higher CPUID levels, which may not always
19579 * be available due to CPUID level capping or broken virtualization
19580 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19581 {
19582 struct desc_ptr gdt_descr;
19583
19584 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19585 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19586 gdt_descr.size = GDT_SIZE - 1;
19587 load_gdt(&gdt_descr);
19588 /* Reload the per-cpu base */
19589 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19590 setup_smep(c);
19591 setup_smap(c);
19592
19593 +#ifdef CONFIG_X86_64
19594 + setup_pcid(c);
19595 +#endif
19596 +
19597 /*
19598 * The vendor-specific functions might have changed features.
19599 * Now we do "generic changes."
19600 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19601 /* Filter out anything that depends on CPUID levels we don't have */
19602 filter_cpuid_features(c, true);
19603
19604 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19605 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19606 +#endif
19607 +
19608 /* If the model name is still unset, do table lookup. */
19609 if (!c->x86_model_id[0]) {
19610 const char *p;
19611 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19612 }
19613 __setup("clearcpuid=", setup_disablecpuid);
19614
19615 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19616 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19617 +
19618 #ifdef CONFIG_X86_64
19619 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19620 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19621 - (unsigned long) debug_idt_table };
19622 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19623 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19624
19625 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19626 irq_stack_union) __aligned(PAGE_SIZE);
19627 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19628 EXPORT_PER_CPU_SYMBOL(current_task);
19629
19630 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19631 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19632 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19633 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19634
19635 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19636 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19637 load_ucode_ap();
19638
19639 cpu = stack_smp_processor_id();
19640 - t = &per_cpu(init_tss, cpu);
19641 + t = init_tss + cpu;
19642 oist = &per_cpu(orig_ist, cpu);
19643
19644 #ifdef CONFIG_NUMA
19645 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19646 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19647 barrier();
19648
19649 - x86_configure_nx();
19650 enable_x2apic();
19651
19652 /*
19653 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19654 {
19655 int cpu = smp_processor_id();
19656 struct task_struct *curr = current;
19657 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19658 + struct tss_struct *t = init_tss + cpu;
19659 struct thread_struct *thread = &curr->thread;
19660
19661 show_ucode_info_early();
19662 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19663 index 1414c90..1159406 100644
19664 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19665 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19666 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19667 };
19668
19669 #ifdef CONFIG_AMD_NB
19670 +static struct attribute *default_attrs_amd_nb[] = {
19671 + &type.attr,
19672 + &level.attr,
19673 + &coherency_line_size.attr,
19674 + &physical_line_partition.attr,
19675 + &ways_of_associativity.attr,
19676 + &number_of_sets.attr,
19677 + &size.attr,
19678 + &shared_cpu_map.attr,
19679 + &shared_cpu_list.attr,
19680 + NULL,
19681 + NULL,
19682 + NULL,
19683 + NULL
19684 +};
19685 +
19686 static struct attribute **amd_l3_attrs(void)
19687 {
19688 static struct attribute **attrs;
19689 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19690
19691 n = ARRAY_SIZE(default_attrs);
19692
19693 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19694 - n += 2;
19695 -
19696 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19697 - n += 1;
19698 -
19699 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19700 - if (attrs == NULL)
19701 - return attrs = default_attrs;
19702 -
19703 - for (n = 0; default_attrs[n]; n++)
19704 - attrs[n] = default_attrs[n];
19705 + attrs = default_attrs_amd_nb;
19706
19707 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19708 attrs[n++] = &cache_disable_0.attr;
19709 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19710 .default_attrs = default_attrs,
19711 };
19712
19713 +#ifdef CONFIG_AMD_NB
19714 +static struct kobj_type ktype_cache_amd_nb = {
19715 + .sysfs_ops = &sysfs_ops,
19716 + .default_attrs = default_attrs_amd_nb,
19717 +};
19718 +#endif
19719 +
19720 static struct kobj_type ktype_percpu_entry = {
19721 .sysfs_ops = &sysfs_ops,
19722 };
19723 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19724 return retval;
19725 }
19726
19727 +#ifdef CONFIG_AMD_NB
19728 + amd_l3_attrs();
19729 +#endif
19730 +
19731 for (i = 0; i < num_cache_leaves; i++) {
19732 + struct kobj_type *ktype;
19733 +
19734 this_object = INDEX_KOBJECT_PTR(cpu, i);
19735 this_object->cpu = cpu;
19736 this_object->index = i;
19737
19738 this_leaf = CPUID4_INFO_IDX(cpu, i);
19739
19740 - ktype_cache.default_attrs = default_attrs;
19741 + ktype = &ktype_cache;
19742 #ifdef CONFIG_AMD_NB
19743 if (this_leaf->base.nb)
19744 - ktype_cache.default_attrs = amd_l3_attrs();
19745 + ktype = &ktype_cache_amd_nb;
19746 #endif
19747 retval = kobject_init_and_add(&(this_object->kobj),
19748 - &ktype_cache,
19749 + ktype,
19750 per_cpu(ici_cache_kobject, cpu),
19751 "index%1lu", i);
19752 if (unlikely(retval)) {
19753 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19754 index 87a65c9..92fcce6 100644
19755 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19756 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19757 @@ -45,6 +45,7 @@
19758 #include <asm/processor.h>
19759 #include <asm/mce.h>
19760 #include <asm/msr.h>
19761 +#include <asm/local.h>
19762
19763 #include "mce-internal.h"
19764
19765 @@ -249,7 +250,7 @@ static void print_mce(struct mce *m)
19766 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19767 m->cs, m->ip);
19768
19769 - if (m->cs == __KERNEL_CS)
19770 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19771 print_symbol("{%s}", m->ip);
19772 pr_cont("\n");
19773 }
19774 @@ -282,10 +283,10 @@ static void print_mce(struct mce *m)
19775
19776 #define PANIC_TIMEOUT 5 /* 5 seconds */
19777
19778 -static atomic_t mce_paniced;
19779 +static atomic_unchecked_t mce_paniced;
19780
19781 static int fake_panic;
19782 -static atomic_t mce_fake_paniced;
19783 +static atomic_unchecked_t mce_fake_paniced;
19784
19785 /* Panic in progress. Enable interrupts and wait for final IPI */
19786 static void wait_for_panic(void)
19787 @@ -309,7 +310,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19788 /*
19789 * Make sure only one CPU runs in machine check panic
19790 */
19791 - if (atomic_inc_return(&mce_paniced) > 1)
19792 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19793 wait_for_panic();
19794 barrier();
19795
19796 @@ -317,7 +318,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19797 console_verbose();
19798 } else {
19799 /* Don't log too much for fake panic */
19800 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19801 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19802 return;
19803 }
19804 /* First print corrected ones that are still unlogged */
19805 @@ -356,7 +357,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19806 if (!fake_panic) {
19807 if (panic_timeout == 0)
19808 panic_timeout = mca_cfg.panic_timeout;
19809 - panic(msg);
19810 + panic("%s", msg);
19811 } else
19812 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19813 }
19814 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
19815 * might have been modified by someone else.
19816 */
19817 rmb();
19818 - if (atomic_read(&mce_paniced))
19819 + if (atomic_read_unchecked(&mce_paniced))
19820 wait_for_panic();
19821 if (!mca_cfg.monarch_timeout)
19822 goto out;
19823 @@ -1657,7 +1658,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19824 }
19825
19826 /* Call the installed machine check handler for this CPU setup. */
19827 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19828 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19829 unexpected_machine_check;
19830
19831 /*
19832 @@ -1680,7 +1681,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19833 return;
19834 }
19835
19836 + pax_open_kernel();
19837 machine_check_vector = do_machine_check;
19838 + pax_close_kernel();
19839
19840 __mcheck_cpu_init_generic();
19841 __mcheck_cpu_init_vendor(c);
19842 @@ -1694,7 +1697,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19843 */
19844
19845 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19846 -static int mce_chrdev_open_count; /* #times opened */
19847 +static local_t mce_chrdev_open_count; /* #times opened */
19848 static int mce_chrdev_open_exclu; /* already open exclusive? */
19849
19850 static int mce_chrdev_open(struct inode *inode, struct file *file)
19851 @@ -1702,7 +1705,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19852 spin_lock(&mce_chrdev_state_lock);
19853
19854 if (mce_chrdev_open_exclu ||
19855 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19856 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19857 spin_unlock(&mce_chrdev_state_lock);
19858
19859 return -EBUSY;
19860 @@ -1710,7 +1713,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19861
19862 if (file->f_flags & O_EXCL)
19863 mce_chrdev_open_exclu = 1;
19864 - mce_chrdev_open_count++;
19865 + local_inc(&mce_chrdev_open_count);
19866
19867 spin_unlock(&mce_chrdev_state_lock);
19868
19869 @@ -1721,7 +1724,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19870 {
19871 spin_lock(&mce_chrdev_state_lock);
19872
19873 - mce_chrdev_open_count--;
19874 + local_dec(&mce_chrdev_open_count);
19875 mce_chrdev_open_exclu = 0;
19876
19877 spin_unlock(&mce_chrdev_state_lock);
19878 @@ -2376,7 +2379,7 @@ static __init void mce_init_banks(void)
19879
19880 for (i = 0; i < mca_cfg.banks; i++) {
19881 struct mce_bank *b = &mce_banks[i];
19882 - struct device_attribute *a = &b->attr;
19883 + device_attribute_no_const *a = &b->attr;
19884
19885 sysfs_attr_init(&a->attr);
19886 a->attr.name = b->attrname;
19887 @@ -2444,7 +2447,7 @@ struct dentry *mce_get_debugfs_dir(void)
19888 static void mce_reset(void)
19889 {
19890 cpu_missing = 0;
19891 - atomic_set(&mce_fake_paniced, 0);
19892 + atomic_set_unchecked(&mce_fake_paniced, 0);
19893 atomic_set(&mce_executing, 0);
19894 atomic_set(&mce_callin, 0);
19895 atomic_set(&global_nwo, 0);
19896 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19897 index 1c044b1..37a2a43 100644
19898 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19899 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19900 @@ -11,6 +11,7 @@
19901 #include <asm/processor.h>
19902 #include <asm/mce.h>
19903 #include <asm/msr.h>
19904 +#include <asm/pgtable.h>
19905
19906 /* By default disabled */
19907 int mce_p5_enabled __read_mostly;
19908 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19909 if (!cpu_has(c, X86_FEATURE_MCE))
19910 return;
19911
19912 + pax_open_kernel();
19913 machine_check_vector = pentium_machine_check;
19914 + pax_close_kernel();
19915 /* Make sure the vector pointer is visible before we enable MCEs: */
19916 wmb();
19917
19918 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19919 index e9a701a..35317d6 100644
19920 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19921 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19922 @@ -10,6 +10,7 @@
19923 #include <asm/processor.h>
19924 #include <asm/mce.h>
19925 #include <asm/msr.h>
19926 +#include <asm/pgtable.h>
19927
19928 /* Machine check handler for WinChip C6: */
19929 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19930 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19931 {
19932 u32 lo, hi;
19933
19934 + pax_open_kernel();
19935 machine_check_vector = winchip_machine_check;
19936 + pax_close_kernel();
19937 /* Make sure the vector pointer is visible before we enable MCEs: */
19938 wmb();
19939
19940 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19941 index f961de9..8a9d332 100644
19942 --- a/arch/x86/kernel/cpu/mtrr/main.c
19943 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19944 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19945 u64 size_or_mask, size_and_mask;
19946 static bool mtrr_aps_delayed_init;
19947
19948 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19949 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19950
19951 const struct mtrr_ops *mtrr_if;
19952
19953 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19954 index df5e41f..816c719 100644
19955 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19956 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19957 @@ -25,7 +25,7 @@ struct mtrr_ops {
19958 int (*validate_add_page)(unsigned long base, unsigned long size,
19959 unsigned int type);
19960 int (*have_wrcomb)(void);
19961 -};
19962 +} __do_const;
19963
19964 extern int generic_get_free_region(unsigned long base, unsigned long size,
19965 int replace_reg);
19966 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19967 index a7c7305..b9705ab 100644
19968 --- a/arch/x86/kernel/cpu/perf_event.c
19969 +++ b/arch/x86/kernel/cpu/perf_event.c
19970 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
19971 pr_info("no hardware sampling interrupt available.\n");
19972 }
19973
19974 -static struct attribute_group x86_pmu_format_group = {
19975 +static attribute_group_no_const x86_pmu_format_group = {
19976 .name = "format",
19977 .attrs = NULL,
19978 };
19979 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
19980 NULL,
19981 };
19982
19983 -static struct attribute_group x86_pmu_events_group = {
19984 +static attribute_group_no_const x86_pmu_events_group = {
19985 .name = "events",
19986 .attrs = events_attr,
19987 };
19988 @@ -1957,7 +1957,7 @@ static unsigned long get_segment_base(unsigned int segment)
19989 if (idx > GDT_ENTRIES)
19990 return 0;
19991
19992 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
19993 + desc = get_cpu_gdt_table(smp_processor_id());
19994 }
19995
19996 return get_desc_base(desc + idx);
19997 @@ -2047,7 +2047,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
19998 break;
19999
20000 perf_callchain_store(entry, frame.return_address);
20001 - fp = frame.next_frame;
20002 + fp = (const void __force_user *)frame.next_frame;
20003 }
20004 }
20005
20006 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20007 index 639d128..e92d7e5 100644
20008 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20009 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20010 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20011 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20012 {
20013 struct attribute **attrs;
20014 - struct attribute_group *attr_group;
20015 + attribute_group_no_const *attr_group;
20016 int i = 0, j;
20017
20018 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20019 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20020 index a45d8d4..8abd32c 100644
20021 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20022 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20023 @@ -2099,10 +2099,10 @@ __init int intel_pmu_init(void)
20024 * v2 and above have a perf capabilities MSR
20025 */
20026 if (version > 1) {
20027 - u64 capabilities;
20028 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20029
20030 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20031 - x86_pmu.intel_cap.capabilities = capabilities;
20032 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20033 + x86_pmu.intel_cap.capabilities = capabilities;
20034 }
20035
20036 intel_ds_init();
20037 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20038 index 1fb6c72..f5fa2a3 100644
20039 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20040 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20041 @@ -3095,7 +3095,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20042 static int __init uncore_type_init(struct intel_uncore_type *type)
20043 {
20044 struct intel_uncore_pmu *pmus;
20045 - struct attribute_group *attr_group;
20046 + attribute_group_no_const *attr_group;
20047 struct attribute **attrs;
20048 int i, j;
20049
20050 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20051 index 47b3d00c..2cf1751 100644
20052 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20053 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20054 @@ -488,7 +488,7 @@ struct intel_uncore_box {
20055 struct uncore_event_desc {
20056 struct kobj_attribute attr;
20057 const char *config;
20058 -};
20059 +} __do_const;
20060
20061 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20062 { \
20063 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20064 index 7d9481c..99c7e4b 100644
20065 --- a/arch/x86/kernel/cpuid.c
20066 +++ b/arch/x86/kernel/cpuid.c
20067 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20068 return notifier_from_errno(err);
20069 }
20070
20071 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20072 +static struct notifier_block cpuid_class_cpu_notifier =
20073 {
20074 .notifier_call = cpuid_class_cpu_callback,
20075 };
20076 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20077 index 74467fe..18793d5 100644
20078 --- a/arch/x86/kernel/crash.c
20079 +++ b/arch/x86/kernel/crash.c
20080 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20081 {
20082 #ifdef CONFIG_X86_32
20083 struct pt_regs fixed_regs;
20084 -#endif
20085
20086 -#ifdef CONFIG_X86_32
20087 - if (!user_mode_vm(regs)) {
20088 + if (!user_mode(regs)) {
20089 crash_fixup_ss_esp(&fixed_regs, regs);
20090 regs = &fixed_regs;
20091 }
20092 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20093 index afa64ad..dce67dd 100644
20094 --- a/arch/x86/kernel/crash_dump_64.c
20095 +++ b/arch/x86/kernel/crash_dump_64.c
20096 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20097 return -ENOMEM;
20098
20099 if (userbuf) {
20100 - if (copy_to_user(buf, vaddr + offset, csize)) {
20101 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20102 iounmap(vaddr);
20103 return -EFAULT;
20104 }
20105 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20106 index 5d3fe8d..02e1429 100644
20107 --- a/arch/x86/kernel/doublefault.c
20108 +++ b/arch/x86/kernel/doublefault.c
20109 @@ -13,7 +13,7 @@
20110
20111 #define DOUBLEFAULT_STACKSIZE (1024)
20112 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20113 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20114 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20115
20116 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20117
20118 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20119 unsigned long gdt, tss;
20120
20121 native_store_gdt(&gdt_desc);
20122 - gdt = gdt_desc.address;
20123 + gdt = (unsigned long)gdt_desc.address;
20124
20125 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20126
20127 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20128 /* 0x2 bit is always set */
20129 .flags = X86_EFLAGS_SF | 0x2,
20130 .sp = STACK_START,
20131 - .es = __USER_DS,
20132 + .es = __KERNEL_DS,
20133 .cs = __KERNEL_CS,
20134 .ss = __KERNEL_DS,
20135 - .ds = __USER_DS,
20136 + .ds = __KERNEL_DS,
20137 .fs = __KERNEL_PERCPU,
20138
20139 .__cr3 = __pa_nodebug(swapper_pg_dir),
20140 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20141 index deb6421..76bbc12 100644
20142 --- a/arch/x86/kernel/dumpstack.c
20143 +++ b/arch/x86/kernel/dumpstack.c
20144 @@ -2,6 +2,9 @@
20145 * Copyright (C) 1991, 1992 Linus Torvalds
20146 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20147 */
20148 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20149 +#define __INCLUDED_BY_HIDESYM 1
20150 +#endif
20151 #include <linux/kallsyms.h>
20152 #include <linux/kprobes.h>
20153 #include <linux/uaccess.h>
20154 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20155 static void
20156 print_ftrace_graph_addr(unsigned long addr, void *data,
20157 const struct stacktrace_ops *ops,
20158 - struct thread_info *tinfo, int *graph)
20159 + struct task_struct *task, int *graph)
20160 {
20161 - struct task_struct *task;
20162 unsigned long ret_addr;
20163 int index;
20164
20165 if (addr != (unsigned long)return_to_handler)
20166 return;
20167
20168 - task = tinfo->task;
20169 index = task->curr_ret_stack;
20170
20171 if (!task->ret_stack || index < *graph)
20172 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20173 static inline void
20174 print_ftrace_graph_addr(unsigned long addr, void *data,
20175 const struct stacktrace_ops *ops,
20176 - struct thread_info *tinfo, int *graph)
20177 + struct task_struct *task, int *graph)
20178 { }
20179 #endif
20180
20181 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20182 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20183 */
20184
20185 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20186 - void *p, unsigned int size, void *end)
20187 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20188 {
20189 - void *t = tinfo;
20190 if (end) {
20191 if (p < end && p >= (end-THREAD_SIZE))
20192 return 1;
20193 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20194 }
20195
20196 unsigned long
20197 -print_context_stack(struct thread_info *tinfo,
20198 +print_context_stack(struct task_struct *task, void *stack_start,
20199 unsigned long *stack, unsigned long bp,
20200 const struct stacktrace_ops *ops, void *data,
20201 unsigned long *end, int *graph)
20202 {
20203 struct stack_frame *frame = (struct stack_frame *)bp;
20204
20205 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20206 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20207 unsigned long addr;
20208
20209 addr = *stack;
20210 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20211 } else {
20212 ops->address(data, addr, 0);
20213 }
20214 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20215 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20216 }
20217 stack++;
20218 }
20219 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20220 EXPORT_SYMBOL_GPL(print_context_stack);
20221
20222 unsigned long
20223 -print_context_stack_bp(struct thread_info *tinfo,
20224 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20225 unsigned long *stack, unsigned long bp,
20226 const struct stacktrace_ops *ops, void *data,
20227 unsigned long *end, int *graph)
20228 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20229 struct stack_frame *frame = (struct stack_frame *)bp;
20230 unsigned long *ret_addr = &frame->return_address;
20231
20232 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20233 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20234 unsigned long addr = *ret_addr;
20235
20236 if (!__kernel_text_address(addr))
20237 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20238 ops->address(data, addr, 1);
20239 frame = frame->next_frame;
20240 ret_addr = &frame->return_address;
20241 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20242 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20243 }
20244
20245 return (unsigned long)frame;
20246 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20247 static void print_trace_address(void *data, unsigned long addr, int reliable)
20248 {
20249 touch_nmi_watchdog();
20250 - printk(data);
20251 + printk("%s", (char *)data);
20252 printk_address(addr, reliable);
20253 }
20254
20255 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20256 }
20257 EXPORT_SYMBOL_GPL(oops_begin);
20258
20259 +extern void gr_handle_kernel_exploit(void);
20260 +
20261 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20262 {
20263 if (regs && kexec_should_crash(current))
20264 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20265 panic("Fatal exception in interrupt");
20266 if (panic_on_oops)
20267 panic("Fatal exception");
20268 - do_exit(signr);
20269 +
20270 + gr_handle_kernel_exploit();
20271 +
20272 + do_group_exit(signr);
20273 }
20274
20275 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20276 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20277 print_modules();
20278 show_regs(regs);
20279 #ifdef CONFIG_X86_32
20280 - if (user_mode_vm(regs)) {
20281 + if (user_mode(regs)) {
20282 sp = regs->sp;
20283 ss = regs->ss & 0xffff;
20284 } else {
20285 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20286 unsigned long flags = oops_begin();
20287 int sig = SIGSEGV;
20288
20289 - if (!user_mode_vm(regs))
20290 + if (!user_mode(regs))
20291 report_bug(regs->ip, regs);
20292
20293 if (__die(str, regs, err))
20294 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20295 index f2a1770..540657f 100644
20296 --- a/arch/x86/kernel/dumpstack_32.c
20297 +++ b/arch/x86/kernel/dumpstack_32.c
20298 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20299 bp = stack_frame(task, regs);
20300
20301 for (;;) {
20302 - struct thread_info *context;
20303 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20304
20305 - context = (struct thread_info *)
20306 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20307 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20308 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20309
20310 - stack = (unsigned long *)context->previous_esp;
20311 - if (!stack)
20312 + if (stack_start == task_stack_page(task))
20313 break;
20314 + stack = *(unsigned long **)stack_start;
20315 if (ops->stack(data, "IRQ") < 0)
20316 break;
20317 touch_nmi_watchdog();
20318 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20319 int i;
20320
20321 show_regs_print_info(KERN_EMERG);
20322 - __show_regs(regs, !user_mode_vm(regs));
20323 + __show_regs(regs, !user_mode(regs));
20324
20325 /*
20326 * When in-kernel, we also print out the stack and code at the
20327 * time of the fault..
20328 */
20329 - if (!user_mode_vm(regs)) {
20330 + if (!user_mode(regs)) {
20331 unsigned int code_prologue = code_bytes * 43 / 64;
20332 unsigned int code_len = code_bytes;
20333 unsigned char c;
20334 u8 *ip;
20335 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20336
20337 pr_emerg("Stack:\n");
20338 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20339
20340 pr_emerg("Code:");
20341
20342 - ip = (u8 *)regs->ip - code_prologue;
20343 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20344 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20345 /* try starting at IP */
20346 - ip = (u8 *)regs->ip;
20347 + ip = (u8 *)regs->ip + cs_base;
20348 code_len = code_len - code_prologue + 1;
20349 }
20350 for (i = 0; i < code_len; i++, ip++) {
20351 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20352 pr_cont(" Bad EIP value.");
20353 break;
20354 }
20355 - if (ip == (u8 *)regs->ip)
20356 + if (ip == (u8 *)regs->ip + cs_base)
20357 pr_cont(" <%02x>", c);
20358 else
20359 pr_cont(" %02x", c);
20360 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20361 {
20362 unsigned short ud2;
20363
20364 + ip = ktla_ktva(ip);
20365 if (ip < PAGE_OFFSET)
20366 return 0;
20367 if (probe_kernel_address((unsigned short *)ip, ud2))
20368 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20369
20370 return ud2 == 0x0b0f;
20371 }
20372 +
20373 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20374 +void pax_check_alloca(unsigned long size)
20375 +{
20376 + unsigned long sp = (unsigned long)&sp, stack_left;
20377 +
20378 + /* all kernel stacks are of the same size */
20379 + stack_left = sp & (THREAD_SIZE - 1);
20380 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20381 +}
20382 +EXPORT_SYMBOL(pax_check_alloca);
20383 +#endif
20384 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20385 index addb207..99635fa 100644
20386 --- a/arch/x86/kernel/dumpstack_64.c
20387 +++ b/arch/x86/kernel/dumpstack_64.c
20388 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20389 unsigned long *irq_stack_end =
20390 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20391 unsigned used = 0;
20392 - struct thread_info *tinfo;
20393 int graph = 0;
20394 unsigned long dummy;
20395 + void *stack_start;
20396
20397 if (!task)
20398 task = current;
20399 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20400 * current stack address. If the stacks consist of nested
20401 * exceptions
20402 */
20403 - tinfo = task_thread_info(task);
20404 for (;;) {
20405 char *id;
20406 unsigned long *estack_end;
20407 +
20408 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20409 &used, &id);
20410
20411 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20412 if (ops->stack(data, id) < 0)
20413 break;
20414
20415 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20416 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20417 data, estack_end, &graph);
20418 ops->stack(data, "<EOE>");
20419 /*
20420 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20421 * second-to-last pointer (index -2 to end) in the
20422 * exception stack:
20423 */
20424 + if ((u16)estack_end[-1] != __KERNEL_DS)
20425 + goto out;
20426 stack = (unsigned long *) estack_end[-2];
20427 continue;
20428 }
20429 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20430 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20431 if (ops->stack(data, "IRQ") < 0)
20432 break;
20433 - bp = ops->walk_stack(tinfo, stack, bp,
20434 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20435 ops, data, irq_stack_end, &graph);
20436 /*
20437 * We link to the next stack (which would be
20438 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20439 /*
20440 * This handles the process stack:
20441 */
20442 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20443 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20444 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20445 +out:
20446 put_cpu();
20447 }
20448 EXPORT_SYMBOL(dump_trace);
20449 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20450
20451 return ud2 == 0x0b0f;
20452 }
20453 +
20454 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20455 +void pax_check_alloca(unsigned long size)
20456 +{
20457 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20458 + unsigned cpu, used;
20459 + char *id;
20460 +
20461 + /* check the process stack first */
20462 + stack_start = (unsigned long)task_stack_page(current);
20463 + stack_end = stack_start + THREAD_SIZE;
20464 + if (likely(stack_start <= sp && sp < stack_end)) {
20465 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20466 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20467 + return;
20468 + }
20469 +
20470 + cpu = get_cpu();
20471 +
20472 + /* check the irq stacks */
20473 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20474 + stack_start = stack_end - IRQ_STACK_SIZE;
20475 + if (stack_start <= sp && sp < stack_end) {
20476 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20477 + put_cpu();
20478 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20479 + return;
20480 + }
20481 +
20482 + /* check the exception stacks */
20483 + used = 0;
20484 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20485 + stack_start = stack_end - EXCEPTION_STKSZ;
20486 + if (stack_end && stack_start <= sp && sp < stack_end) {
20487 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20488 + put_cpu();
20489 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20490 + return;
20491 + }
20492 +
20493 + put_cpu();
20494 +
20495 + /* unknown stack */
20496 + BUG();
20497 +}
20498 +EXPORT_SYMBOL(pax_check_alloca);
20499 +#endif
20500 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20501 index d32abea..74daf4f 100644
20502 --- a/arch/x86/kernel/e820.c
20503 +++ b/arch/x86/kernel/e820.c
20504 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20505
20506 static void early_panic(char *msg)
20507 {
20508 - early_printk(msg);
20509 - panic(msg);
20510 + early_printk("%s", msg);
20511 + panic("%s", msg);
20512 }
20513
20514 static int userdef __initdata;
20515 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20516 index d15f575..d692043 100644
20517 --- a/arch/x86/kernel/early_printk.c
20518 +++ b/arch/x86/kernel/early_printk.c
20519 @@ -7,6 +7,7 @@
20520 #include <linux/pci_regs.h>
20521 #include <linux/pci_ids.h>
20522 #include <linux/errno.h>
20523 +#include <linux/sched.h>
20524 #include <asm/io.h>
20525 #include <asm/processor.h>
20526 #include <asm/fcntl.h>
20527 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20528 index 2cfbc3a..b756682 100644
20529 --- a/arch/x86/kernel/entry_32.S
20530 +++ b/arch/x86/kernel/entry_32.S
20531 @@ -177,13 +177,153 @@
20532 /*CFI_REL_OFFSET gs, PT_GS*/
20533 .endm
20534 .macro SET_KERNEL_GS reg
20535 +
20536 +#ifdef CONFIG_CC_STACKPROTECTOR
20537 movl $(__KERNEL_STACK_CANARY), \reg
20538 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20539 + movl $(__USER_DS), \reg
20540 +#else
20541 + xorl \reg, \reg
20542 +#endif
20543 +
20544 movl \reg, %gs
20545 .endm
20546
20547 #endif /* CONFIG_X86_32_LAZY_GS */
20548
20549 -.macro SAVE_ALL
20550 +.macro pax_enter_kernel
20551 +#ifdef CONFIG_PAX_KERNEXEC
20552 + call pax_enter_kernel
20553 +#endif
20554 +.endm
20555 +
20556 +.macro pax_exit_kernel
20557 +#ifdef CONFIG_PAX_KERNEXEC
20558 + call pax_exit_kernel
20559 +#endif
20560 +.endm
20561 +
20562 +#ifdef CONFIG_PAX_KERNEXEC
20563 +ENTRY(pax_enter_kernel)
20564 +#ifdef CONFIG_PARAVIRT
20565 + pushl %eax
20566 + pushl %ecx
20567 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20568 + mov %eax, %esi
20569 +#else
20570 + mov %cr0, %esi
20571 +#endif
20572 + bts $16, %esi
20573 + jnc 1f
20574 + mov %cs, %esi
20575 + cmp $__KERNEL_CS, %esi
20576 + jz 3f
20577 + ljmp $__KERNEL_CS, $3f
20578 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20579 +2:
20580 +#ifdef CONFIG_PARAVIRT
20581 + mov %esi, %eax
20582 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20583 +#else
20584 + mov %esi, %cr0
20585 +#endif
20586 +3:
20587 +#ifdef CONFIG_PARAVIRT
20588 + popl %ecx
20589 + popl %eax
20590 +#endif
20591 + ret
20592 +ENDPROC(pax_enter_kernel)
20593 +
20594 +ENTRY(pax_exit_kernel)
20595 +#ifdef CONFIG_PARAVIRT
20596 + pushl %eax
20597 + pushl %ecx
20598 +#endif
20599 + mov %cs, %esi
20600 + cmp $__KERNEXEC_KERNEL_CS, %esi
20601 + jnz 2f
20602 +#ifdef CONFIG_PARAVIRT
20603 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20604 + mov %eax, %esi
20605 +#else
20606 + mov %cr0, %esi
20607 +#endif
20608 + btr $16, %esi
20609 + ljmp $__KERNEL_CS, $1f
20610 +1:
20611 +#ifdef CONFIG_PARAVIRT
20612 + mov %esi, %eax
20613 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20614 +#else
20615 + mov %esi, %cr0
20616 +#endif
20617 +2:
20618 +#ifdef CONFIG_PARAVIRT
20619 + popl %ecx
20620 + popl %eax
20621 +#endif
20622 + ret
20623 +ENDPROC(pax_exit_kernel)
20624 +#endif
20625 +
20626 + .macro pax_erase_kstack
20627 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20628 + call pax_erase_kstack
20629 +#endif
20630 + .endm
20631 +
20632 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20633 +/*
20634 + * ebp: thread_info
20635 + */
20636 +ENTRY(pax_erase_kstack)
20637 + pushl %edi
20638 + pushl %ecx
20639 + pushl %eax
20640 +
20641 + mov TI_lowest_stack(%ebp), %edi
20642 + mov $-0xBEEF, %eax
20643 + std
20644 +
20645 +1: mov %edi, %ecx
20646 + and $THREAD_SIZE_asm - 1, %ecx
20647 + shr $2, %ecx
20648 + repne scasl
20649 + jecxz 2f
20650 +
20651 + cmp $2*16, %ecx
20652 + jc 2f
20653 +
20654 + mov $2*16, %ecx
20655 + repe scasl
20656 + jecxz 2f
20657 + jne 1b
20658 +
20659 +2: cld
20660 + mov %esp, %ecx
20661 + sub %edi, %ecx
20662 +
20663 + cmp $THREAD_SIZE_asm, %ecx
20664 + jb 3f
20665 + ud2
20666 +3:
20667 +
20668 + shr $2, %ecx
20669 + rep stosl
20670 +
20671 + mov TI_task_thread_sp0(%ebp), %edi
20672 + sub $128, %edi
20673 + mov %edi, TI_lowest_stack(%ebp)
20674 +
20675 + popl %eax
20676 + popl %ecx
20677 + popl %edi
20678 + ret
20679 +ENDPROC(pax_erase_kstack)
20680 +#endif
20681 +
20682 +.macro __SAVE_ALL _DS
20683 cld
20684 PUSH_GS
20685 pushl_cfi %fs
20686 @@ -206,7 +346,7 @@
20687 CFI_REL_OFFSET ecx, 0
20688 pushl_cfi %ebx
20689 CFI_REL_OFFSET ebx, 0
20690 - movl $(__USER_DS), %edx
20691 + movl $\_DS, %edx
20692 movl %edx, %ds
20693 movl %edx, %es
20694 movl $(__KERNEL_PERCPU), %edx
20695 @@ -214,6 +354,15 @@
20696 SET_KERNEL_GS %edx
20697 .endm
20698
20699 +.macro SAVE_ALL
20700 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20701 + __SAVE_ALL __KERNEL_DS
20702 + pax_enter_kernel
20703 +#else
20704 + __SAVE_ALL __USER_DS
20705 +#endif
20706 +.endm
20707 +
20708 .macro RESTORE_INT_REGS
20709 popl_cfi %ebx
20710 CFI_RESTORE ebx
20711 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20712 popfl_cfi
20713 jmp syscall_exit
20714 CFI_ENDPROC
20715 -END(ret_from_fork)
20716 +ENDPROC(ret_from_fork)
20717
20718 ENTRY(ret_from_kernel_thread)
20719 CFI_STARTPROC
20720 @@ -344,7 +493,15 @@ ret_from_intr:
20721 andl $SEGMENT_RPL_MASK, %eax
20722 #endif
20723 cmpl $USER_RPL, %eax
20724 +
20725 +#ifdef CONFIG_PAX_KERNEXEC
20726 + jae resume_userspace
20727 +
20728 + pax_exit_kernel
20729 + jmp resume_kernel
20730 +#else
20731 jb resume_kernel # not returning to v8086 or userspace
20732 +#endif
20733
20734 ENTRY(resume_userspace)
20735 LOCKDEP_SYS_EXIT
20736 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20737 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20738 # int/exception return?
20739 jne work_pending
20740 - jmp restore_all
20741 -END(ret_from_exception)
20742 + jmp restore_all_pax
20743 +ENDPROC(ret_from_exception)
20744
20745 #ifdef CONFIG_PREEMPT
20746 ENTRY(resume_kernel)
20747 @@ -372,7 +529,7 @@ need_resched:
20748 jz restore_all
20749 call preempt_schedule_irq
20750 jmp need_resched
20751 -END(resume_kernel)
20752 +ENDPROC(resume_kernel)
20753 #endif
20754 CFI_ENDPROC
20755 /*
20756 @@ -406,30 +563,45 @@ sysenter_past_esp:
20757 /*CFI_REL_OFFSET cs, 0*/
20758 /*
20759 * Push current_thread_info()->sysenter_return to the stack.
20760 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20761 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20762 */
20763 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20764 + pushl_cfi $0
20765 CFI_REL_OFFSET eip, 0
20766
20767 pushl_cfi %eax
20768 SAVE_ALL
20769 + GET_THREAD_INFO(%ebp)
20770 + movl TI_sysenter_return(%ebp),%ebp
20771 + movl %ebp,PT_EIP(%esp)
20772 ENABLE_INTERRUPTS(CLBR_NONE)
20773
20774 /*
20775 * Load the potential sixth argument from user stack.
20776 * Careful about security.
20777 */
20778 + movl PT_OLDESP(%esp),%ebp
20779 +
20780 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20781 + mov PT_OLDSS(%esp),%ds
20782 +1: movl %ds:(%ebp),%ebp
20783 + push %ss
20784 + pop %ds
20785 +#else
20786 cmpl $__PAGE_OFFSET-3,%ebp
20787 jae syscall_fault
20788 ASM_STAC
20789 1: movl (%ebp),%ebp
20790 ASM_CLAC
20791 +#endif
20792 +
20793 movl %ebp,PT_EBP(%esp)
20794 _ASM_EXTABLE(1b,syscall_fault)
20795
20796 GET_THREAD_INFO(%ebp)
20797
20798 +#ifdef CONFIG_PAX_RANDKSTACK
20799 + pax_erase_kstack
20800 +#endif
20801 +
20802 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20803 jnz sysenter_audit
20804 sysenter_do_call:
20805 @@ -444,12 +616,24 @@ sysenter_do_call:
20806 testl $_TIF_ALLWORK_MASK, %ecx
20807 jne sysexit_audit
20808 sysenter_exit:
20809 +
20810 +#ifdef CONFIG_PAX_RANDKSTACK
20811 + pushl_cfi %eax
20812 + movl %esp, %eax
20813 + call pax_randomize_kstack
20814 + popl_cfi %eax
20815 +#endif
20816 +
20817 + pax_erase_kstack
20818 +
20819 /* if something modifies registers it must also disable sysexit */
20820 movl PT_EIP(%esp), %edx
20821 movl PT_OLDESP(%esp), %ecx
20822 xorl %ebp,%ebp
20823 TRACE_IRQS_ON
20824 1: mov PT_FS(%esp), %fs
20825 +2: mov PT_DS(%esp), %ds
20826 +3: mov PT_ES(%esp), %es
20827 PTGS_TO_GS
20828 ENABLE_INTERRUPTS_SYSEXIT
20829
20830 @@ -466,6 +650,9 @@ sysenter_audit:
20831 movl %eax,%edx /* 2nd arg: syscall number */
20832 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20833 call __audit_syscall_entry
20834 +
20835 + pax_erase_kstack
20836 +
20837 pushl_cfi %ebx
20838 movl PT_EAX(%esp),%eax /* reload syscall number */
20839 jmp sysenter_do_call
20840 @@ -491,10 +678,16 @@ sysexit_audit:
20841
20842 CFI_ENDPROC
20843 .pushsection .fixup,"ax"
20844 -2: movl $0,PT_FS(%esp)
20845 +4: movl $0,PT_FS(%esp)
20846 + jmp 1b
20847 +5: movl $0,PT_DS(%esp)
20848 + jmp 1b
20849 +6: movl $0,PT_ES(%esp)
20850 jmp 1b
20851 .popsection
20852 - _ASM_EXTABLE(1b,2b)
20853 + _ASM_EXTABLE(1b,4b)
20854 + _ASM_EXTABLE(2b,5b)
20855 + _ASM_EXTABLE(3b,6b)
20856 PTGS_TO_GS_EX
20857 ENDPROC(ia32_sysenter_target)
20858
20859 @@ -509,6 +702,11 @@ ENTRY(system_call)
20860 pushl_cfi %eax # save orig_eax
20861 SAVE_ALL
20862 GET_THREAD_INFO(%ebp)
20863 +
20864 +#ifdef CONFIG_PAX_RANDKSTACK
20865 + pax_erase_kstack
20866 +#endif
20867 +
20868 # system call tracing in operation / emulation
20869 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20870 jnz syscall_trace_entry
20871 @@ -527,6 +725,15 @@ syscall_exit:
20872 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20873 jne syscall_exit_work
20874
20875 +restore_all_pax:
20876 +
20877 +#ifdef CONFIG_PAX_RANDKSTACK
20878 + movl %esp, %eax
20879 + call pax_randomize_kstack
20880 +#endif
20881 +
20882 + pax_erase_kstack
20883 +
20884 restore_all:
20885 TRACE_IRQS_IRET
20886 restore_all_notrace:
20887 @@ -583,14 +790,34 @@ ldt_ss:
20888 * compensating for the offset by changing to the ESPFIX segment with
20889 * a base address that matches for the difference.
20890 */
20891 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20892 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20893 mov %esp, %edx /* load kernel esp */
20894 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20895 mov %dx, %ax /* eax: new kernel esp */
20896 sub %eax, %edx /* offset (low word is 0) */
20897 +#ifdef CONFIG_SMP
20898 + movl PER_CPU_VAR(cpu_number), %ebx
20899 + shll $PAGE_SHIFT_asm, %ebx
20900 + addl $cpu_gdt_table, %ebx
20901 +#else
20902 + movl $cpu_gdt_table, %ebx
20903 +#endif
20904 shr $16, %edx
20905 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20906 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20907 +
20908 +#ifdef CONFIG_PAX_KERNEXEC
20909 + mov %cr0, %esi
20910 + btr $16, %esi
20911 + mov %esi, %cr0
20912 +#endif
20913 +
20914 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20915 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20916 +
20917 +#ifdef CONFIG_PAX_KERNEXEC
20918 + bts $16, %esi
20919 + mov %esi, %cr0
20920 +#endif
20921 +
20922 pushl_cfi $__ESPFIX_SS
20923 pushl_cfi %eax /* new kernel esp */
20924 /* Disable interrupts, but do not irqtrace this section: we
20925 @@ -619,20 +846,18 @@ work_resched:
20926 movl TI_flags(%ebp), %ecx
20927 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20928 # than syscall tracing?
20929 - jz restore_all
20930 + jz restore_all_pax
20931 testb $_TIF_NEED_RESCHED, %cl
20932 jnz work_resched
20933
20934 work_notifysig: # deal with pending signals and
20935 # notify-resume requests
20936 + movl %esp, %eax
20937 #ifdef CONFIG_VM86
20938 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20939 - movl %esp, %eax
20940 jne work_notifysig_v86 # returning to kernel-space or
20941 # vm86-space
20942 1:
20943 -#else
20944 - movl %esp, %eax
20945 #endif
20946 TRACE_IRQS_ON
20947 ENABLE_INTERRUPTS(CLBR_NONE)
20948 @@ -653,7 +878,7 @@ work_notifysig_v86:
20949 movl %eax, %esp
20950 jmp 1b
20951 #endif
20952 -END(work_pending)
20953 +ENDPROC(work_pending)
20954
20955 # perform syscall exit tracing
20956 ALIGN
20957 @@ -661,11 +886,14 @@ syscall_trace_entry:
20958 movl $-ENOSYS,PT_EAX(%esp)
20959 movl %esp, %eax
20960 call syscall_trace_enter
20961 +
20962 + pax_erase_kstack
20963 +
20964 /* What it returned is what we'll actually use. */
20965 cmpl $(NR_syscalls), %eax
20966 jnae syscall_call
20967 jmp syscall_exit
20968 -END(syscall_trace_entry)
20969 +ENDPROC(syscall_trace_entry)
20970
20971 # perform syscall exit tracing
20972 ALIGN
20973 @@ -678,21 +906,25 @@ syscall_exit_work:
20974 movl %esp, %eax
20975 call syscall_trace_leave
20976 jmp resume_userspace
20977 -END(syscall_exit_work)
20978 +ENDPROC(syscall_exit_work)
20979 CFI_ENDPROC
20980
20981 RING0_INT_FRAME # can't unwind into user space anyway
20982 syscall_fault:
20983 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20984 + push %ss
20985 + pop %ds
20986 +#endif
20987 ASM_CLAC
20988 GET_THREAD_INFO(%ebp)
20989 movl $-EFAULT,PT_EAX(%esp)
20990 jmp resume_userspace
20991 -END(syscall_fault)
20992 +ENDPROC(syscall_fault)
20993
20994 syscall_badsys:
20995 movl $-ENOSYS,PT_EAX(%esp)
20996 jmp resume_userspace
20997 -END(syscall_badsys)
20998 +ENDPROC(syscall_badsys)
20999 CFI_ENDPROC
21000 /*
21001 * End of kprobes section
21002 @@ -708,8 +940,15 @@ END(syscall_badsys)
21003 * normal stack and adjusts ESP with the matching offset.
21004 */
21005 /* fixup the stack */
21006 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21007 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21008 +#ifdef CONFIG_SMP
21009 + movl PER_CPU_VAR(cpu_number), %ebx
21010 + shll $PAGE_SHIFT_asm, %ebx
21011 + addl $cpu_gdt_table, %ebx
21012 +#else
21013 + movl $cpu_gdt_table, %ebx
21014 +#endif
21015 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21016 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21017 shl $16, %eax
21018 addl %esp, %eax /* the adjusted stack pointer */
21019 pushl_cfi $__KERNEL_DS
21020 @@ -762,7 +1001,7 @@ vector=vector+1
21021 .endr
21022 2: jmp common_interrupt
21023 .endr
21024 -END(irq_entries_start)
21025 +ENDPROC(irq_entries_start)
21026
21027 .previous
21028 END(interrupt)
21029 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21030 pushl_cfi $do_coprocessor_error
21031 jmp error_code
21032 CFI_ENDPROC
21033 -END(coprocessor_error)
21034 +ENDPROC(coprocessor_error)
21035
21036 ENTRY(simd_coprocessor_error)
21037 RING0_INT_FRAME
21038 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21039 .section .altinstructions,"a"
21040 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21041 .previous
21042 -.section .altinstr_replacement,"ax"
21043 +.section .altinstr_replacement,"a"
21044 663: pushl $do_simd_coprocessor_error
21045 664:
21046 .previous
21047 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21048 #endif
21049 jmp error_code
21050 CFI_ENDPROC
21051 -END(simd_coprocessor_error)
21052 +ENDPROC(simd_coprocessor_error)
21053
21054 ENTRY(device_not_available)
21055 RING0_INT_FRAME
21056 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21057 pushl_cfi $do_device_not_available
21058 jmp error_code
21059 CFI_ENDPROC
21060 -END(device_not_available)
21061 +ENDPROC(device_not_available)
21062
21063 #ifdef CONFIG_PARAVIRT
21064 ENTRY(native_iret)
21065 iret
21066 _ASM_EXTABLE(native_iret, iret_exc)
21067 -END(native_iret)
21068 +ENDPROC(native_iret)
21069
21070 ENTRY(native_irq_enable_sysexit)
21071 sti
21072 sysexit
21073 -END(native_irq_enable_sysexit)
21074 +ENDPROC(native_irq_enable_sysexit)
21075 #endif
21076
21077 ENTRY(overflow)
21078 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21079 pushl_cfi $do_overflow
21080 jmp error_code
21081 CFI_ENDPROC
21082 -END(overflow)
21083 +ENDPROC(overflow)
21084
21085 ENTRY(bounds)
21086 RING0_INT_FRAME
21087 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21088 pushl_cfi $do_bounds
21089 jmp error_code
21090 CFI_ENDPROC
21091 -END(bounds)
21092 +ENDPROC(bounds)
21093
21094 ENTRY(invalid_op)
21095 RING0_INT_FRAME
21096 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21097 pushl_cfi $do_invalid_op
21098 jmp error_code
21099 CFI_ENDPROC
21100 -END(invalid_op)
21101 +ENDPROC(invalid_op)
21102
21103 ENTRY(coprocessor_segment_overrun)
21104 RING0_INT_FRAME
21105 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21106 pushl_cfi $do_coprocessor_segment_overrun
21107 jmp error_code
21108 CFI_ENDPROC
21109 -END(coprocessor_segment_overrun)
21110 +ENDPROC(coprocessor_segment_overrun)
21111
21112 ENTRY(invalid_TSS)
21113 RING0_EC_FRAME
21114 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21115 pushl_cfi $do_invalid_TSS
21116 jmp error_code
21117 CFI_ENDPROC
21118 -END(invalid_TSS)
21119 +ENDPROC(invalid_TSS)
21120
21121 ENTRY(segment_not_present)
21122 RING0_EC_FRAME
21123 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21124 pushl_cfi $do_segment_not_present
21125 jmp error_code
21126 CFI_ENDPROC
21127 -END(segment_not_present)
21128 +ENDPROC(segment_not_present)
21129
21130 ENTRY(stack_segment)
21131 RING0_EC_FRAME
21132 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21133 pushl_cfi $do_stack_segment
21134 jmp error_code
21135 CFI_ENDPROC
21136 -END(stack_segment)
21137 +ENDPROC(stack_segment)
21138
21139 ENTRY(alignment_check)
21140 RING0_EC_FRAME
21141 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21142 pushl_cfi $do_alignment_check
21143 jmp error_code
21144 CFI_ENDPROC
21145 -END(alignment_check)
21146 +ENDPROC(alignment_check)
21147
21148 ENTRY(divide_error)
21149 RING0_INT_FRAME
21150 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21151 pushl_cfi $do_divide_error
21152 jmp error_code
21153 CFI_ENDPROC
21154 -END(divide_error)
21155 +ENDPROC(divide_error)
21156
21157 #ifdef CONFIG_X86_MCE
21158 ENTRY(machine_check)
21159 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21160 pushl_cfi machine_check_vector
21161 jmp error_code
21162 CFI_ENDPROC
21163 -END(machine_check)
21164 +ENDPROC(machine_check)
21165 #endif
21166
21167 ENTRY(spurious_interrupt_bug)
21168 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21169 pushl_cfi $do_spurious_interrupt_bug
21170 jmp error_code
21171 CFI_ENDPROC
21172 -END(spurious_interrupt_bug)
21173 +ENDPROC(spurious_interrupt_bug)
21174 /*
21175 * End of kprobes section
21176 */
21177 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21178
21179 ENTRY(mcount)
21180 ret
21181 -END(mcount)
21182 +ENDPROC(mcount)
21183
21184 ENTRY(ftrace_caller)
21185 cmpl $0, function_trace_stop
21186 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21187 .globl ftrace_stub
21188 ftrace_stub:
21189 ret
21190 -END(ftrace_caller)
21191 +ENDPROC(ftrace_caller)
21192
21193 ENTRY(ftrace_regs_caller)
21194 pushf /* push flags before compare (in cs location) */
21195 @@ -1207,7 +1446,7 @@ trace:
21196 popl %ecx
21197 popl %eax
21198 jmp ftrace_stub
21199 -END(mcount)
21200 +ENDPROC(mcount)
21201 #endif /* CONFIG_DYNAMIC_FTRACE */
21202 #endif /* CONFIG_FUNCTION_TRACER */
21203
21204 @@ -1225,7 +1464,7 @@ ENTRY(ftrace_graph_caller)
21205 popl %ecx
21206 popl %eax
21207 ret
21208 -END(ftrace_graph_caller)
21209 +ENDPROC(ftrace_graph_caller)
21210
21211 .globl return_to_handler
21212 return_to_handler:
21213 @@ -1281,15 +1520,18 @@ error_code:
21214 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21215 REG_TO_PTGS %ecx
21216 SET_KERNEL_GS %ecx
21217 - movl $(__USER_DS), %ecx
21218 + movl $(__KERNEL_DS), %ecx
21219 movl %ecx, %ds
21220 movl %ecx, %es
21221 +
21222 + pax_enter_kernel
21223 +
21224 TRACE_IRQS_OFF
21225 movl %esp,%eax # pt_regs pointer
21226 call *%edi
21227 jmp ret_from_exception
21228 CFI_ENDPROC
21229 -END(page_fault)
21230 +ENDPROC(page_fault)
21231
21232 /*
21233 * Debug traps and NMI can happen at the one SYSENTER instruction
21234 @@ -1332,7 +1574,7 @@ debug_stack_correct:
21235 call do_debug
21236 jmp ret_from_exception
21237 CFI_ENDPROC
21238 -END(debug)
21239 +ENDPROC(debug)
21240
21241 /*
21242 * NMI is doubly nasty. It can happen _while_ we're handling
21243 @@ -1370,6 +1612,9 @@ nmi_stack_correct:
21244 xorl %edx,%edx # zero error code
21245 movl %esp,%eax # pt_regs pointer
21246 call do_nmi
21247 +
21248 + pax_exit_kernel
21249 +
21250 jmp restore_all_notrace
21251 CFI_ENDPROC
21252
21253 @@ -1406,12 +1651,15 @@ nmi_espfix_stack:
21254 FIXUP_ESPFIX_STACK # %eax == %esp
21255 xorl %edx,%edx # zero error code
21256 call do_nmi
21257 +
21258 + pax_exit_kernel
21259 +
21260 RESTORE_REGS
21261 lss 12+4(%esp), %esp # back to espfix stack
21262 CFI_ADJUST_CFA_OFFSET -24
21263 jmp irq_return
21264 CFI_ENDPROC
21265 -END(nmi)
21266 +ENDPROC(nmi)
21267
21268 ENTRY(int3)
21269 RING0_INT_FRAME
21270 @@ -1424,14 +1672,14 @@ ENTRY(int3)
21271 call do_int3
21272 jmp ret_from_exception
21273 CFI_ENDPROC
21274 -END(int3)
21275 +ENDPROC(int3)
21276
21277 ENTRY(general_protection)
21278 RING0_EC_FRAME
21279 pushl_cfi $do_general_protection
21280 jmp error_code
21281 CFI_ENDPROC
21282 -END(general_protection)
21283 +ENDPROC(general_protection)
21284
21285 #ifdef CONFIG_KVM_GUEST
21286 ENTRY(async_page_fault)
21287 @@ -1440,7 +1688,7 @@ ENTRY(async_page_fault)
21288 pushl_cfi $do_async_page_fault
21289 jmp error_code
21290 CFI_ENDPROC
21291 -END(async_page_fault)
21292 +ENDPROC(async_page_fault)
21293 #endif
21294
21295 /*
21296 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21297 index 1b69951..8430a6d 100644
21298 --- a/arch/x86/kernel/entry_64.S
21299 +++ b/arch/x86/kernel/entry_64.S
21300 @@ -59,6 +59,8 @@
21301 #include <asm/context_tracking.h>
21302 #include <asm/smap.h>
21303 #include <linux/err.h>
21304 +#include <asm/pgtable.h>
21305 +#include <asm/alternative-asm.h>
21306
21307 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21308 #include <linux/elf-em.h>
21309 @@ -80,8 +82,9 @@
21310 #ifdef CONFIG_DYNAMIC_FTRACE
21311
21312 ENTRY(function_hook)
21313 + pax_force_retaddr
21314 retq
21315 -END(function_hook)
21316 +ENDPROC(function_hook)
21317
21318 /* skip is set if stack has been adjusted */
21319 .macro ftrace_caller_setup skip=0
21320 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21321 #endif
21322
21323 GLOBAL(ftrace_stub)
21324 + pax_force_retaddr
21325 retq
21326 -END(ftrace_caller)
21327 +ENDPROC(ftrace_caller)
21328
21329 ENTRY(ftrace_regs_caller)
21330 /* Save the current flags before compare (in SS location)*/
21331 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21332 popfq
21333 jmp ftrace_stub
21334
21335 -END(ftrace_regs_caller)
21336 +ENDPROC(ftrace_regs_caller)
21337
21338
21339 #else /* ! CONFIG_DYNAMIC_FTRACE */
21340 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21341 #endif
21342
21343 GLOBAL(ftrace_stub)
21344 + pax_force_retaddr
21345 retq
21346
21347 trace:
21348 @@ -225,12 +230,13 @@ trace:
21349 #endif
21350 subq $MCOUNT_INSN_SIZE, %rdi
21351
21352 + pax_force_fptr ftrace_trace_function
21353 call *ftrace_trace_function
21354
21355 MCOUNT_RESTORE_FRAME
21356
21357 jmp ftrace_stub
21358 -END(function_hook)
21359 +ENDPROC(function_hook)
21360 #endif /* CONFIG_DYNAMIC_FTRACE */
21361 #endif /* CONFIG_FUNCTION_TRACER */
21362
21363 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21364
21365 MCOUNT_RESTORE_FRAME
21366
21367 + pax_force_retaddr
21368 retq
21369 -END(ftrace_graph_caller)
21370 +ENDPROC(ftrace_graph_caller)
21371
21372 GLOBAL(return_to_handler)
21373 subq $24, %rsp
21374 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21375 movq 8(%rsp), %rdx
21376 movq (%rsp), %rax
21377 addq $24, %rsp
21378 + pax_force_fptr %rdi
21379 jmp *%rdi
21380 +ENDPROC(return_to_handler)
21381 #endif
21382
21383
21384 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21385 ENDPROC(native_usergs_sysret64)
21386 #endif /* CONFIG_PARAVIRT */
21387
21388 + .macro ljmpq sel, off
21389 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21390 + .byte 0x48; ljmp *1234f(%rip)
21391 + .pushsection .rodata
21392 + .align 16
21393 + 1234: .quad \off; .word \sel
21394 + .popsection
21395 +#else
21396 + pushq $\sel
21397 + pushq $\off
21398 + lretq
21399 +#endif
21400 + .endm
21401 +
21402 + .macro pax_enter_kernel
21403 + pax_set_fptr_mask
21404 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21405 + call pax_enter_kernel
21406 +#endif
21407 + .endm
21408 +
21409 + .macro pax_exit_kernel
21410 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21411 + call pax_exit_kernel
21412 +#endif
21413 +
21414 + .endm
21415 +
21416 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21417 +ENTRY(pax_enter_kernel)
21418 + pushq %rdi
21419 +
21420 +#ifdef CONFIG_PARAVIRT
21421 + PV_SAVE_REGS(CLBR_RDI)
21422 +#endif
21423 +
21424 +#ifdef CONFIG_PAX_KERNEXEC
21425 + GET_CR0_INTO_RDI
21426 + bts $16,%rdi
21427 + jnc 3f
21428 + mov %cs,%edi
21429 + cmp $__KERNEL_CS,%edi
21430 + jnz 2f
21431 +1:
21432 +#endif
21433 +
21434 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21435 + 661: jmp 111f
21436 + .pushsection .altinstr_replacement, "a"
21437 + 662: ASM_NOP2
21438 + .popsection
21439 + .pushsection .altinstructions, "a"
21440 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21441 + .popsection
21442 + GET_CR3_INTO_RDI
21443 + cmp $0,%dil
21444 + jnz 112f
21445 + mov $__KERNEL_DS,%edi
21446 + mov %edi,%ss
21447 + jmp 111f
21448 +112: cmp $1,%dil
21449 + jz 113f
21450 + ud2
21451 +113: sub $4097,%rdi
21452 + bts $63,%rdi
21453 + SET_RDI_INTO_CR3
21454 + mov $__UDEREF_KERNEL_DS,%edi
21455 + mov %edi,%ss
21456 +111:
21457 +#endif
21458 +
21459 +#ifdef CONFIG_PARAVIRT
21460 + PV_RESTORE_REGS(CLBR_RDI)
21461 +#endif
21462 +
21463 + popq %rdi
21464 + pax_force_retaddr
21465 + retq
21466 +
21467 +#ifdef CONFIG_PAX_KERNEXEC
21468 +2: ljmpq __KERNEL_CS,1b
21469 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21470 +4: SET_RDI_INTO_CR0
21471 + jmp 1b
21472 +#endif
21473 +ENDPROC(pax_enter_kernel)
21474 +
21475 +ENTRY(pax_exit_kernel)
21476 + pushq %rdi
21477 +
21478 +#ifdef CONFIG_PARAVIRT
21479 + PV_SAVE_REGS(CLBR_RDI)
21480 +#endif
21481 +
21482 +#ifdef CONFIG_PAX_KERNEXEC
21483 + mov %cs,%rdi
21484 + cmp $__KERNEXEC_KERNEL_CS,%edi
21485 + jz 2f
21486 + GET_CR0_INTO_RDI
21487 + bts $16,%rdi
21488 + jnc 4f
21489 +1:
21490 +#endif
21491 +
21492 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21493 + 661: jmp 111f
21494 + .pushsection .altinstr_replacement, "a"
21495 + 662: ASM_NOP2
21496 + .popsection
21497 + .pushsection .altinstructions, "a"
21498 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21499 + .popsection
21500 + mov %ss,%edi
21501 + cmp $__UDEREF_KERNEL_DS,%edi
21502 + jnz 111f
21503 + GET_CR3_INTO_RDI
21504 + cmp $0,%dil
21505 + jz 112f
21506 + ud2
21507 +112: add $4097,%rdi
21508 + bts $63,%rdi
21509 + SET_RDI_INTO_CR3
21510 + mov $__KERNEL_DS,%edi
21511 + mov %edi,%ss
21512 +111:
21513 +#endif
21514 +
21515 +#ifdef CONFIG_PARAVIRT
21516 + PV_RESTORE_REGS(CLBR_RDI);
21517 +#endif
21518 +
21519 + popq %rdi
21520 + pax_force_retaddr
21521 + retq
21522 +
21523 +#ifdef CONFIG_PAX_KERNEXEC
21524 +2: GET_CR0_INTO_RDI
21525 + btr $16,%rdi
21526 + jnc 4f
21527 + ljmpq __KERNEL_CS,3f
21528 +3: SET_RDI_INTO_CR0
21529 + jmp 1b
21530 +4: ud2
21531 + jmp 4b
21532 +#endif
21533 +ENDPROC(pax_exit_kernel)
21534 +#endif
21535 +
21536 + .macro pax_enter_kernel_user
21537 + pax_set_fptr_mask
21538 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21539 + call pax_enter_kernel_user
21540 +#endif
21541 + .endm
21542 +
21543 + .macro pax_exit_kernel_user
21544 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21545 + call pax_exit_kernel_user
21546 +#endif
21547 +#ifdef CONFIG_PAX_RANDKSTACK
21548 + pushq %rax
21549 + pushq %r11
21550 + call pax_randomize_kstack
21551 + popq %r11
21552 + popq %rax
21553 +#endif
21554 + .endm
21555 +
21556 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21557 +ENTRY(pax_enter_kernel_user)
21558 + pushq %rdi
21559 + pushq %rbx
21560 +
21561 +#ifdef CONFIG_PARAVIRT
21562 + PV_SAVE_REGS(CLBR_RDI)
21563 +#endif
21564 +
21565 + 661: jmp 111f
21566 + .pushsection .altinstr_replacement, "a"
21567 + 662: ASM_NOP2
21568 + .popsection
21569 + .pushsection .altinstructions, "a"
21570 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21571 + .popsection
21572 + GET_CR3_INTO_RDI
21573 + cmp $1,%dil
21574 + jnz 4f
21575 + sub $4097,%rdi
21576 + bts $63,%rdi
21577 + SET_RDI_INTO_CR3
21578 + jmp 3f
21579 +111:
21580 +
21581 + GET_CR3_INTO_RDI
21582 + mov %rdi,%rbx
21583 + add $__START_KERNEL_map,%rbx
21584 + sub phys_base(%rip),%rbx
21585 +
21586 +#ifdef CONFIG_PARAVIRT
21587 + cmpl $0, pv_info+PARAVIRT_enabled
21588 + jz 1f
21589 + pushq %rdi
21590 + i = 0
21591 + .rept USER_PGD_PTRS
21592 + mov i*8(%rbx),%rsi
21593 + mov $0,%sil
21594 + lea i*8(%rbx),%rdi
21595 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21596 + i = i + 1
21597 + .endr
21598 + popq %rdi
21599 + jmp 2f
21600 +1:
21601 +#endif
21602 +
21603 + i = 0
21604 + .rept USER_PGD_PTRS
21605 + movb $0,i*8(%rbx)
21606 + i = i + 1
21607 + .endr
21608 +
21609 +2: SET_RDI_INTO_CR3
21610 +
21611 +#ifdef CONFIG_PAX_KERNEXEC
21612 + GET_CR0_INTO_RDI
21613 + bts $16,%rdi
21614 + SET_RDI_INTO_CR0
21615 +#endif
21616 +
21617 +3:
21618 +
21619 +#ifdef CONFIG_PARAVIRT
21620 + PV_RESTORE_REGS(CLBR_RDI)
21621 +#endif
21622 +
21623 + popq %rbx
21624 + popq %rdi
21625 + pax_force_retaddr
21626 + retq
21627 +4: ud2
21628 +ENDPROC(pax_enter_kernel_user)
21629 +
21630 +ENTRY(pax_exit_kernel_user)
21631 + pushq %rdi
21632 + pushq %rbx
21633 +
21634 +#ifdef CONFIG_PARAVIRT
21635 + PV_SAVE_REGS(CLBR_RDI)
21636 +#endif
21637 +
21638 + GET_CR3_INTO_RDI
21639 + 661: jmp 1f
21640 + .pushsection .altinstr_replacement, "a"
21641 + 662: ASM_NOP2
21642 + .popsection
21643 + .pushsection .altinstructions, "a"
21644 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21645 + .popsection
21646 + cmp $0,%dil
21647 + jnz 3f
21648 + add $4097,%rdi
21649 + bts $63,%rdi
21650 + SET_RDI_INTO_CR3
21651 + jmp 2f
21652 +1:
21653 +
21654 + mov %rdi,%rbx
21655 +
21656 +#ifdef CONFIG_PAX_KERNEXEC
21657 + GET_CR0_INTO_RDI
21658 + btr $16,%rdi
21659 + jnc 3f
21660 + SET_RDI_INTO_CR0
21661 +#endif
21662 +
21663 + add $__START_KERNEL_map,%rbx
21664 + sub phys_base(%rip),%rbx
21665 +
21666 +#ifdef CONFIG_PARAVIRT
21667 + cmpl $0, pv_info+PARAVIRT_enabled
21668 + jz 1f
21669 + i = 0
21670 + .rept USER_PGD_PTRS
21671 + mov i*8(%rbx),%rsi
21672 + mov $0x67,%sil
21673 + lea i*8(%rbx),%rdi
21674 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21675 + i = i + 1
21676 + .endr
21677 + jmp 2f
21678 +1:
21679 +#endif
21680 +
21681 + i = 0
21682 + .rept USER_PGD_PTRS
21683 + movb $0x67,i*8(%rbx)
21684 + i = i + 1
21685 + .endr
21686 +2:
21687 +
21688 +#ifdef CONFIG_PARAVIRT
21689 + PV_RESTORE_REGS(CLBR_RDI)
21690 +#endif
21691 +
21692 + popq %rbx
21693 + popq %rdi
21694 + pax_force_retaddr
21695 + retq
21696 +3: ud2
21697 +ENDPROC(pax_exit_kernel_user)
21698 +#endif
21699 +
21700 + .macro pax_enter_kernel_nmi
21701 + pax_set_fptr_mask
21702 +
21703 +#ifdef CONFIG_PAX_KERNEXEC
21704 + GET_CR0_INTO_RDI
21705 + bts $16,%rdi
21706 + jc 110f
21707 + SET_RDI_INTO_CR0
21708 + or $2,%ebx
21709 +110:
21710 +#endif
21711 +
21712 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21713 + 661: jmp 111f
21714 + .pushsection .altinstr_replacement, "a"
21715 + 662: ASM_NOP2
21716 + .popsection
21717 + .pushsection .altinstructions, "a"
21718 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21719 + .popsection
21720 + GET_CR3_INTO_RDI
21721 + cmp $0,%dil
21722 + jz 111f
21723 + sub $4097,%rdi
21724 + or $4,%ebx
21725 + bts $63,%rdi
21726 + SET_RDI_INTO_CR3
21727 + mov $__UDEREF_KERNEL_DS,%edi
21728 + mov %edi,%ss
21729 +111:
21730 +#endif
21731 + .endm
21732 +
21733 + .macro pax_exit_kernel_nmi
21734 +#ifdef CONFIG_PAX_KERNEXEC
21735 + btr $1,%ebx
21736 + jnc 110f
21737 + GET_CR0_INTO_RDI
21738 + btr $16,%rdi
21739 + SET_RDI_INTO_CR0
21740 +110:
21741 +#endif
21742 +
21743 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21744 + btr $2,%ebx
21745 + jnc 111f
21746 + GET_CR3_INTO_RDI
21747 + add $4097,%rdi
21748 + bts $63,%rdi
21749 + SET_RDI_INTO_CR3
21750 + mov $__KERNEL_DS,%edi
21751 + mov %edi,%ss
21752 +111:
21753 +#endif
21754 + .endm
21755 +
21756 + .macro pax_erase_kstack
21757 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21758 + call pax_erase_kstack
21759 +#endif
21760 + .endm
21761 +
21762 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21763 +ENTRY(pax_erase_kstack)
21764 + pushq %rdi
21765 + pushq %rcx
21766 + pushq %rax
21767 + pushq %r11
21768 +
21769 + GET_THREAD_INFO(%r11)
21770 + mov TI_lowest_stack(%r11), %rdi
21771 + mov $-0xBEEF, %rax
21772 + std
21773 +
21774 +1: mov %edi, %ecx
21775 + and $THREAD_SIZE_asm - 1, %ecx
21776 + shr $3, %ecx
21777 + repne scasq
21778 + jecxz 2f
21779 +
21780 + cmp $2*8, %ecx
21781 + jc 2f
21782 +
21783 + mov $2*8, %ecx
21784 + repe scasq
21785 + jecxz 2f
21786 + jne 1b
21787 +
21788 +2: cld
21789 + mov %esp, %ecx
21790 + sub %edi, %ecx
21791 +
21792 + cmp $THREAD_SIZE_asm, %rcx
21793 + jb 3f
21794 + ud2
21795 +3:
21796 +
21797 + shr $3, %ecx
21798 + rep stosq
21799 +
21800 + mov TI_task_thread_sp0(%r11), %rdi
21801 + sub $256, %rdi
21802 + mov %rdi, TI_lowest_stack(%r11)
21803 +
21804 + popq %r11
21805 + popq %rax
21806 + popq %rcx
21807 + popq %rdi
21808 + pax_force_retaddr
21809 + ret
21810 +ENDPROC(pax_erase_kstack)
21811 +#endif
21812
21813 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21814 #ifdef CONFIG_TRACE_IRQFLAGS
21815 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21816 .endm
21817
21818 .macro UNFAKE_STACK_FRAME
21819 - addq $8*6, %rsp
21820 - CFI_ADJUST_CFA_OFFSET -(6*8)
21821 + addq $8*6 + ARG_SKIP, %rsp
21822 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21823 .endm
21824
21825 /*
21826 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21827 movq %rsp, %rsi
21828
21829 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21830 - testl $3, CS-RBP(%rsi)
21831 + testb $3, CS-RBP(%rsi)
21832 je 1f
21833 SWAPGS
21834 /*
21835 @@ -498,9 +931,10 @@ ENTRY(save_rest)
21836 movq_cfi r15, R15+16
21837 movq %r11, 8(%rsp) /* return address */
21838 FIXUP_TOP_OF_STACK %r11, 16
21839 + pax_force_retaddr
21840 ret
21841 CFI_ENDPROC
21842 -END(save_rest)
21843 +ENDPROC(save_rest)
21844
21845 /* save complete stack frame */
21846 .pushsection .kprobes.text, "ax"
21847 @@ -529,9 +963,10 @@ ENTRY(save_paranoid)
21848 js 1f /* negative -> in kernel */
21849 SWAPGS
21850 xorl %ebx,%ebx
21851 -1: ret
21852 +1: pax_force_retaddr_bts
21853 + ret
21854 CFI_ENDPROC
21855 -END(save_paranoid)
21856 +ENDPROC(save_paranoid)
21857 .popsection
21858
21859 /*
21860 @@ -553,7 +988,7 @@ ENTRY(ret_from_fork)
21861
21862 RESTORE_REST
21863
21864 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21865 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21866 jz 1f
21867
21868 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21869 @@ -571,7 +1006,7 @@ ENTRY(ret_from_fork)
21870 RESTORE_REST
21871 jmp int_ret_from_sys_call
21872 CFI_ENDPROC
21873 -END(ret_from_fork)
21874 +ENDPROC(ret_from_fork)
21875
21876 /*
21877 * System call entry. Up to 6 arguments in registers are supported.
21878 @@ -608,7 +1043,7 @@ END(ret_from_fork)
21879 ENTRY(system_call)
21880 CFI_STARTPROC simple
21881 CFI_SIGNAL_FRAME
21882 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21883 + CFI_DEF_CFA rsp,0
21884 CFI_REGISTER rip,rcx
21885 /*CFI_REGISTER rflags,r11*/
21886 SWAPGS_UNSAFE_STACK
21887 @@ -621,16 +1056,23 @@ GLOBAL(system_call_after_swapgs)
21888
21889 movq %rsp,PER_CPU_VAR(old_rsp)
21890 movq PER_CPU_VAR(kernel_stack),%rsp
21891 + SAVE_ARGS 8*6,0
21892 + pax_enter_kernel_user
21893 +
21894 +#ifdef CONFIG_PAX_RANDKSTACK
21895 + pax_erase_kstack
21896 +#endif
21897 +
21898 /*
21899 * No need to follow this irqs off/on section - it's straight
21900 * and short:
21901 */
21902 ENABLE_INTERRUPTS(CLBR_NONE)
21903 - SAVE_ARGS 8,0
21904 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21905 movq %rcx,RIP-ARGOFFSET(%rsp)
21906 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21907 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21908 + GET_THREAD_INFO(%rcx)
21909 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21910 jnz tracesys
21911 system_call_fastpath:
21912 #if __SYSCALL_MASK == ~0
21913 @@ -640,7 +1082,7 @@ system_call_fastpath:
21914 cmpl $__NR_syscall_max,%eax
21915 #endif
21916 ja badsys
21917 - movq %r10,%rcx
21918 + movq R10-ARGOFFSET(%rsp),%rcx
21919 call *sys_call_table(,%rax,8) # XXX: rip relative
21920 movq %rax,RAX-ARGOFFSET(%rsp)
21921 /*
21922 @@ -654,10 +1096,13 @@ sysret_check:
21923 LOCKDEP_SYS_EXIT
21924 DISABLE_INTERRUPTS(CLBR_NONE)
21925 TRACE_IRQS_OFF
21926 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21927 + GET_THREAD_INFO(%rcx)
21928 + movl TI_flags(%rcx),%edx
21929 andl %edi,%edx
21930 jnz sysret_careful
21931 CFI_REMEMBER_STATE
21932 + pax_exit_kernel_user
21933 + pax_erase_kstack
21934 /*
21935 * sysretq will re-enable interrupts:
21936 */
21937 @@ -709,14 +1154,18 @@ badsys:
21938 * jump back to the normal fast path.
21939 */
21940 auditsys:
21941 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21942 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21943 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21944 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21945 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21946 movq %rax,%rsi /* 2nd arg: syscall number */
21947 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21948 call __audit_syscall_entry
21949 +
21950 + pax_erase_kstack
21951 +
21952 LOAD_ARGS 0 /* reload call-clobbered registers */
21953 + pax_set_fptr_mask
21954 jmp system_call_fastpath
21955
21956 /*
21957 @@ -737,7 +1186,7 @@ sysret_audit:
21958 /* Do syscall tracing */
21959 tracesys:
21960 #ifdef CONFIG_AUDITSYSCALL
21961 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21962 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21963 jz auditsys
21964 #endif
21965 SAVE_REST
21966 @@ -745,12 +1194,16 @@ tracesys:
21967 FIXUP_TOP_OF_STACK %rdi
21968 movq %rsp,%rdi
21969 call syscall_trace_enter
21970 +
21971 + pax_erase_kstack
21972 +
21973 /*
21974 * Reload arg registers from stack in case ptrace changed them.
21975 * We don't reload %rax because syscall_trace_enter() returned
21976 * the value it wants us to use in the table lookup.
21977 */
21978 LOAD_ARGS ARGOFFSET, 1
21979 + pax_set_fptr_mask
21980 RESTORE_REST
21981 #if __SYSCALL_MASK == ~0
21982 cmpq $__NR_syscall_max,%rax
21983 @@ -759,7 +1212,7 @@ tracesys:
21984 cmpl $__NR_syscall_max,%eax
21985 #endif
21986 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21987 - movq %r10,%rcx /* fixup for C */
21988 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21989 call *sys_call_table(,%rax,8)
21990 movq %rax,RAX-ARGOFFSET(%rsp)
21991 /* Use IRET because user could have changed frame */
21992 @@ -780,7 +1233,9 @@ GLOBAL(int_with_check)
21993 andl %edi,%edx
21994 jnz int_careful
21995 andl $~TS_COMPAT,TI_status(%rcx)
21996 - jmp retint_swapgs
21997 + pax_exit_kernel_user
21998 + pax_erase_kstack
21999 + jmp retint_swapgs_pax
22000
22001 /* Either reschedule or signal or syscall exit tracking needed. */
22002 /* First do a reschedule test. */
22003 @@ -826,7 +1281,7 @@ int_restore_rest:
22004 TRACE_IRQS_OFF
22005 jmp int_with_check
22006 CFI_ENDPROC
22007 -END(system_call)
22008 +ENDPROC(system_call)
22009
22010 .macro FORK_LIKE func
22011 ENTRY(stub_\func)
22012 @@ -839,9 +1294,10 @@ ENTRY(stub_\func)
22013 DEFAULT_FRAME 0 8 /* offset 8: return address */
22014 call sys_\func
22015 RESTORE_TOP_OF_STACK %r11, 8
22016 + pax_force_retaddr
22017 ret $REST_SKIP /* pop extended registers */
22018 CFI_ENDPROC
22019 -END(stub_\func)
22020 +ENDPROC(stub_\func)
22021 .endm
22022
22023 .macro FIXED_FRAME label,func
22024 @@ -851,9 +1307,10 @@ ENTRY(\label)
22025 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22026 call \func
22027 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22028 + pax_force_retaddr
22029 ret
22030 CFI_ENDPROC
22031 -END(\label)
22032 +ENDPROC(\label)
22033 .endm
22034
22035 FORK_LIKE clone
22036 @@ -870,9 +1327,10 @@ ENTRY(ptregscall_common)
22037 movq_cfi_restore R12+8, r12
22038 movq_cfi_restore RBP+8, rbp
22039 movq_cfi_restore RBX+8, rbx
22040 + pax_force_retaddr
22041 ret $REST_SKIP /* pop extended registers */
22042 CFI_ENDPROC
22043 -END(ptregscall_common)
22044 +ENDPROC(ptregscall_common)
22045
22046 ENTRY(stub_execve)
22047 CFI_STARTPROC
22048 @@ -885,7 +1343,7 @@ ENTRY(stub_execve)
22049 RESTORE_REST
22050 jmp int_ret_from_sys_call
22051 CFI_ENDPROC
22052 -END(stub_execve)
22053 +ENDPROC(stub_execve)
22054
22055 /*
22056 * sigreturn is special because it needs to restore all registers on return.
22057 @@ -902,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
22058 RESTORE_REST
22059 jmp int_ret_from_sys_call
22060 CFI_ENDPROC
22061 -END(stub_rt_sigreturn)
22062 +ENDPROC(stub_rt_sigreturn)
22063
22064 #ifdef CONFIG_X86_X32_ABI
22065 ENTRY(stub_x32_rt_sigreturn)
22066 @@ -916,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
22067 RESTORE_REST
22068 jmp int_ret_from_sys_call
22069 CFI_ENDPROC
22070 -END(stub_x32_rt_sigreturn)
22071 +ENDPROC(stub_x32_rt_sigreturn)
22072
22073 ENTRY(stub_x32_execve)
22074 CFI_STARTPROC
22075 @@ -930,7 +1388,7 @@ ENTRY(stub_x32_execve)
22076 RESTORE_REST
22077 jmp int_ret_from_sys_call
22078 CFI_ENDPROC
22079 -END(stub_x32_execve)
22080 +ENDPROC(stub_x32_execve)
22081
22082 #endif
22083
22084 @@ -967,7 +1425,7 @@ vector=vector+1
22085 2: jmp common_interrupt
22086 .endr
22087 CFI_ENDPROC
22088 -END(irq_entries_start)
22089 +ENDPROC(irq_entries_start)
22090
22091 .previous
22092 END(interrupt)
22093 @@ -987,6 +1445,16 @@ END(interrupt)
22094 subq $ORIG_RAX-RBP, %rsp
22095 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22096 SAVE_ARGS_IRQ
22097 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22098 + testb $3, CS(%rdi)
22099 + jnz 1f
22100 + pax_enter_kernel
22101 + jmp 2f
22102 +1: pax_enter_kernel_user
22103 +2:
22104 +#else
22105 + pax_enter_kernel
22106 +#endif
22107 call \func
22108 .endm
22109
22110 @@ -1019,7 +1487,7 @@ ret_from_intr:
22111
22112 exit_intr:
22113 GET_THREAD_INFO(%rcx)
22114 - testl $3,CS-ARGOFFSET(%rsp)
22115 + testb $3,CS-ARGOFFSET(%rsp)
22116 je retint_kernel
22117
22118 /* Interrupt came from user space */
22119 @@ -1041,12 +1509,16 @@ retint_swapgs: /* return to user-space */
22120 * The iretq could re-enable interrupts:
22121 */
22122 DISABLE_INTERRUPTS(CLBR_ANY)
22123 + pax_exit_kernel_user
22124 +retint_swapgs_pax:
22125 TRACE_IRQS_IRETQ
22126 SWAPGS
22127 jmp restore_args
22128
22129 retint_restore_args: /* return to kernel space */
22130 DISABLE_INTERRUPTS(CLBR_ANY)
22131 + pax_exit_kernel
22132 + pax_force_retaddr (RIP-ARGOFFSET)
22133 /*
22134 * The iretq could re-enable interrupts:
22135 */
22136 @@ -1129,7 +1601,7 @@ ENTRY(retint_kernel)
22137 #endif
22138
22139 CFI_ENDPROC
22140 -END(common_interrupt)
22141 +ENDPROC(common_interrupt)
22142 /*
22143 * End of kprobes section
22144 */
22145 @@ -1147,7 +1619,7 @@ ENTRY(\sym)
22146 interrupt \do_sym
22147 jmp ret_from_intr
22148 CFI_ENDPROC
22149 -END(\sym)
22150 +ENDPROC(\sym)
22151 .endm
22152
22153 #ifdef CONFIG_TRACING
22154 @@ -1230,12 +1702,22 @@ ENTRY(\sym)
22155 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22156 call error_entry
22157 DEFAULT_FRAME 0
22158 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22159 + testb $3, CS(%rsp)
22160 + jnz 1f
22161 + pax_enter_kernel
22162 + jmp 2f
22163 +1: pax_enter_kernel_user
22164 +2:
22165 +#else
22166 + pax_enter_kernel
22167 +#endif
22168 movq %rsp,%rdi /* pt_regs pointer */
22169 xorl %esi,%esi /* no error code */
22170 call \do_sym
22171 jmp error_exit /* %ebx: no swapgs flag */
22172 CFI_ENDPROC
22173 -END(\sym)
22174 +ENDPROC(\sym)
22175 .endm
22176
22177 .macro paranoidzeroentry sym do_sym
22178 @@ -1248,15 +1730,25 @@ ENTRY(\sym)
22179 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22180 call save_paranoid
22181 TRACE_IRQS_OFF
22182 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22183 + testb $3, CS(%rsp)
22184 + jnz 1f
22185 + pax_enter_kernel
22186 + jmp 2f
22187 +1: pax_enter_kernel_user
22188 +2:
22189 +#else
22190 + pax_enter_kernel
22191 +#endif
22192 movq %rsp,%rdi /* pt_regs pointer */
22193 xorl %esi,%esi /* no error code */
22194 call \do_sym
22195 jmp paranoid_exit /* %ebx: no swapgs flag */
22196 CFI_ENDPROC
22197 -END(\sym)
22198 +ENDPROC(\sym)
22199 .endm
22200
22201 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22202 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22203 .macro paranoidzeroentry_ist sym do_sym ist
22204 ENTRY(\sym)
22205 INTR_FRAME
22206 @@ -1267,14 +1759,30 @@ ENTRY(\sym)
22207 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22208 call save_paranoid
22209 TRACE_IRQS_OFF_DEBUG
22210 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22211 + testb $3, CS(%rsp)
22212 + jnz 1f
22213 + pax_enter_kernel
22214 + jmp 2f
22215 +1: pax_enter_kernel_user
22216 +2:
22217 +#else
22218 + pax_enter_kernel
22219 +#endif
22220 movq %rsp,%rdi /* pt_regs pointer */
22221 xorl %esi,%esi /* no error code */
22222 +#ifdef CONFIG_SMP
22223 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22224 + lea init_tss(%r12), %r12
22225 +#else
22226 + lea init_tss(%rip), %r12
22227 +#endif
22228 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22229 call \do_sym
22230 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22231 jmp paranoid_exit /* %ebx: no swapgs flag */
22232 CFI_ENDPROC
22233 -END(\sym)
22234 +ENDPROC(\sym)
22235 .endm
22236
22237 .macro errorentry sym do_sym
22238 @@ -1286,13 +1794,23 @@ ENTRY(\sym)
22239 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22240 call error_entry
22241 DEFAULT_FRAME 0
22242 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22243 + testb $3, CS(%rsp)
22244 + jnz 1f
22245 + pax_enter_kernel
22246 + jmp 2f
22247 +1: pax_enter_kernel_user
22248 +2:
22249 +#else
22250 + pax_enter_kernel
22251 +#endif
22252 movq %rsp,%rdi /* pt_regs pointer */
22253 movq ORIG_RAX(%rsp),%rsi /* get error code */
22254 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22255 call \do_sym
22256 jmp error_exit /* %ebx: no swapgs flag */
22257 CFI_ENDPROC
22258 -END(\sym)
22259 +ENDPROC(\sym)
22260 .endm
22261
22262 /* error code is on the stack already */
22263 @@ -1306,13 +1824,23 @@ ENTRY(\sym)
22264 call save_paranoid
22265 DEFAULT_FRAME 0
22266 TRACE_IRQS_OFF
22267 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22268 + testb $3, CS(%rsp)
22269 + jnz 1f
22270 + pax_enter_kernel
22271 + jmp 2f
22272 +1: pax_enter_kernel_user
22273 +2:
22274 +#else
22275 + pax_enter_kernel
22276 +#endif
22277 movq %rsp,%rdi /* pt_regs pointer */
22278 movq ORIG_RAX(%rsp),%rsi /* get error code */
22279 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22280 call \do_sym
22281 jmp paranoid_exit /* %ebx: no swapgs flag */
22282 CFI_ENDPROC
22283 -END(\sym)
22284 +ENDPROC(\sym)
22285 .endm
22286
22287 zeroentry divide_error do_divide_error
22288 @@ -1342,9 +1870,10 @@ gs_change:
22289 2: mfence /* workaround */
22290 SWAPGS
22291 popfq_cfi
22292 + pax_force_retaddr
22293 ret
22294 CFI_ENDPROC
22295 -END(native_load_gs_index)
22296 +ENDPROC(native_load_gs_index)
22297
22298 _ASM_EXTABLE(gs_change,bad_gs)
22299 .section .fixup,"ax"
22300 @@ -1372,9 +1901,10 @@ ENTRY(call_softirq)
22301 CFI_DEF_CFA_REGISTER rsp
22302 CFI_ADJUST_CFA_OFFSET -8
22303 decl PER_CPU_VAR(irq_count)
22304 + pax_force_retaddr
22305 ret
22306 CFI_ENDPROC
22307 -END(call_softirq)
22308 +ENDPROC(call_softirq)
22309
22310 #ifdef CONFIG_XEN
22311 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22312 @@ -1412,7 +1942,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22313 decl PER_CPU_VAR(irq_count)
22314 jmp error_exit
22315 CFI_ENDPROC
22316 -END(xen_do_hypervisor_callback)
22317 +ENDPROC(xen_do_hypervisor_callback)
22318
22319 /*
22320 * Hypervisor uses this for application faults while it executes.
22321 @@ -1471,7 +2001,7 @@ ENTRY(xen_failsafe_callback)
22322 SAVE_ALL
22323 jmp error_exit
22324 CFI_ENDPROC
22325 -END(xen_failsafe_callback)
22326 +ENDPROC(xen_failsafe_callback)
22327
22328 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22329 xen_hvm_callback_vector xen_evtchn_do_upcall
22330 @@ -1523,18 +2053,33 @@ ENTRY(paranoid_exit)
22331 DEFAULT_FRAME
22332 DISABLE_INTERRUPTS(CLBR_NONE)
22333 TRACE_IRQS_OFF_DEBUG
22334 - testl %ebx,%ebx /* swapgs needed? */
22335 + testl $1,%ebx /* swapgs needed? */
22336 jnz paranoid_restore
22337 - testl $3,CS(%rsp)
22338 + testb $3,CS(%rsp)
22339 jnz paranoid_userspace
22340 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22341 + pax_exit_kernel
22342 + TRACE_IRQS_IRETQ 0
22343 + SWAPGS_UNSAFE_STACK
22344 + RESTORE_ALL 8
22345 + pax_force_retaddr_bts
22346 + jmp irq_return
22347 +#endif
22348 paranoid_swapgs:
22349 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22350 + pax_exit_kernel_user
22351 +#else
22352 + pax_exit_kernel
22353 +#endif
22354 TRACE_IRQS_IRETQ 0
22355 SWAPGS_UNSAFE_STACK
22356 RESTORE_ALL 8
22357 jmp irq_return
22358 paranoid_restore:
22359 + pax_exit_kernel
22360 TRACE_IRQS_IRETQ_DEBUG 0
22361 RESTORE_ALL 8
22362 + pax_force_retaddr_bts
22363 jmp irq_return
22364 paranoid_userspace:
22365 GET_THREAD_INFO(%rcx)
22366 @@ -1563,7 +2108,7 @@ paranoid_schedule:
22367 TRACE_IRQS_OFF
22368 jmp paranoid_userspace
22369 CFI_ENDPROC
22370 -END(paranoid_exit)
22371 +ENDPROC(paranoid_exit)
22372
22373 /*
22374 * Exception entry point. This expects an error code/orig_rax on the stack.
22375 @@ -1590,12 +2135,13 @@ ENTRY(error_entry)
22376 movq_cfi r14, R14+8
22377 movq_cfi r15, R15+8
22378 xorl %ebx,%ebx
22379 - testl $3,CS+8(%rsp)
22380 + testb $3,CS+8(%rsp)
22381 je error_kernelspace
22382 error_swapgs:
22383 SWAPGS
22384 error_sti:
22385 TRACE_IRQS_OFF
22386 + pax_force_retaddr_bts
22387 ret
22388
22389 /*
22390 @@ -1622,7 +2168,7 @@ bstep_iret:
22391 movq %rcx,RIP+8(%rsp)
22392 jmp error_swapgs
22393 CFI_ENDPROC
22394 -END(error_entry)
22395 +ENDPROC(error_entry)
22396
22397
22398 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22399 @@ -1633,7 +2179,7 @@ ENTRY(error_exit)
22400 DISABLE_INTERRUPTS(CLBR_NONE)
22401 TRACE_IRQS_OFF
22402 GET_THREAD_INFO(%rcx)
22403 - testl %eax,%eax
22404 + testl $1,%eax
22405 jne retint_kernel
22406 LOCKDEP_SYS_EXIT_IRQ
22407 movl TI_flags(%rcx),%edx
22408 @@ -1642,7 +2188,7 @@ ENTRY(error_exit)
22409 jnz retint_careful
22410 jmp retint_swapgs
22411 CFI_ENDPROC
22412 -END(error_exit)
22413 +ENDPROC(error_exit)
22414
22415 /*
22416 * Test if a given stack is an NMI stack or not.
22417 @@ -1700,9 +2246,11 @@ ENTRY(nmi)
22418 * If %cs was not the kernel segment, then the NMI triggered in user
22419 * space, which means it is definitely not nested.
22420 */
22421 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22422 + je 1f
22423 cmpl $__KERNEL_CS, 16(%rsp)
22424 jne first_nmi
22425 -
22426 +1:
22427 /*
22428 * Check the special variable on the stack to see if NMIs are
22429 * executing.
22430 @@ -1736,8 +2284,7 @@ nested_nmi:
22431
22432 1:
22433 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22434 - leaq -1*8(%rsp), %rdx
22435 - movq %rdx, %rsp
22436 + subq $8, %rsp
22437 CFI_ADJUST_CFA_OFFSET 1*8
22438 leaq -10*8(%rsp), %rdx
22439 pushq_cfi $__KERNEL_DS
22440 @@ -1755,6 +2302,7 @@ nested_nmi_out:
22441 CFI_RESTORE rdx
22442
22443 /* No need to check faults here */
22444 +# pax_force_retaddr_bts
22445 INTERRUPT_RETURN
22446
22447 CFI_RESTORE_STATE
22448 @@ -1871,6 +2419,8 @@ end_repeat_nmi:
22449 */
22450 movq %cr2, %r12
22451
22452 + pax_enter_kernel_nmi
22453 +
22454 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22455 movq %rsp,%rdi
22456 movq $-1,%rsi
22457 @@ -1883,26 +2433,31 @@ end_repeat_nmi:
22458 movq %r12, %cr2
22459 1:
22460
22461 - testl %ebx,%ebx /* swapgs needed? */
22462 + testl $1,%ebx /* swapgs needed? */
22463 jnz nmi_restore
22464 nmi_swapgs:
22465 SWAPGS_UNSAFE_STACK
22466 nmi_restore:
22467 + pax_exit_kernel_nmi
22468 /* Pop the extra iret frame at once */
22469 RESTORE_ALL 6*8
22470 + testb $3, 8(%rsp)
22471 + jnz 1f
22472 + pax_force_retaddr_bts
22473 +1:
22474
22475 /* Clear the NMI executing stack variable */
22476 movq $0, 5*8(%rsp)
22477 jmp irq_return
22478 CFI_ENDPROC
22479 -END(nmi)
22480 +ENDPROC(nmi)
22481
22482 ENTRY(ignore_sysret)
22483 CFI_STARTPROC
22484 mov $-ENOSYS,%eax
22485 sysret
22486 CFI_ENDPROC
22487 -END(ignore_sysret)
22488 +ENDPROC(ignore_sysret)
22489
22490 /*
22491 * End of kprobes section
22492 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22493 index 42a392a..fbbd930 100644
22494 --- a/arch/x86/kernel/ftrace.c
22495 +++ b/arch/x86/kernel/ftrace.c
22496 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22497 {
22498 unsigned char replaced[MCOUNT_INSN_SIZE];
22499
22500 + ip = ktla_ktva(ip);
22501 +
22502 /*
22503 * Note: Due to modules and __init, code can
22504 * disappear and change, we need to protect against faulting
22505 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22506 unsigned char old[MCOUNT_INSN_SIZE], *new;
22507 int ret;
22508
22509 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22510 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22511 new = ftrace_call_replace(ip, (unsigned long)func);
22512
22513 /* See comment above by declaration of modifying_ftrace_code */
22514 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22515 /* Also update the regs callback function */
22516 if (!ret) {
22517 ip = (unsigned long)(&ftrace_regs_call);
22518 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22519 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22520 new = ftrace_call_replace(ip, (unsigned long)func);
22521 ret = ftrace_modify_code(ip, old, new);
22522 }
22523 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22524 * kernel identity mapping to modify code.
22525 */
22526 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22527 - ip = (unsigned long)__va(__pa_symbol(ip));
22528 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22529
22530 return probe_kernel_write((void *)ip, val, size);
22531 }
22532 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22533 unsigned char replaced[MCOUNT_INSN_SIZE];
22534 unsigned char brk = BREAKPOINT_INSTRUCTION;
22535
22536 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22537 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22538 return -EFAULT;
22539
22540 /* Make sure it is what we expect it to be */
22541 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22542 return ret;
22543
22544 fail_update:
22545 - probe_kernel_write((void *)ip, &old_code[0], 1);
22546 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22547 goto out;
22548 }
22549
22550 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22551 {
22552 unsigned char code[MCOUNT_INSN_SIZE];
22553
22554 + ip = ktla_ktva(ip);
22555 +
22556 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22557 return -EFAULT;
22558
22559 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22560 index 55b6761..a6456fc 100644
22561 --- a/arch/x86/kernel/head64.c
22562 +++ b/arch/x86/kernel/head64.c
22563 @@ -67,12 +67,12 @@ again:
22564 pgd = *pgd_p;
22565
22566 /*
22567 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22568 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22569 + * The use of __early_va rather than __va here is critical:
22570 + * __va would point us back into the dynamic
22571 * range and we might end up looping forever...
22572 */
22573 if (pgd)
22574 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22575 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22576 else {
22577 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22578 reset_early_page_tables();
22579 @@ -82,13 +82,13 @@ again:
22580 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22581 for (i = 0; i < PTRS_PER_PUD; i++)
22582 pud_p[i] = 0;
22583 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22584 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22585 }
22586 pud_p += pud_index(address);
22587 pud = *pud_p;
22588
22589 if (pud)
22590 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22591 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22592 else {
22593 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22594 reset_early_page_tables();
22595 @@ -98,7 +98,7 @@ again:
22596 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22597 for (i = 0; i < PTRS_PER_PMD; i++)
22598 pmd_p[i] = 0;
22599 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22600 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22601 }
22602 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22603 pmd_p[pmd_index(address)] = pmd;
22604 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
22605 if (console_loglevel == 10)
22606 early_printk("Kernel alive\n");
22607
22608 - clear_page(init_level4_pgt);
22609 /* set init_level4_pgt kernel high mapping*/
22610 init_level4_pgt[511] = early_level4_pgt[511];
22611
22612 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22613 index 5dd87a8..d68b3f4 100644
22614 --- a/arch/x86/kernel/head_32.S
22615 +++ b/arch/x86/kernel/head_32.S
22616 @@ -26,6 +26,12 @@
22617 /* Physical address */
22618 #define pa(X) ((X) - __PAGE_OFFSET)
22619
22620 +#ifdef CONFIG_PAX_KERNEXEC
22621 +#define ta(X) (X)
22622 +#else
22623 +#define ta(X) ((X) - __PAGE_OFFSET)
22624 +#endif
22625 +
22626 /*
22627 * References to members of the new_cpu_data structure.
22628 */
22629 @@ -55,11 +61,7 @@
22630 * and small than max_low_pfn, otherwise will waste some page table entries
22631 */
22632
22633 -#if PTRS_PER_PMD > 1
22634 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22635 -#else
22636 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22637 -#endif
22638 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22639
22640 /* Number of possible pages in the lowmem region */
22641 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22642 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22643 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22644
22645 /*
22646 + * Real beginning of normal "text" segment
22647 + */
22648 +ENTRY(stext)
22649 +ENTRY(_stext)
22650 +
22651 +/*
22652 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22653 * %esi points to the real-mode code as a 32-bit pointer.
22654 * CS and DS must be 4 GB flat segments, but we don't depend on
22655 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22656 * can.
22657 */
22658 __HEAD
22659 +
22660 +#ifdef CONFIG_PAX_KERNEXEC
22661 + jmp startup_32
22662 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22663 +.fill PAGE_SIZE-5,1,0xcc
22664 +#endif
22665 +
22666 ENTRY(startup_32)
22667 movl pa(stack_start),%ecx
22668
22669 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22670 2:
22671 leal -__PAGE_OFFSET(%ecx),%esp
22672
22673 +#ifdef CONFIG_SMP
22674 + movl $pa(cpu_gdt_table),%edi
22675 + movl $__per_cpu_load,%eax
22676 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22677 + rorl $16,%eax
22678 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22679 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22680 + movl $__per_cpu_end - 1,%eax
22681 + subl $__per_cpu_start,%eax
22682 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22683 +#endif
22684 +
22685 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22686 + movl $NR_CPUS,%ecx
22687 + movl $pa(cpu_gdt_table),%edi
22688 +1:
22689 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22690 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22691 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22692 + addl $PAGE_SIZE_asm,%edi
22693 + loop 1b
22694 +#endif
22695 +
22696 +#ifdef CONFIG_PAX_KERNEXEC
22697 + movl $pa(boot_gdt),%edi
22698 + movl $__LOAD_PHYSICAL_ADDR,%eax
22699 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22700 + rorl $16,%eax
22701 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22702 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22703 + rorl $16,%eax
22704 +
22705 + ljmp $(__BOOT_CS),$1f
22706 +1:
22707 +
22708 + movl $NR_CPUS,%ecx
22709 + movl $pa(cpu_gdt_table),%edi
22710 + addl $__PAGE_OFFSET,%eax
22711 +1:
22712 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22713 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22714 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22715 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22716 + rorl $16,%eax
22717 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22718 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22719 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22720 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22721 + rorl $16,%eax
22722 + addl $PAGE_SIZE_asm,%edi
22723 + loop 1b
22724 +#endif
22725 +
22726 /*
22727 * Clear BSS first so that there are no surprises...
22728 */
22729 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22730 movl %eax, pa(max_pfn_mapped)
22731
22732 /* Do early initialization of the fixmap area */
22733 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22734 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22735 +#ifdef CONFIG_COMPAT_VDSO
22736 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22737 +#else
22738 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22739 +#endif
22740 #else /* Not PAE */
22741
22742 page_pde_offset = (__PAGE_OFFSET >> 20);
22743 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22744 movl %eax, pa(max_pfn_mapped)
22745
22746 /* Do early initialization of the fixmap area */
22747 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22748 - movl %eax,pa(initial_page_table+0xffc)
22749 +#ifdef CONFIG_COMPAT_VDSO
22750 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22751 +#else
22752 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22753 +#endif
22754 #endif
22755
22756 #ifdef CONFIG_PARAVIRT
22757 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22758 cmpl $num_subarch_entries, %eax
22759 jae bad_subarch
22760
22761 - movl pa(subarch_entries)(,%eax,4), %eax
22762 - subl $__PAGE_OFFSET, %eax
22763 - jmp *%eax
22764 + jmp *pa(subarch_entries)(,%eax,4)
22765
22766 bad_subarch:
22767 WEAK(lguest_entry)
22768 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22769 __INITDATA
22770
22771 subarch_entries:
22772 - .long default_entry /* normal x86/PC */
22773 - .long lguest_entry /* lguest hypervisor */
22774 - .long xen_entry /* Xen hypervisor */
22775 - .long default_entry /* Moorestown MID */
22776 + .long ta(default_entry) /* normal x86/PC */
22777 + .long ta(lguest_entry) /* lguest hypervisor */
22778 + .long ta(xen_entry) /* Xen hypervisor */
22779 + .long ta(default_entry) /* Moorestown MID */
22780 num_subarch_entries = (. - subarch_entries) / 4
22781 .previous
22782 #else
22783 @@ -354,6 +426,7 @@ default_entry:
22784 movl pa(mmu_cr4_features),%eax
22785 movl %eax,%cr4
22786
22787 +#ifdef CONFIG_X86_PAE
22788 testb $X86_CR4_PAE, %al # check if PAE is enabled
22789 jz enable_paging
22790
22791 @@ -382,6 +455,9 @@ default_entry:
22792 /* Make changes effective */
22793 wrmsr
22794
22795 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22796 +#endif
22797 +
22798 enable_paging:
22799
22800 /*
22801 @@ -449,14 +525,20 @@ is486:
22802 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22803 movl %eax,%ss # after changing gdt.
22804
22805 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22806 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22807 movl %eax,%ds
22808 movl %eax,%es
22809
22810 movl $(__KERNEL_PERCPU), %eax
22811 movl %eax,%fs # set this cpu's percpu
22812
22813 +#ifdef CONFIG_CC_STACKPROTECTOR
22814 movl $(__KERNEL_STACK_CANARY),%eax
22815 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22816 + movl $(__USER_DS),%eax
22817 +#else
22818 + xorl %eax,%eax
22819 +#endif
22820 movl %eax,%gs
22821
22822 xorl %eax,%eax # Clear LDT
22823 @@ -512,8 +594,11 @@ setup_once:
22824 * relocation. Manually set base address in stack canary
22825 * segment descriptor.
22826 */
22827 - movl $gdt_page,%eax
22828 + movl $cpu_gdt_table,%eax
22829 movl $stack_canary,%ecx
22830 +#ifdef CONFIG_SMP
22831 + addl $__per_cpu_load,%ecx
22832 +#endif
22833 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22834 shrl $16, %ecx
22835 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22836 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22837 /* This is global to keep gas from relaxing the jumps */
22838 ENTRY(early_idt_handler)
22839 cld
22840 - cmpl $2,%ss:early_recursion_flag
22841 + cmpl $1,%ss:early_recursion_flag
22842 je hlt_loop
22843 incl %ss:early_recursion_flag
22844
22845 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22846 pushl (20+6*4)(%esp) /* trapno */
22847 pushl $fault_msg
22848 call printk
22849 -#endif
22850 call dump_stack
22851 +#endif
22852 hlt_loop:
22853 hlt
22854 jmp hlt_loop
22855 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22856 /* This is the default interrupt "handler" :-) */
22857 ALIGN
22858 ignore_int:
22859 - cld
22860 #ifdef CONFIG_PRINTK
22861 + cmpl $2,%ss:early_recursion_flag
22862 + je hlt_loop
22863 + incl %ss:early_recursion_flag
22864 + cld
22865 pushl %eax
22866 pushl %ecx
22867 pushl %edx
22868 @@ -612,9 +700,6 @@ ignore_int:
22869 movl $(__KERNEL_DS),%eax
22870 movl %eax,%ds
22871 movl %eax,%es
22872 - cmpl $2,early_recursion_flag
22873 - je hlt_loop
22874 - incl early_recursion_flag
22875 pushl 16(%esp)
22876 pushl 24(%esp)
22877 pushl 32(%esp)
22878 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22879 /*
22880 * BSS section
22881 */
22882 -__PAGE_ALIGNED_BSS
22883 - .align PAGE_SIZE
22884 #ifdef CONFIG_X86_PAE
22885 +.section .initial_pg_pmd,"a",@progbits
22886 initial_pg_pmd:
22887 .fill 1024*KPMDS,4,0
22888 #else
22889 +.section .initial_page_table,"a",@progbits
22890 ENTRY(initial_page_table)
22891 .fill 1024,4,0
22892 #endif
22893 +.section .initial_pg_fixmap,"a",@progbits
22894 initial_pg_fixmap:
22895 .fill 1024,4,0
22896 +.section .empty_zero_page,"a",@progbits
22897 ENTRY(empty_zero_page)
22898 .fill 4096,1,0
22899 +.section .swapper_pg_dir,"a",@progbits
22900 ENTRY(swapper_pg_dir)
22901 +#ifdef CONFIG_X86_PAE
22902 + .fill 4,8,0
22903 +#else
22904 .fill 1024,4,0
22905 +#endif
22906
22907 /*
22908 * This starts the data section.
22909 */
22910 #ifdef CONFIG_X86_PAE
22911 -__PAGE_ALIGNED_DATA
22912 - /* Page-aligned for the benefit of paravirt? */
22913 - .align PAGE_SIZE
22914 +.section .initial_page_table,"a",@progbits
22915 ENTRY(initial_page_table)
22916 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22917 # if KPMDS == 3
22918 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22919 # error "Kernel PMDs should be 1, 2 or 3"
22920 # endif
22921 .align PAGE_SIZE /* needs to be page-sized too */
22922 +
22923 +#ifdef CONFIG_PAX_PER_CPU_PGD
22924 +ENTRY(cpu_pgd)
22925 + .rept 2*NR_CPUS
22926 + .fill 4,8,0
22927 + .endr
22928 +#endif
22929 +
22930 #endif
22931
22932 .data
22933 .balign 4
22934 ENTRY(stack_start)
22935 - .long init_thread_union+THREAD_SIZE
22936 + .long init_thread_union+THREAD_SIZE-8
22937
22938 __INITRODATA
22939 int_msg:
22940 @@ -722,7 +820,7 @@ fault_msg:
22941 * segment size, and 32-bit linear address value:
22942 */
22943
22944 - .data
22945 +.section .rodata,"a",@progbits
22946 .globl boot_gdt_descr
22947 .globl idt_descr
22948
22949 @@ -731,7 +829,7 @@ fault_msg:
22950 .word 0 # 32 bit align gdt_desc.address
22951 boot_gdt_descr:
22952 .word __BOOT_DS+7
22953 - .long boot_gdt - __PAGE_OFFSET
22954 + .long pa(boot_gdt)
22955
22956 .word 0 # 32-bit align idt_desc.address
22957 idt_descr:
22958 @@ -742,7 +840,7 @@ idt_descr:
22959 .word 0 # 32 bit align gdt_desc.address
22960 ENTRY(early_gdt_descr)
22961 .word GDT_ENTRIES*8-1
22962 - .long gdt_page /* Overwritten for secondary CPUs */
22963 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22964
22965 /*
22966 * The boot_gdt must mirror the equivalent in setup.S and is
22967 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
22968 .align L1_CACHE_BYTES
22969 ENTRY(boot_gdt)
22970 .fill GDT_ENTRY_BOOT_CS,8,0
22971 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22972 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22973 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22974 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22975 +
22976 + .align PAGE_SIZE_asm
22977 +ENTRY(cpu_gdt_table)
22978 + .rept NR_CPUS
22979 + .quad 0x0000000000000000 /* NULL descriptor */
22980 + .quad 0x0000000000000000 /* 0x0b reserved */
22981 + .quad 0x0000000000000000 /* 0x13 reserved */
22982 + .quad 0x0000000000000000 /* 0x1b reserved */
22983 +
22984 +#ifdef CONFIG_PAX_KERNEXEC
22985 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22986 +#else
22987 + .quad 0x0000000000000000 /* 0x20 unused */
22988 +#endif
22989 +
22990 + .quad 0x0000000000000000 /* 0x28 unused */
22991 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
22992 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
22993 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
22994 + .quad 0x0000000000000000 /* 0x4b reserved */
22995 + .quad 0x0000000000000000 /* 0x53 reserved */
22996 + .quad 0x0000000000000000 /* 0x5b reserved */
22997 +
22998 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
22999 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23000 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23001 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23002 +
23003 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23004 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23005 +
23006 + /*
23007 + * Segments used for calling PnP BIOS have byte granularity.
23008 + * The code segments and data segments have fixed 64k limits,
23009 + * the transfer segment sizes are set at run time.
23010 + */
23011 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23012 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23013 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23014 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23015 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23016 +
23017 + /*
23018 + * The APM segments have byte granularity and their bases
23019 + * are set at run time. All have 64k limits.
23020 + */
23021 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23022 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23023 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23024 +
23025 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23026 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23027 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23028 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23029 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23030 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23031 +
23032 + /* Be sure this is zeroed to avoid false validations in Xen */
23033 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23034 + .endr
23035 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23036 index e1aabdb..73dcad8 100644
23037 --- a/arch/x86/kernel/head_64.S
23038 +++ b/arch/x86/kernel/head_64.S
23039 @@ -20,6 +20,8 @@
23040 #include <asm/processor-flags.h>
23041 #include <asm/percpu.h>
23042 #include <asm/nops.h>
23043 +#include <asm/cpufeature.h>
23044 +#include <asm/alternative-asm.h>
23045
23046 #ifdef CONFIG_PARAVIRT
23047 #include <asm/asm-offsets.h>
23048 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23049 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23050 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23051 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23052 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23053 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23054 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23055 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23056 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23057 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23058
23059 .text
23060 __HEAD
23061 @@ -89,11 +97,23 @@ startup_64:
23062 * Fixup the physical addresses in the page table
23063 */
23064 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23065 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23066 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23067 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23068 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23069 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23070
23071 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23072 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23073 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23074 +#ifndef CONFIG_XEN
23075 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23076 +#endif
23077
23078 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23079 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23080 +
23081 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23082 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23083 +
23084 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23085
23086 /*
23087 * Set up the identity mapping for the switchover. These
23088 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
23089 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23090 1:
23091
23092 - /* Enable PAE mode and PGE */
23093 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23094 + /* Enable PAE mode and PSE/PGE */
23095 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23096 movq %rcx, %cr4
23097
23098 /* Setup early boot stage 4 level pagetables. */
23099 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
23100 movl $MSR_EFER, %ecx
23101 rdmsr
23102 btsl $_EFER_SCE, %eax /* Enable System Call */
23103 - btl $20,%edi /* No Execute supported? */
23104 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23105 jnc 1f
23106 btsl $_EFER_NX, %eax
23107 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23108 + leaq init_level4_pgt(%rip), %rdi
23109 +#ifndef CONFIG_EFI
23110 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
23111 +#endif
23112 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
23113 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
23114 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
23115 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23116 1: wrmsr /* Make changes effective */
23117
23118 /* Setup cr0 */
23119 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
23120 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23121 * address given in m16:64.
23122 */
23123 + pax_set_fptr_mask
23124 movq initial_code(%rip),%rax
23125 pushq $0 # fake return address to stop unwinder
23126 pushq $__KERNEL_CS # set correct cs
23127 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
23128 call dump_stack
23129 #ifdef CONFIG_KALLSYMS
23130 leaq early_idt_ripmsg(%rip),%rdi
23131 - movq 40(%rsp),%rsi # %rip again
23132 + movq 88(%rsp),%rsi # %rip again
23133 call __print_symbol
23134 #endif
23135 #endif /* EARLY_PRINTK */
23136 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
23137 early_recursion_flag:
23138 .long 0
23139
23140 + .section .rodata,"a",@progbits
23141 #ifdef CONFIG_EARLY_PRINTK
23142 early_idt_msg:
23143 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23144 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
23145 NEXT_PAGE(early_dynamic_pgts)
23146 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23147
23148 - .data
23149 + .section .rodata,"a",@progbits
23150
23151 -#ifndef CONFIG_XEN
23152 NEXT_PAGE(init_level4_pgt)
23153 - .fill 512,8,0
23154 -#else
23155 -NEXT_PAGE(init_level4_pgt)
23156 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23157 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23158 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23159 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23160 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23161 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23162 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23163 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23164 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23165 .org init_level4_pgt + L4_START_KERNEL*8, 0
23166 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23167 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23168
23169 +#ifdef CONFIG_PAX_PER_CPU_PGD
23170 +NEXT_PAGE(cpu_pgd)
23171 + .rept 2*NR_CPUS
23172 + .fill 512,8,0
23173 + .endr
23174 +#endif
23175 +
23176 NEXT_PAGE(level3_ident_pgt)
23177 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23178 +#ifdef CONFIG_XEN
23179 .fill 511, 8, 0
23180 +#else
23181 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23182 + .fill 510,8,0
23183 +#endif
23184 +
23185 +NEXT_PAGE(level3_vmalloc_start_pgt)
23186 + .fill 512,8,0
23187 +
23188 +NEXT_PAGE(level3_vmalloc_end_pgt)
23189 + .fill 512,8,0
23190 +
23191 +NEXT_PAGE(level3_vmemmap_pgt)
23192 + .fill L3_VMEMMAP_START,8,0
23193 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23194 +
23195 NEXT_PAGE(level2_ident_pgt)
23196 - /* Since I easily can, map the first 1G.
23197 + /* Since I easily can, map the first 2G.
23198 * Don't set NX because code runs from these pages.
23199 */
23200 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23201 -#endif
23202 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23203
23204 NEXT_PAGE(level3_kernel_pgt)
23205 .fill L3_START_KERNEL,8,0
23206 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
23207 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23208 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23209
23210 +NEXT_PAGE(level2_vmemmap_pgt)
23211 + .fill 512,8,0
23212 +
23213 NEXT_PAGE(level2_kernel_pgt)
23214 /*
23215 * 512 MB kernel mapping. We spend a full page on this pagetable
23216 @@ -488,30 +544,62 @@ NEXT_PAGE(level2_kernel_pgt)
23217 KERNEL_IMAGE_SIZE/PMD_SIZE)
23218
23219 NEXT_PAGE(level2_fixmap_pgt)
23220 - .fill 506,8,0
23221 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23222 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23223 - .fill 5,8,0
23224 + .fill 507,8,0
23225 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23226 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23227 + .fill 4,8,0
23228
23229 -NEXT_PAGE(level1_fixmap_pgt)
23230 +NEXT_PAGE(level1_vsyscall_pgt)
23231 .fill 512,8,0
23232
23233 #undef PMDS
23234
23235 - .data
23236 + .align PAGE_SIZE
23237 +ENTRY(cpu_gdt_table)
23238 + .rept NR_CPUS
23239 + .quad 0x0000000000000000 /* NULL descriptor */
23240 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23241 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23242 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23243 + .quad 0x00cffb000000ffff /* __USER32_CS */
23244 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23245 + .quad 0x00affb000000ffff /* __USER_CS */
23246 +
23247 +#ifdef CONFIG_PAX_KERNEXEC
23248 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23249 +#else
23250 + .quad 0x0 /* unused */
23251 +#endif
23252 +
23253 + .quad 0,0 /* TSS */
23254 + .quad 0,0 /* LDT */
23255 + .quad 0,0,0 /* three TLS descriptors */
23256 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23257 + /* asm/segment.h:GDT_ENTRIES must match this */
23258 +
23259 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23260 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23261 +#else
23262 + .quad 0x0 /* unused */
23263 +#endif
23264 +
23265 + /* zero the remaining page */
23266 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23267 + .endr
23268 +
23269 .align 16
23270 .globl early_gdt_descr
23271 early_gdt_descr:
23272 .word GDT_ENTRIES*8-1
23273 early_gdt_descr_base:
23274 - .quad INIT_PER_CPU_VAR(gdt_page)
23275 + .quad cpu_gdt_table
23276
23277 ENTRY(phys_base)
23278 /* This must match the first entry in level2_kernel_pgt */
23279 .quad 0x0000000000000000
23280
23281 #include "../../x86/xen/xen-head.S"
23282 -
23283 - __PAGE_ALIGNED_BSS
23284 +
23285 + .section .rodata,"a",@progbits
23286 NEXT_PAGE(empty_zero_page)
23287 .skip PAGE_SIZE
23288 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23289 index 0fa6912..b37438b 100644
23290 --- a/arch/x86/kernel/i386_ksyms_32.c
23291 +++ b/arch/x86/kernel/i386_ksyms_32.c
23292 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23293 EXPORT_SYMBOL(cmpxchg8b_emu);
23294 #endif
23295
23296 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23297 +
23298 /* Networking helper routines. */
23299 EXPORT_SYMBOL(csum_partial_copy_generic);
23300 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23301 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23302
23303 EXPORT_SYMBOL(__get_user_1);
23304 EXPORT_SYMBOL(__get_user_2);
23305 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23306
23307 EXPORT_SYMBOL(csum_partial);
23308 EXPORT_SYMBOL(empty_zero_page);
23309 +
23310 +#ifdef CONFIG_PAX_KERNEXEC
23311 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23312 +#endif
23313 +
23314 +#ifdef CONFIG_PAX_PER_CPU_PGD
23315 +EXPORT_SYMBOL(cpu_pgd);
23316 +#endif
23317 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23318 index 5d576ab..1403a03 100644
23319 --- a/arch/x86/kernel/i387.c
23320 +++ b/arch/x86/kernel/i387.c
23321 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23322 static inline bool interrupted_user_mode(void)
23323 {
23324 struct pt_regs *regs = get_irq_regs();
23325 - return regs && user_mode_vm(regs);
23326 + return regs && user_mode(regs);
23327 }
23328
23329 /*
23330 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23331 index 9a5c460..84868423 100644
23332 --- a/arch/x86/kernel/i8259.c
23333 +++ b/arch/x86/kernel/i8259.c
23334 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23335 static void make_8259A_irq(unsigned int irq)
23336 {
23337 disable_irq_nosync(irq);
23338 - io_apic_irqs &= ~(1<<irq);
23339 + io_apic_irqs &= ~(1UL<<irq);
23340 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23341 i8259A_chip.name);
23342 enable_irq(irq);
23343 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23344 "spurious 8259A interrupt: IRQ%d.\n", irq);
23345 spurious_irq_mask |= irqmask;
23346 }
23347 - atomic_inc(&irq_err_count);
23348 + atomic_inc_unchecked(&irq_err_count);
23349 /*
23350 * Theoretically we do not have to handle this IRQ,
23351 * but in Linux this does not cause problems and is
23352 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23353 /* (slave's support for AEOI in flat mode is to be investigated) */
23354 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23355
23356 + pax_open_kernel();
23357 if (auto_eoi)
23358 /*
23359 * In AEOI mode we just have to mask the interrupt
23360 * when acking.
23361 */
23362 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23363 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23364 else
23365 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23366 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23367 + pax_close_kernel();
23368
23369 udelay(100); /* wait for 8259A to initialize */
23370
23371 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23372 index a979b5b..1d6db75 100644
23373 --- a/arch/x86/kernel/io_delay.c
23374 +++ b/arch/x86/kernel/io_delay.c
23375 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23376 * Quirk table for systems that misbehave (lock up, etc.) if port
23377 * 0x80 is used:
23378 */
23379 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23380 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23381 {
23382 .callback = dmi_io_delay_0xed_port,
23383 .ident = "Compaq Presario V6000",
23384 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23385 index 4ddaf66..6292f4e 100644
23386 --- a/arch/x86/kernel/ioport.c
23387 +++ b/arch/x86/kernel/ioport.c
23388 @@ -6,6 +6,7 @@
23389 #include <linux/sched.h>
23390 #include <linux/kernel.h>
23391 #include <linux/capability.h>
23392 +#include <linux/security.h>
23393 #include <linux/errno.h>
23394 #include <linux/types.h>
23395 #include <linux/ioport.h>
23396 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23397
23398 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23399 return -EINVAL;
23400 +#ifdef CONFIG_GRKERNSEC_IO
23401 + if (turn_on && grsec_disable_privio) {
23402 + gr_handle_ioperm();
23403 + return -EPERM;
23404 + }
23405 +#endif
23406 if (turn_on && !capable(CAP_SYS_RAWIO))
23407 return -EPERM;
23408
23409 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23410 * because the ->io_bitmap_max value must match the bitmap
23411 * contents:
23412 */
23413 - tss = &per_cpu(init_tss, get_cpu());
23414 + tss = init_tss + get_cpu();
23415
23416 if (turn_on)
23417 bitmap_clear(t->io_bitmap_ptr, from, num);
23418 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23419 return -EINVAL;
23420 /* Trying to gain more privileges? */
23421 if (level > old) {
23422 +#ifdef CONFIG_GRKERNSEC_IO
23423 + if (grsec_disable_privio) {
23424 + gr_handle_iopl();
23425 + return -EPERM;
23426 + }
23427 +#endif
23428 if (!capable(CAP_SYS_RAWIO))
23429 return -EPERM;
23430 }
23431 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23432 index 3a8185c..3c042ee 100644
23433 --- a/arch/x86/kernel/irq.c
23434 +++ b/arch/x86/kernel/irq.c
23435 @@ -21,7 +21,7 @@
23436 #define CREATE_TRACE_POINTS
23437 #include <asm/trace/irq_vectors.h>
23438
23439 -atomic_t irq_err_count;
23440 +atomic_unchecked_t irq_err_count;
23441
23442 /* Function pointer for generic interrupt vector handling */
23443 void (*x86_platform_ipi_callback)(void) = NULL;
23444 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23445 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23446 seq_printf(p, " Machine check polls\n");
23447 #endif
23448 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23449 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23450 #if defined(CONFIG_X86_IO_APIC)
23451 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23452 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23453 #endif
23454 return 0;
23455 }
23456 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23457
23458 u64 arch_irq_stat(void)
23459 {
23460 - u64 sum = atomic_read(&irq_err_count);
23461 + u64 sum = atomic_read_unchecked(&irq_err_count);
23462 return sum;
23463 }
23464
23465 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23466 index 4186755..784efa0 100644
23467 --- a/arch/x86/kernel/irq_32.c
23468 +++ b/arch/x86/kernel/irq_32.c
23469 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23470 __asm__ __volatile__("andl %%esp,%0" :
23471 "=r" (sp) : "0" (THREAD_SIZE - 1));
23472
23473 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23474 + return sp < STACK_WARN;
23475 }
23476
23477 static void print_stack_overflow(void)
23478 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23479 * per-CPU IRQ handling contexts (thread information and stack)
23480 */
23481 union irq_ctx {
23482 - struct thread_info tinfo;
23483 - u32 stack[THREAD_SIZE/sizeof(u32)];
23484 + unsigned long previous_esp;
23485 + u32 stack[THREAD_SIZE/sizeof(u32)];
23486 } __attribute__((aligned(THREAD_SIZE)));
23487
23488 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23489 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23490 static inline int
23491 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23492 {
23493 - union irq_ctx *curctx, *irqctx;
23494 + union irq_ctx *irqctx;
23495 u32 *isp, arg1, arg2;
23496
23497 - curctx = (union irq_ctx *) current_thread_info();
23498 irqctx = __this_cpu_read(hardirq_ctx);
23499
23500 /*
23501 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23502 * handler) we can't do that and just have to keep using the
23503 * current stack (which is the irq stack already after all)
23504 */
23505 - if (unlikely(curctx == irqctx))
23506 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23507 return 0;
23508
23509 /* build the stack frame on the IRQ stack */
23510 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23511 - irqctx->tinfo.task = curctx->tinfo.task;
23512 - irqctx->tinfo.previous_esp = current_stack_pointer;
23513 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23514 + irqctx->previous_esp = current_stack_pointer;
23515
23516 - /* Copy the preempt_count so that the [soft]irq checks work. */
23517 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23518 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23519 + __set_fs(MAKE_MM_SEG(0));
23520 +#endif
23521
23522 if (unlikely(overflow))
23523 call_on_stack(print_stack_overflow, isp);
23524 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23525 : "0" (irq), "1" (desc), "2" (isp),
23526 "D" (desc->handle_irq)
23527 : "memory", "cc", "ecx");
23528 +
23529 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23530 + __set_fs(current_thread_info()->addr_limit);
23531 +#endif
23532 +
23533 return 1;
23534 }
23535
23536 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23537 */
23538 void irq_ctx_init(int cpu)
23539 {
23540 - union irq_ctx *irqctx;
23541 -
23542 if (per_cpu(hardirq_ctx, cpu))
23543 return;
23544
23545 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23546 - THREADINFO_GFP,
23547 - THREAD_SIZE_ORDER));
23548 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23549 - irqctx->tinfo.cpu = cpu;
23550 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23551 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23552 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23553 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23554
23555 - per_cpu(hardirq_ctx, cpu) = irqctx;
23556 -
23557 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23558 - THREADINFO_GFP,
23559 - THREAD_SIZE_ORDER));
23560 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23561 - irqctx->tinfo.cpu = cpu;
23562 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23563 -
23564 - per_cpu(softirq_ctx, cpu) = irqctx;
23565 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23566 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23567
23568 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23569 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23570 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23571 asmlinkage void do_softirq(void)
23572 {
23573 unsigned long flags;
23574 - struct thread_info *curctx;
23575 union irq_ctx *irqctx;
23576 u32 *isp;
23577
23578 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23579 local_irq_save(flags);
23580
23581 if (local_softirq_pending()) {
23582 - curctx = current_thread_info();
23583 irqctx = __this_cpu_read(softirq_ctx);
23584 - irqctx->tinfo.task = curctx->task;
23585 - irqctx->tinfo.previous_esp = current_stack_pointer;
23586 + irqctx->previous_esp = current_stack_pointer;
23587
23588 /* build the stack frame on the softirq stack */
23589 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23590 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23591 +
23592 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23593 + __set_fs(MAKE_MM_SEG(0));
23594 +#endif
23595
23596 call_on_stack(__do_softirq, isp);
23597 +
23598 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23599 + __set_fs(current_thread_info()->addr_limit);
23600 +#endif
23601 +
23602 /*
23603 * Shouldn't happen, we returned above if in_interrupt():
23604 */
23605 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23606 if (unlikely(!desc))
23607 return false;
23608
23609 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23610 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23611 if (unlikely(overflow))
23612 print_stack_overflow();
23613 desc->handle_irq(irq, desc);
23614 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23615 index d04d3ec..ea4b374 100644
23616 --- a/arch/x86/kernel/irq_64.c
23617 +++ b/arch/x86/kernel/irq_64.c
23618 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23619 u64 estack_top, estack_bottom;
23620 u64 curbase = (u64)task_stack_page(current);
23621
23622 - if (user_mode_vm(regs))
23623 + if (user_mode(regs))
23624 return;
23625
23626 if (regs->sp >= curbase + sizeof(struct thread_info) +
23627 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
23628 index dc1404b..bbc43e7 100644
23629 --- a/arch/x86/kernel/kdebugfs.c
23630 +++ b/arch/x86/kernel/kdebugfs.c
23631 @@ -27,7 +27,7 @@ struct setup_data_node {
23632 u32 len;
23633 };
23634
23635 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
23636 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
23637 size_t count, loff_t *ppos)
23638 {
23639 struct setup_data_node *node = file->private_data;
23640 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23641 index 836f832..a8bda67 100644
23642 --- a/arch/x86/kernel/kgdb.c
23643 +++ b/arch/x86/kernel/kgdb.c
23644 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23645 #ifdef CONFIG_X86_32
23646 switch (regno) {
23647 case GDB_SS:
23648 - if (!user_mode_vm(regs))
23649 + if (!user_mode(regs))
23650 *(unsigned long *)mem = __KERNEL_DS;
23651 break;
23652 case GDB_SP:
23653 - if (!user_mode_vm(regs))
23654 + if (!user_mode(regs))
23655 *(unsigned long *)mem = kernel_stack_pointer(regs);
23656 break;
23657 case GDB_GS:
23658 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23659 bp->attr.bp_addr = breakinfo[breakno].addr;
23660 bp->attr.bp_len = breakinfo[breakno].len;
23661 bp->attr.bp_type = breakinfo[breakno].type;
23662 - info->address = breakinfo[breakno].addr;
23663 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23664 + info->address = ktla_ktva(breakinfo[breakno].addr);
23665 + else
23666 + info->address = breakinfo[breakno].addr;
23667 info->len = breakinfo[breakno].len;
23668 info->type = breakinfo[breakno].type;
23669 val = arch_install_hw_breakpoint(bp);
23670 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23671 case 'k':
23672 /* clear the trace bit */
23673 linux_regs->flags &= ~X86_EFLAGS_TF;
23674 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23675 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23676
23677 /* set the trace bit if we're stepping */
23678 if (remcomInBuffer[0] == 's') {
23679 linux_regs->flags |= X86_EFLAGS_TF;
23680 - atomic_set(&kgdb_cpu_doing_single_step,
23681 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23682 raw_smp_processor_id());
23683 }
23684
23685 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23686
23687 switch (cmd) {
23688 case DIE_DEBUG:
23689 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23690 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23691 if (user_mode(regs))
23692 return single_step_cont(regs, args);
23693 break;
23694 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23695 #endif /* CONFIG_DEBUG_RODATA */
23696
23697 bpt->type = BP_BREAKPOINT;
23698 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23699 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23700 BREAK_INSTR_SIZE);
23701 if (err)
23702 return err;
23703 - err = probe_kernel_write((char *)bpt->bpt_addr,
23704 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23705 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23706 #ifdef CONFIG_DEBUG_RODATA
23707 if (!err)
23708 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23709 return -EBUSY;
23710 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23711 BREAK_INSTR_SIZE);
23712 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23713 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23714 if (err)
23715 return err;
23716 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23717 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23718 if (mutex_is_locked(&text_mutex))
23719 goto knl_write;
23720 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23721 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23722 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23723 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23724 goto knl_write;
23725 return err;
23726 knl_write:
23727 #endif /* CONFIG_DEBUG_RODATA */
23728 - return probe_kernel_write((char *)bpt->bpt_addr,
23729 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23730 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23731 }
23732
23733 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23734 index 211bce4..6e2580a 100644
23735 --- a/arch/x86/kernel/kprobes/core.c
23736 +++ b/arch/x86/kernel/kprobes/core.c
23737 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23738 s32 raddr;
23739 } __packed *insn;
23740
23741 - insn = (struct __arch_relative_insn *)from;
23742 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23743 +
23744 + pax_open_kernel();
23745 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23746 insn->op = op;
23747 + pax_close_kernel();
23748 }
23749
23750 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23751 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23752 kprobe_opcode_t opcode;
23753 kprobe_opcode_t *orig_opcodes = opcodes;
23754
23755 - if (search_exception_tables((unsigned long)opcodes))
23756 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23757 return 0; /* Page fault may occur on this address. */
23758
23759 retry:
23760 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23761 * for the first byte, we can recover the original instruction
23762 * from it and kp->opcode.
23763 */
23764 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23765 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23766 buf[0] = kp->opcode;
23767 - return (unsigned long)buf;
23768 + return ktva_ktla((unsigned long)buf);
23769 }
23770
23771 /*
23772 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23773 /* Another subsystem puts a breakpoint, failed to recover */
23774 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23775 return 0;
23776 + pax_open_kernel();
23777 memcpy(dest, insn.kaddr, insn.length);
23778 + pax_close_kernel();
23779
23780 #ifdef CONFIG_X86_64
23781 if (insn_rip_relative(&insn)) {
23782 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23783 return 0;
23784 }
23785 disp = (u8 *) dest + insn_offset_displacement(&insn);
23786 + pax_open_kernel();
23787 *(s32 *) disp = (s32) newdisp;
23788 + pax_close_kernel();
23789 }
23790 #endif
23791 return insn.length;
23792 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23793 * nor set current_kprobe, because it doesn't use single
23794 * stepping.
23795 */
23796 - regs->ip = (unsigned long)p->ainsn.insn;
23797 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23798 preempt_enable_no_resched();
23799 return;
23800 }
23801 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23802 regs->flags &= ~X86_EFLAGS_IF;
23803 /* single step inline if the instruction is an int3 */
23804 if (p->opcode == BREAKPOINT_INSTRUCTION)
23805 - regs->ip = (unsigned long)p->addr;
23806 + regs->ip = ktla_ktva((unsigned long)p->addr);
23807 else
23808 - regs->ip = (unsigned long)p->ainsn.insn;
23809 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23810 }
23811
23812 /*
23813 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23814 setup_singlestep(p, regs, kcb, 0);
23815 return 1;
23816 }
23817 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23818 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23819 /*
23820 * The breakpoint instruction was removed right
23821 * after we hit it. Another cpu has removed
23822 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23823 " movq %rax, 152(%rsp)\n"
23824 RESTORE_REGS_STRING
23825 " popfq\n"
23826 +#ifdef KERNEXEC_PLUGIN
23827 + " btsq $63,(%rsp)\n"
23828 +#endif
23829 #else
23830 " pushf\n"
23831 SAVE_REGS_STRING
23832 @@ -779,7 +789,7 @@ static void __kprobes
23833 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23834 {
23835 unsigned long *tos = stack_addr(regs);
23836 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23837 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23838 unsigned long orig_ip = (unsigned long)p->addr;
23839 kprobe_opcode_t *insn = p->ainsn.insn;
23840
23841 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23842 struct die_args *args = data;
23843 int ret = NOTIFY_DONE;
23844
23845 - if (args->regs && user_mode_vm(args->regs))
23846 + if (args->regs && user_mode(args->regs))
23847 return ret;
23848
23849 switch (val) {
23850 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23851 index 76dc6f0..66bdfc3 100644
23852 --- a/arch/x86/kernel/kprobes/opt.c
23853 +++ b/arch/x86/kernel/kprobes/opt.c
23854 @@ -79,6 +79,7 @@ found:
23855 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23856 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23857 {
23858 + pax_open_kernel();
23859 #ifdef CONFIG_X86_64
23860 *addr++ = 0x48;
23861 *addr++ = 0xbf;
23862 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23863 *addr++ = 0xb8;
23864 #endif
23865 *(unsigned long *)addr = val;
23866 + pax_close_kernel();
23867 }
23868
23869 static void __used __kprobes kprobes_optinsn_template_holder(void)
23870 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23871 * Verify if the address gap is in 2GB range, because this uses
23872 * a relative jump.
23873 */
23874 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23875 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23876 if (abs(rel) > 0x7fffffff)
23877 return -ERANGE;
23878
23879 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23880 op->optinsn.size = ret;
23881
23882 /* Copy arch-dep-instance from template */
23883 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23884 + pax_open_kernel();
23885 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23886 + pax_close_kernel();
23887
23888 /* Set probe information */
23889 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23890
23891 /* Set probe function call */
23892 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23893 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23894
23895 /* Set returning jmp instruction at the tail of out-of-line buffer */
23896 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23897 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23898 (u8 *)op->kp.addr + op->optinsn.size);
23899
23900 flush_icache_range((unsigned long) buf,
23901 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
23902 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
23903
23904 /* Backup instructions which will be replaced by jump address */
23905 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23906 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23907 RELATIVE_ADDR_SIZE);
23908
23909 insn_buf[0] = RELATIVEJUMP_OPCODE;
23910 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23911 /* This kprobe is really able to run optimized path. */
23912 op = container_of(p, struct optimized_kprobe, kp);
23913 /* Detour through copied instructions */
23914 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23915 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23916 if (!reenter)
23917 reset_current_kprobe();
23918 preempt_enable_no_resched();
23919 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23920 index ebc9873..1b9724b 100644
23921 --- a/arch/x86/kernel/ldt.c
23922 +++ b/arch/x86/kernel/ldt.c
23923 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23924 if (reload) {
23925 #ifdef CONFIG_SMP
23926 preempt_disable();
23927 - load_LDT(pc);
23928 + load_LDT_nolock(pc);
23929 if (!cpumask_equal(mm_cpumask(current->mm),
23930 cpumask_of(smp_processor_id())))
23931 smp_call_function(flush_ldt, current->mm, 1);
23932 preempt_enable();
23933 #else
23934 - load_LDT(pc);
23935 + load_LDT_nolock(pc);
23936 #endif
23937 }
23938 if (oldsize) {
23939 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23940 return err;
23941
23942 for (i = 0; i < old->size; i++)
23943 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23944 + write_ldt_entry(new->ldt, i, old->ldt + i);
23945 return 0;
23946 }
23947
23948 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23949 retval = copy_ldt(&mm->context, &old_mm->context);
23950 mutex_unlock(&old_mm->context.lock);
23951 }
23952 +
23953 + if (tsk == current) {
23954 + mm->context.vdso = 0;
23955 +
23956 +#ifdef CONFIG_X86_32
23957 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23958 + mm->context.user_cs_base = 0UL;
23959 + mm->context.user_cs_limit = ~0UL;
23960 +
23961 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23962 + cpus_clear(mm->context.cpu_user_cs_mask);
23963 +#endif
23964 +
23965 +#endif
23966 +#endif
23967 +
23968 + }
23969 +
23970 return retval;
23971 }
23972
23973 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23974 }
23975 }
23976
23977 +#ifdef CONFIG_PAX_SEGMEXEC
23978 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23979 + error = -EINVAL;
23980 + goto out_unlock;
23981 + }
23982 +#endif
23983 +
23984 fill_ldt(&ldt, &ldt_info);
23985 if (oldmode)
23986 ldt.avl = 0;
23987 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
23988 index 5b19e4d..6476a76 100644
23989 --- a/arch/x86/kernel/machine_kexec_32.c
23990 +++ b/arch/x86/kernel/machine_kexec_32.c
23991 @@ -26,7 +26,7 @@
23992 #include <asm/cacheflush.h>
23993 #include <asm/debugreg.h>
23994
23995 -static void set_idt(void *newidt, __u16 limit)
23996 +static void set_idt(struct desc_struct *newidt, __u16 limit)
23997 {
23998 struct desc_ptr curidt;
23999
24000 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24001 }
24002
24003
24004 -static void set_gdt(void *newgdt, __u16 limit)
24005 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24006 {
24007 struct desc_ptr curgdt;
24008
24009 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24010 }
24011
24012 control_page = page_address(image->control_code_page);
24013 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24014 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24015
24016 relocate_kernel_ptr = control_page;
24017 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24018 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24019 index 15c9876..0a43909 100644
24020 --- a/arch/x86/kernel/microcode_core.c
24021 +++ b/arch/x86/kernel/microcode_core.c
24022 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24023 return NOTIFY_OK;
24024 }
24025
24026 -static struct notifier_block __refdata mc_cpu_notifier = {
24027 +static struct notifier_block mc_cpu_notifier = {
24028 .notifier_call = mc_cpu_callback,
24029 };
24030
24031 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24032 index 5fb2ceb..3ae90bb 100644
24033 --- a/arch/x86/kernel/microcode_intel.c
24034 +++ b/arch/x86/kernel/microcode_intel.c
24035 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24036
24037 static int get_ucode_user(void *to, const void *from, size_t n)
24038 {
24039 - return copy_from_user(to, from, n);
24040 + return copy_from_user(to, (const void __force_user *)from, n);
24041 }
24042
24043 static enum ucode_state
24044 request_microcode_user(int cpu, const void __user *buf, size_t size)
24045 {
24046 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24047 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24048 }
24049
24050 static void microcode_fini_cpu(int cpu)
24051 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24052 index 216a4d7..228255a 100644
24053 --- a/arch/x86/kernel/module.c
24054 +++ b/arch/x86/kernel/module.c
24055 @@ -43,15 +43,60 @@ do { \
24056 } while (0)
24057 #endif
24058
24059 -void *module_alloc(unsigned long size)
24060 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24061 {
24062 - if (PAGE_ALIGN(size) > MODULES_LEN)
24063 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24064 return NULL;
24065 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24066 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24067 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24068 -1, __builtin_return_address(0));
24069 }
24070
24071 +void *module_alloc(unsigned long size)
24072 +{
24073 +
24074 +#ifdef CONFIG_PAX_KERNEXEC
24075 + return __module_alloc(size, PAGE_KERNEL);
24076 +#else
24077 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24078 +#endif
24079 +
24080 +}
24081 +
24082 +#ifdef CONFIG_PAX_KERNEXEC
24083 +#ifdef CONFIG_X86_32
24084 +void *module_alloc_exec(unsigned long size)
24085 +{
24086 + struct vm_struct *area;
24087 +
24088 + if (size == 0)
24089 + return NULL;
24090 +
24091 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24092 + return area ? area->addr : NULL;
24093 +}
24094 +EXPORT_SYMBOL(module_alloc_exec);
24095 +
24096 +void module_free_exec(struct module *mod, void *module_region)
24097 +{
24098 + vunmap(module_region);
24099 +}
24100 +EXPORT_SYMBOL(module_free_exec);
24101 +#else
24102 +void module_free_exec(struct module *mod, void *module_region)
24103 +{
24104 + module_free(mod, module_region);
24105 +}
24106 +EXPORT_SYMBOL(module_free_exec);
24107 +
24108 +void *module_alloc_exec(unsigned long size)
24109 +{
24110 + return __module_alloc(size, PAGE_KERNEL_RX);
24111 +}
24112 +EXPORT_SYMBOL(module_alloc_exec);
24113 +#endif
24114 +#endif
24115 +
24116 #ifdef CONFIG_X86_32
24117 int apply_relocate(Elf32_Shdr *sechdrs,
24118 const char *strtab,
24119 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24120 unsigned int i;
24121 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24122 Elf32_Sym *sym;
24123 - uint32_t *location;
24124 + uint32_t *plocation, location;
24125
24126 DEBUGP("Applying relocate section %u to %u\n",
24127 relsec, sechdrs[relsec].sh_info);
24128 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24129 /* This is where to make the change */
24130 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24131 - + rel[i].r_offset;
24132 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24133 + location = (uint32_t)plocation;
24134 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24135 + plocation = ktla_ktva((void *)plocation);
24136 /* This is the symbol it is referring to. Note that all
24137 undefined symbols have been resolved. */
24138 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24139 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24140 switch (ELF32_R_TYPE(rel[i].r_info)) {
24141 case R_386_32:
24142 /* We add the value into the location given */
24143 - *location += sym->st_value;
24144 + pax_open_kernel();
24145 + *plocation += sym->st_value;
24146 + pax_close_kernel();
24147 break;
24148 case R_386_PC32:
24149 /* Add the value, subtract its position */
24150 - *location += sym->st_value - (uint32_t)location;
24151 + pax_open_kernel();
24152 + *plocation += sym->st_value - location;
24153 + pax_close_kernel();
24154 break;
24155 default:
24156 pr_err("%s: Unknown relocation: %u\n",
24157 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24158 case R_X86_64_NONE:
24159 break;
24160 case R_X86_64_64:
24161 + pax_open_kernel();
24162 *(u64 *)loc = val;
24163 + pax_close_kernel();
24164 break;
24165 case R_X86_64_32:
24166 + pax_open_kernel();
24167 *(u32 *)loc = val;
24168 + pax_close_kernel();
24169 if (val != *(u32 *)loc)
24170 goto overflow;
24171 break;
24172 case R_X86_64_32S:
24173 + pax_open_kernel();
24174 *(s32 *)loc = val;
24175 + pax_close_kernel();
24176 if ((s64)val != *(s32 *)loc)
24177 goto overflow;
24178 break;
24179 case R_X86_64_PC32:
24180 val -= (u64)loc;
24181 + pax_open_kernel();
24182 *(u32 *)loc = val;
24183 + pax_close_kernel();
24184 +
24185 #if 0
24186 if ((s64)val != *(s32 *)loc)
24187 goto overflow;
24188 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24189 index 88458fa..349f7a4 100644
24190 --- a/arch/x86/kernel/msr.c
24191 +++ b/arch/x86/kernel/msr.c
24192 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24193 return notifier_from_errno(err);
24194 }
24195
24196 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24197 +static struct notifier_block msr_class_cpu_notifier = {
24198 .notifier_call = msr_class_cpu_callback,
24199 };
24200
24201 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24202 index ba77ebc..65da999 100644
24203 --- a/arch/x86/kernel/nmi.c
24204 +++ b/arch/x86/kernel/nmi.c
24205 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24206 return handled;
24207 }
24208
24209 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24210 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24211 {
24212 struct nmi_desc *desc = nmi_to_desc(type);
24213 unsigned long flags;
24214 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24215 * event confuses some handlers (kdump uses this flag)
24216 */
24217 if (action->flags & NMI_FLAG_FIRST)
24218 - list_add_rcu(&action->list, &desc->head);
24219 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24220 else
24221 - list_add_tail_rcu(&action->list, &desc->head);
24222 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24223
24224 spin_unlock_irqrestore(&desc->lock, flags);
24225 return 0;
24226 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24227 if (!strcmp(n->name, name)) {
24228 WARN(in_nmi(),
24229 "Trying to free NMI (%s) from NMI context!\n", n->name);
24230 - list_del_rcu(&n->list);
24231 + pax_list_del_rcu((struct list_head *)&n->list);
24232 break;
24233 }
24234 }
24235 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24236 dotraplinkage notrace __kprobes void
24237 do_nmi(struct pt_regs *regs, long error_code)
24238 {
24239 +
24240 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24241 + if (!user_mode(regs)) {
24242 + unsigned long cs = regs->cs & 0xFFFF;
24243 + unsigned long ip = ktva_ktla(regs->ip);
24244 +
24245 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24246 + regs->ip = ip;
24247 + }
24248 +#endif
24249 +
24250 nmi_nesting_preprocess(regs);
24251
24252 nmi_enter();
24253 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24254 index 6d9582e..f746287 100644
24255 --- a/arch/x86/kernel/nmi_selftest.c
24256 +++ b/arch/x86/kernel/nmi_selftest.c
24257 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24258 {
24259 /* trap all the unknown NMIs we may generate */
24260 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24261 - __initdata);
24262 + __initconst);
24263 }
24264
24265 static void __init cleanup_nmi_testsuite(void)
24266 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24267 unsigned long timeout;
24268
24269 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24270 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24271 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24272 nmi_fail = FAILURE;
24273 return;
24274 }
24275 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24276 index 676b8c7..870ba04 100644
24277 --- a/arch/x86/kernel/paravirt-spinlocks.c
24278 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24279 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
24280 arch_spin_lock(lock);
24281 }
24282
24283 -struct pv_lock_ops pv_lock_ops = {
24284 +struct pv_lock_ops pv_lock_ops __read_only = {
24285 #ifdef CONFIG_SMP
24286 .spin_is_locked = __ticket_spin_is_locked,
24287 .spin_is_contended = __ticket_spin_is_contended,
24288 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24289 index cd6de64..27c6af0 100644
24290 --- a/arch/x86/kernel/paravirt.c
24291 +++ b/arch/x86/kernel/paravirt.c
24292 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24293 {
24294 return x;
24295 }
24296 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24297 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24298 +#endif
24299
24300 void __init default_banner(void)
24301 {
24302 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24303 if (opfunc == NULL)
24304 /* If there's no function, patch it with a ud2a (BUG) */
24305 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24306 - else if (opfunc == _paravirt_nop)
24307 + else if (opfunc == (void *)_paravirt_nop)
24308 /* If the operation is a nop, then nop the callsite */
24309 ret = paravirt_patch_nop();
24310
24311 /* identity functions just return their single argument */
24312 - else if (opfunc == _paravirt_ident_32)
24313 + else if (opfunc == (void *)_paravirt_ident_32)
24314 ret = paravirt_patch_ident_32(insnbuf, len);
24315 - else if (opfunc == _paravirt_ident_64)
24316 + else if (opfunc == (void *)_paravirt_ident_64)
24317 ret = paravirt_patch_ident_64(insnbuf, len);
24318 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24319 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24320 + ret = paravirt_patch_ident_64(insnbuf, len);
24321 +#endif
24322
24323 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24324 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24325 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24326 if (insn_len > len || start == NULL)
24327 insn_len = len;
24328 else
24329 - memcpy(insnbuf, start, insn_len);
24330 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24331
24332 return insn_len;
24333 }
24334 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24335 return this_cpu_read(paravirt_lazy_mode);
24336 }
24337
24338 -struct pv_info pv_info = {
24339 +struct pv_info pv_info __read_only = {
24340 .name = "bare hardware",
24341 .paravirt_enabled = 0,
24342 .kernel_rpl = 0,
24343 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
24344 #endif
24345 };
24346
24347 -struct pv_init_ops pv_init_ops = {
24348 +struct pv_init_ops pv_init_ops __read_only = {
24349 .patch = native_patch,
24350 };
24351
24352 -struct pv_time_ops pv_time_ops = {
24353 +struct pv_time_ops pv_time_ops __read_only = {
24354 .sched_clock = native_sched_clock,
24355 .steal_clock = native_steal_clock,
24356 };
24357
24358 -struct pv_irq_ops pv_irq_ops = {
24359 +struct pv_irq_ops pv_irq_ops __read_only = {
24360 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24361 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24362 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24363 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
24364 #endif
24365 };
24366
24367 -struct pv_cpu_ops pv_cpu_ops = {
24368 +struct pv_cpu_ops pv_cpu_ops __read_only = {
24369 .cpuid = native_cpuid,
24370 .get_debugreg = native_get_debugreg,
24371 .set_debugreg = native_set_debugreg,
24372 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
24373 .end_context_switch = paravirt_nop,
24374 };
24375
24376 -struct pv_apic_ops pv_apic_ops = {
24377 +struct pv_apic_ops pv_apic_ops __read_only= {
24378 #ifdef CONFIG_X86_LOCAL_APIC
24379 .startup_ipi_hook = paravirt_nop,
24380 #endif
24381 };
24382
24383 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24384 +#ifdef CONFIG_X86_32
24385 +#ifdef CONFIG_X86_PAE
24386 +/* 64-bit pagetable entries */
24387 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24388 +#else
24389 /* 32-bit pagetable entries */
24390 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24391 +#endif
24392 #else
24393 /* 64-bit pagetable entries */
24394 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24395 #endif
24396
24397 -struct pv_mmu_ops pv_mmu_ops = {
24398 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24399
24400 .read_cr2 = native_read_cr2,
24401 .write_cr2 = native_write_cr2,
24402 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24403 .make_pud = PTE_IDENT,
24404
24405 .set_pgd = native_set_pgd,
24406 + .set_pgd_batched = native_set_pgd_batched,
24407 #endif
24408 #endif /* PAGETABLE_LEVELS >= 3 */
24409
24410 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24411 },
24412
24413 .set_fixmap = native_set_fixmap,
24414 +
24415 +#ifdef CONFIG_PAX_KERNEXEC
24416 + .pax_open_kernel = native_pax_open_kernel,
24417 + .pax_close_kernel = native_pax_close_kernel,
24418 +#endif
24419 +
24420 };
24421
24422 EXPORT_SYMBOL_GPL(pv_time_ops);
24423 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24424 index 299d493..2ccb0ee 100644
24425 --- a/arch/x86/kernel/pci-calgary_64.c
24426 +++ b/arch/x86/kernel/pci-calgary_64.c
24427 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24428 tce_space = be64_to_cpu(readq(target));
24429 tce_space = tce_space & TAR_SW_BITS;
24430
24431 - tce_space = tce_space & (~specified_table_size);
24432 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24433 info->tce_space = (u64 *)__va(tce_space);
24434 }
24435 }
24436 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24437 index 35ccf75..7a15747 100644
24438 --- a/arch/x86/kernel/pci-iommu_table.c
24439 +++ b/arch/x86/kernel/pci-iommu_table.c
24440 @@ -2,7 +2,7 @@
24441 #include <asm/iommu_table.h>
24442 #include <linux/string.h>
24443 #include <linux/kallsyms.h>
24444 -
24445 +#include <linux/sched.h>
24446
24447 #define DEBUG 1
24448
24449 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24450 index 6c483ba..d10ce2f 100644
24451 --- a/arch/x86/kernel/pci-swiotlb.c
24452 +++ b/arch/x86/kernel/pci-swiotlb.c
24453 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24454 void *vaddr, dma_addr_t dma_addr,
24455 struct dma_attrs *attrs)
24456 {
24457 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24458 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24459 }
24460
24461 static struct dma_map_ops swiotlb_dma_ops = {
24462 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24463 index 83369e5..52b93f0 100644
24464 --- a/arch/x86/kernel/process.c
24465 +++ b/arch/x86/kernel/process.c
24466 @@ -36,7 +36,8 @@
24467 * section. Since TSS's are completely CPU-local, we want them
24468 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24469 */
24470 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24471 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24472 +EXPORT_SYMBOL(init_tss);
24473
24474 #ifdef CONFIG_X86_64
24475 static DEFINE_PER_CPU(unsigned char, is_idle);
24476 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24477 task_xstate_cachep =
24478 kmem_cache_create("task_xstate", xstate_size,
24479 __alignof__(union thread_xstate),
24480 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24481 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24482 }
24483
24484 /*
24485 @@ -105,7 +106,7 @@ void exit_thread(void)
24486 unsigned long *bp = t->io_bitmap_ptr;
24487
24488 if (bp) {
24489 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24490 + struct tss_struct *tss = init_tss + get_cpu();
24491
24492 t->io_bitmap_ptr = NULL;
24493 clear_thread_flag(TIF_IO_BITMAP);
24494 @@ -125,6 +126,9 @@ void flush_thread(void)
24495 {
24496 struct task_struct *tsk = current;
24497
24498 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24499 + loadsegment(gs, 0);
24500 +#endif
24501 flush_ptrace_hw_breakpoint(tsk);
24502 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24503 drop_init_fpu(tsk);
24504 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24505 void exit_idle(void)
24506 {
24507 /* idle loop has pid 0 */
24508 - if (current->pid)
24509 + if (task_pid_nr(current))
24510 return;
24511 __exit_idle();
24512 }
24513 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24514 return ret;
24515 }
24516 #endif
24517 -void stop_this_cpu(void *dummy)
24518 +__noreturn void stop_this_cpu(void *dummy)
24519 {
24520 local_irq_disable();
24521 /*
24522 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24523 }
24524 early_param("idle", idle_setup);
24525
24526 -unsigned long arch_align_stack(unsigned long sp)
24527 +#ifdef CONFIG_PAX_RANDKSTACK
24528 +void pax_randomize_kstack(struct pt_regs *regs)
24529 {
24530 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24531 - sp -= get_random_int() % 8192;
24532 - return sp & ~0xf;
24533 -}
24534 + struct thread_struct *thread = &current->thread;
24535 + unsigned long time;
24536
24537 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24538 -{
24539 - unsigned long range_end = mm->brk + 0x02000000;
24540 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24541 -}
24542 + if (!randomize_va_space)
24543 + return;
24544 +
24545 + if (v8086_mode(regs))
24546 + return;
24547
24548 + rdtscl(time);
24549 +
24550 + /* P4 seems to return a 0 LSB, ignore it */
24551 +#ifdef CONFIG_MPENTIUM4
24552 + time &= 0x3EUL;
24553 + time <<= 2;
24554 +#elif defined(CONFIG_X86_64)
24555 + time &= 0xFUL;
24556 + time <<= 4;
24557 +#else
24558 + time &= 0x1FUL;
24559 + time <<= 3;
24560 +#endif
24561 +
24562 + thread->sp0 ^= time;
24563 + load_sp0(init_tss + smp_processor_id(), thread);
24564 +
24565 +#ifdef CONFIG_X86_64
24566 + this_cpu_write(kernel_stack, thread->sp0);
24567 +#endif
24568 +}
24569 +#endif
24570 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24571 index f8adefc..4bce3d6 100644
24572 --- a/arch/x86/kernel/process_32.c
24573 +++ b/arch/x86/kernel/process_32.c
24574 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24575 unsigned long thread_saved_pc(struct task_struct *tsk)
24576 {
24577 return ((unsigned long *)tsk->thread.sp)[3];
24578 +//XXX return tsk->thread.eip;
24579 }
24580
24581 void __show_regs(struct pt_regs *regs, int all)
24582 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24583 unsigned long sp;
24584 unsigned short ss, gs;
24585
24586 - if (user_mode_vm(regs)) {
24587 + if (user_mode(regs)) {
24588 sp = regs->sp;
24589 ss = regs->ss & 0xffff;
24590 - gs = get_user_gs(regs);
24591 } else {
24592 sp = kernel_stack_pointer(regs);
24593 savesegment(ss, ss);
24594 - savesegment(gs, gs);
24595 }
24596 + gs = get_user_gs(regs);
24597
24598 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24599 (u16)regs->cs, regs->ip, regs->flags,
24600 - smp_processor_id());
24601 + raw_smp_processor_id());
24602 print_symbol("EIP is at %s\n", regs->ip);
24603
24604 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24605 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24606 int copy_thread(unsigned long clone_flags, unsigned long sp,
24607 unsigned long arg, struct task_struct *p)
24608 {
24609 - struct pt_regs *childregs = task_pt_regs(p);
24610 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24611 struct task_struct *tsk;
24612 int err;
24613
24614 p->thread.sp = (unsigned long) childregs;
24615 p->thread.sp0 = (unsigned long) (childregs+1);
24616 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24617
24618 if (unlikely(p->flags & PF_KTHREAD)) {
24619 /* kernel thread */
24620 memset(childregs, 0, sizeof(struct pt_regs));
24621 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24622 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24623 - childregs->ds = __USER_DS;
24624 - childregs->es = __USER_DS;
24625 + savesegment(gs, childregs->gs);
24626 + childregs->ds = __KERNEL_DS;
24627 + childregs->es = __KERNEL_DS;
24628 childregs->fs = __KERNEL_PERCPU;
24629 childregs->bx = sp; /* function */
24630 childregs->bp = arg;
24631 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24632 struct thread_struct *prev = &prev_p->thread,
24633 *next = &next_p->thread;
24634 int cpu = smp_processor_id();
24635 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24636 + struct tss_struct *tss = init_tss + cpu;
24637 fpu_switch_t fpu;
24638
24639 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24640 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24641 */
24642 lazy_save_gs(prev->gs);
24643
24644 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24645 + __set_fs(task_thread_info(next_p)->addr_limit);
24646 +#endif
24647 +
24648 /*
24649 * Load the per-thread Thread-Local Storage descriptor.
24650 */
24651 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24652 */
24653 arch_end_context_switch(next_p);
24654
24655 + this_cpu_write(current_task, next_p);
24656 + this_cpu_write(current_tinfo, &next_p->tinfo);
24657 +
24658 /*
24659 * Restore %gs if needed (which is common)
24660 */
24661 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24662
24663 switch_fpu_finish(next_p, fpu);
24664
24665 - this_cpu_write(current_task, next_p);
24666 -
24667 return prev_p;
24668 }
24669
24670 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24671 } while (count++ < 16);
24672 return 0;
24673 }
24674 -
24675 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24676 index 05646ba..0c2906d 100644
24677 --- a/arch/x86/kernel/process_64.c
24678 +++ b/arch/x86/kernel/process_64.c
24679 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24680 struct pt_regs *childregs;
24681 struct task_struct *me = current;
24682
24683 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24684 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24685 childregs = task_pt_regs(p);
24686 p->thread.sp = (unsigned long) childregs;
24687 p->thread.usersp = me->thread.usersp;
24688 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24689 set_tsk_thread_flag(p, TIF_FORK);
24690 p->fpu_counter = 0;
24691 p->thread.io_bitmap_ptr = NULL;
24692 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24693 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24694 savesegment(es, p->thread.es);
24695 savesegment(ds, p->thread.ds);
24696 + savesegment(ss, p->thread.ss);
24697 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24698 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24699
24700 if (unlikely(p->flags & PF_KTHREAD)) {
24701 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24702 struct thread_struct *prev = &prev_p->thread;
24703 struct thread_struct *next = &next_p->thread;
24704 int cpu = smp_processor_id();
24705 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24706 + struct tss_struct *tss = init_tss + cpu;
24707 unsigned fsindex, gsindex;
24708 fpu_switch_t fpu;
24709
24710 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24711 if (unlikely(next->ds | prev->ds))
24712 loadsegment(ds, next->ds);
24713
24714 + savesegment(ss, prev->ss);
24715 + if (unlikely(next->ss != prev->ss))
24716 + loadsegment(ss, next->ss);
24717
24718 /* We must save %fs and %gs before load_TLS() because
24719 * %fs and %gs may be cleared by load_TLS().
24720 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24721 prev->usersp = this_cpu_read(old_rsp);
24722 this_cpu_write(old_rsp, next->usersp);
24723 this_cpu_write(current_task, next_p);
24724 + this_cpu_write(current_tinfo, &next_p->tinfo);
24725
24726 - this_cpu_write(kernel_stack,
24727 - (unsigned long)task_stack_page(next_p) +
24728 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24729 + this_cpu_write(kernel_stack, next->sp0);
24730
24731 /*
24732 * Now maybe reload the debug registers and handle I/O bitmaps
24733 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24734 if (!p || p == current || p->state == TASK_RUNNING)
24735 return 0;
24736 stack = (unsigned long)task_stack_page(p);
24737 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24738 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24739 return 0;
24740 fp = *(u64 *)(p->thread.sp);
24741 do {
24742 - if (fp < (unsigned long)stack ||
24743 - fp >= (unsigned long)stack+THREAD_SIZE)
24744 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24745 return 0;
24746 ip = *(u64 *)(fp+8);
24747 if (!in_sched_functions(ip))
24748 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24749 index 7461f50..1334029 100644
24750 --- a/arch/x86/kernel/ptrace.c
24751 +++ b/arch/x86/kernel/ptrace.c
24752 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24753 {
24754 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24755 unsigned long sp = (unsigned long)&regs->sp;
24756 - struct thread_info *tinfo;
24757
24758 - if (context == (sp & ~(THREAD_SIZE - 1)))
24759 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24760 return sp;
24761
24762 - tinfo = (struct thread_info *)context;
24763 - if (tinfo->previous_esp)
24764 - return tinfo->previous_esp;
24765 + sp = *(unsigned long *)context;
24766 + if (sp)
24767 + return sp;
24768
24769 return (unsigned long)regs;
24770 }
24771 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24772 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24773 {
24774 int i;
24775 - int dr7 = 0;
24776 + unsigned long dr7 = 0;
24777 struct arch_hw_breakpoint *info;
24778
24779 for (i = 0; i < HBP_NUM; i++) {
24780 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24781 unsigned long addr, unsigned long data)
24782 {
24783 int ret;
24784 - unsigned long __user *datap = (unsigned long __user *)data;
24785 + unsigned long __user *datap = (__force unsigned long __user *)data;
24786
24787 switch (request) {
24788 /* read the word at location addr in the USER area. */
24789 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24790 if ((int) addr < 0)
24791 return -EIO;
24792 ret = do_get_thread_area(child, addr,
24793 - (struct user_desc __user *)data);
24794 + (__force struct user_desc __user *) data);
24795 break;
24796
24797 case PTRACE_SET_THREAD_AREA:
24798 if ((int) addr < 0)
24799 return -EIO;
24800 ret = do_set_thread_area(child, addr,
24801 - (struct user_desc __user *)data, 0);
24802 + (__force struct user_desc __user *) data, 0);
24803 break;
24804 #endif
24805
24806 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24807
24808 #ifdef CONFIG_X86_64
24809
24810 -static struct user_regset x86_64_regsets[] __read_mostly = {
24811 +static user_regset_no_const x86_64_regsets[] __read_only = {
24812 [REGSET_GENERAL] = {
24813 .core_note_type = NT_PRSTATUS,
24814 .n = sizeof(struct user_regs_struct) / sizeof(long),
24815 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24816 #endif /* CONFIG_X86_64 */
24817
24818 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24819 -static struct user_regset x86_32_regsets[] __read_mostly = {
24820 +static user_regset_no_const x86_32_regsets[] __read_only = {
24821 [REGSET_GENERAL] = {
24822 .core_note_type = NT_PRSTATUS,
24823 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24824 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24825 */
24826 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24827
24828 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24829 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24830 {
24831 #ifdef CONFIG_X86_64
24832 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24833 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24834 memset(info, 0, sizeof(*info));
24835 info->si_signo = SIGTRAP;
24836 info->si_code = si_code;
24837 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24838 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24839 }
24840
24841 void user_single_step_siginfo(struct task_struct *tsk,
24842 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24843 # define IS_IA32 0
24844 #endif
24845
24846 +#ifdef CONFIG_GRKERNSEC_SETXID
24847 +extern void gr_delayed_cred_worker(void);
24848 +#endif
24849 +
24850 /*
24851 * We must return the syscall number to actually look up in the table.
24852 * This can be -1L to skip running any syscall at all.
24853 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24854
24855 user_exit();
24856
24857 +#ifdef CONFIG_GRKERNSEC_SETXID
24858 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24859 + gr_delayed_cred_worker();
24860 +#endif
24861 +
24862 /*
24863 * If we stepped into a sysenter/syscall insn, it trapped in
24864 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24865 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24866 */
24867 user_exit();
24868
24869 +#ifdef CONFIG_GRKERNSEC_SETXID
24870 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24871 + gr_delayed_cred_worker();
24872 +#endif
24873 +
24874 audit_syscall_exit(regs);
24875
24876 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24877 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24878 index 2cb9470..ff1fd80 100644
24879 --- a/arch/x86/kernel/pvclock.c
24880 +++ b/arch/x86/kernel/pvclock.c
24881 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24882 return pv_tsc_khz;
24883 }
24884
24885 -static atomic64_t last_value = ATOMIC64_INIT(0);
24886 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24887
24888 void pvclock_resume(void)
24889 {
24890 - atomic64_set(&last_value, 0);
24891 + atomic64_set_unchecked(&last_value, 0);
24892 }
24893
24894 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24895 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24896 * updating at the same time, and one of them could be slightly behind,
24897 * making the assumption that last_value always go forward fail to hold.
24898 */
24899 - last = atomic64_read(&last_value);
24900 + last = atomic64_read_unchecked(&last_value);
24901 do {
24902 if (ret < last)
24903 return last;
24904 - last = atomic64_cmpxchg(&last_value, last, ret);
24905 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24906 } while (unlikely(last != ret));
24907
24908 return ret;
24909 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24910 index 563ed91..b9c3313 100644
24911 --- a/arch/x86/kernel/reboot.c
24912 +++ b/arch/x86/kernel/reboot.c
24913 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24914
24915 void __noreturn machine_real_restart(unsigned int type)
24916 {
24917 +
24918 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24919 + struct desc_struct *gdt;
24920 +#endif
24921 +
24922 local_irq_disable();
24923
24924 /*
24925 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24926
24927 /* Jump to the identity-mapped low memory code */
24928 #ifdef CONFIG_X86_32
24929 - asm volatile("jmpl *%0" : :
24930 +
24931 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24932 + gdt = get_cpu_gdt_table(smp_processor_id());
24933 + pax_open_kernel();
24934 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24935 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24936 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24937 + loadsegment(ds, __KERNEL_DS);
24938 + loadsegment(es, __KERNEL_DS);
24939 + loadsegment(ss, __KERNEL_DS);
24940 +#endif
24941 +#ifdef CONFIG_PAX_KERNEXEC
24942 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24943 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24944 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24945 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24946 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24947 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24948 +#endif
24949 + pax_close_kernel();
24950 +#endif
24951 +
24952 + asm volatile("ljmpl *%0" : :
24953 "rm" (real_mode_header->machine_real_restart_asm),
24954 "a" (type));
24955 #else
24956 @@ -442,7 +469,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24957 * try to force a triple fault and then cycle between hitting the keyboard
24958 * controller and doing that
24959 */
24960 -static void native_machine_emergency_restart(void)
24961 +static void __noreturn native_machine_emergency_restart(void)
24962 {
24963 int i;
24964 int attempt = 0;
24965 @@ -551,13 +578,13 @@ void native_machine_shutdown(void)
24966 #endif
24967 }
24968
24969 -static void __machine_emergency_restart(int emergency)
24970 +static void __noreturn __machine_emergency_restart(int emergency)
24971 {
24972 reboot_emergency = emergency;
24973 machine_ops.emergency_restart();
24974 }
24975
24976 -static void native_machine_restart(char *__unused)
24977 +static void __noreturn native_machine_restart(char *__unused)
24978 {
24979 pr_notice("machine restart\n");
24980
24981 @@ -566,7 +593,7 @@ static void native_machine_restart(char *__unused)
24982 __machine_emergency_restart(0);
24983 }
24984
24985 -static void native_machine_halt(void)
24986 +static void __noreturn native_machine_halt(void)
24987 {
24988 /* Stop other cpus and apics */
24989 machine_shutdown();
24990 @@ -576,7 +603,7 @@ static void native_machine_halt(void)
24991 stop_this_cpu(NULL);
24992 }
24993
24994 -static void native_machine_power_off(void)
24995 +static void __noreturn native_machine_power_off(void)
24996 {
24997 if (pm_power_off) {
24998 if (!reboot_force)
24999 @@ -585,9 +612,10 @@ static void native_machine_power_off(void)
25000 }
25001 /* A fallback in case there is no PM info available */
25002 tboot_shutdown(TB_SHUTDOWN_HALT);
25003 + unreachable();
25004 }
25005
25006 -struct machine_ops machine_ops = {
25007 +struct machine_ops machine_ops __read_only = {
25008 .power_off = native_machine_power_off,
25009 .shutdown = native_machine_shutdown,
25010 .emergency_restart = native_machine_emergency_restart,
25011 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25012 index c8e41e9..64049ef 100644
25013 --- a/arch/x86/kernel/reboot_fixups_32.c
25014 +++ b/arch/x86/kernel/reboot_fixups_32.c
25015 @@ -57,7 +57,7 @@ struct device_fixup {
25016 unsigned int vendor;
25017 unsigned int device;
25018 void (*reboot_fixup)(struct pci_dev *);
25019 -};
25020 +} __do_const;
25021
25022 /*
25023 * PCI ids solely used for fixups_table go here
25024 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25025 index 3fd2c69..16ef367 100644
25026 --- a/arch/x86/kernel/relocate_kernel_64.S
25027 +++ b/arch/x86/kernel/relocate_kernel_64.S
25028 @@ -11,6 +11,7 @@
25029 #include <asm/kexec.h>
25030 #include <asm/processor-flags.h>
25031 #include <asm/pgtable_types.h>
25032 +#include <asm/alternative-asm.h>
25033
25034 /*
25035 * Must be relocatable PIC code callable as a C function
25036 @@ -96,8 +97,7 @@ relocate_kernel:
25037
25038 /* jump to identity mapped page */
25039 addq $(identity_mapped - relocate_kernel), %r8
25040 - pushq %r8
25041 - ret
25042 + jmp *%r8
25043
25044 identity_mapped:
25045 /* set return address to 0 if not preserving context */
25046 @@ -167,6 +167,7 @@ identity_mapped:
25047 xorl %r14d, %r14d
25048 xorl %r15d, %r15d
25049
25050 + pax_force_retaddr 0, 1
25051 ret
25052
25053 1:
25054 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25055 index f8ec578..0cc110a 100644
25056 --- a/arch/x86/kernel/setup.c
25057 +++ b/arch/x86/kernel/setup.c
25058 @@ -110,6 +110,7 @@
25059 #include <asm/mce.h>
25060 #include <asm/alternative.h>
25061 #include <asm/prom.h>
25062 +#include <asm/boot.h>
25063
25064 /*
25065 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25066 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25067 #endif
25068
25069
25070 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25071 -unsigned long mmu_cr4_features;
25072 +#ifdef CONFIG_X86_64
25073 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25074 +#elif defined(CONFIG_X86_PAE)
25075 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25076 #else
25077 -unsigned long mmu_cr4_features = X86_CR4_PAE;
25078 +unsigned long mmu_cr4_features __read_only;
25079 #endif
25080
25081 +void set_in_cr4(unsigned long mask)
25082 +{
25083 + unsigned long cr4 = read_cr4();
25084 +
25085 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25086 + return;
25087 +
25088 + pax_open_kernel();
25089 + mmu_cr4_features |= mask;
25090 + pax_close_kernel();
25091 +
25092 + if (trampoline_cr4_features)
25093 + *trampoline_cr4_features = mmu_cr4_features;
25094 + cr4 |= mask;
25095 + write_cr4(cr4);
25096 +}
25097 +EXPORT_SYMBOL(set_in_cr4);
25098 +
25099 +void clear_in_cr4(unsigned long mask)
25100 +{
25101 + unsigned long cr4 = read_cr4();
25102 +
25103 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25104 + return;
25105 +
25106 + pax_open_kernel();
25107 + mmu_cr4_features &= ~mask;
25108 + pax_close_kernel();
25109 +
25110 + if (trampoline_cr4_features)
25111 + *trampoline_cr4_features = mmu_cr4_features;
25112 + cr4 &= ~mask;
25113 + write_cr4(cr4);
25114 +}
25115 +EXPORT_SYMBOL(clear_in_cr4);
25116 +
25117 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25118 int bootloader_type, bootloader_version;
25119
25120 @@ -444,7 +483,7 @@ static void __init parse_setup_data(void)
25121
25122 switch (data->type) {
25123 case SETUP_E820_EXT:
25124 - parse_e820_ext(data);
25125 + parse_e820_ext((struct setup_data __force_kernel *)data);
25126 break;
25127 case SETUP_DTB:
25128 add_dtb(pa_data);
25129 @@ -771,7 +810,7 @@ static void __init trim_bios_range(void)
25130 * area (640->1Mb) as ram even though it is not.
25131 * take them out.
25132 */
25133 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25134 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25135
25136 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25137 }
25138 @@ -779,7 +818,7 @@ static void __init trim_bios_range(void)
25139 /* called before trim_bios_range() to spare extra sanitize */
25140 static void __init e820_add_kernel_range(void)
25141 {
25142 - u64 start = __pa_symbol(_text);
25143 + u64 start = __pa_symbol(ktla_ktva(_text));
25144 u64 size = __pa_symbol(_end) - start;
25145
25146 /*
25147 @@ -841,8 +880,12 @@ static void __init trim_low_memory_range(void)
25148
25149 void __init setup_arch(char **cmdline_p)
25150 {
25151 +#ifdef CONFIG_X86_32
25152 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25153 +#else
25154 memblock_reserve(__pa_symbol(_text),
25155 (unsigned long)__bss_stop - (unsigned long)_text);
25156 +#endif
25157
25158 early_reserve_initrd();
25159
25160 @@ -934,14 +977,14 @@ void __init setup_arch(char **cmdline_p)
25161
25162 if (!boot_params.hdr.root_flags)
25163 root_mountflags &= ~MS_RDONLY;
25164 - init_mm.start_code = (unsigned long) _text;
25165 - init_mm.end_code = (unsigned long) _etext;
25166 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25167 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25168 init_mm.end_data = (unsigned long) _edata;
25169 init_mm.brk = _brk_end;
25170
25171 - code_resource.start = __pa_symbol(_text);
25172 - code_resource.end = __pa_symbol(_etext)-1;
25173 - data_resource.start = __pa_symbol(_etext);
25174 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25175 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25176 + data_resource.start = __pa_symbol(_sdata);
25177 data_resource.end = __pa_symbol(_edata)-1;
25178 bss_resource.start = __pa_symbol(__bss_start);
25179 bss_resource.end = __pa_symbol(__bss_stop)-1;
25180 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25181 index 5cdff03..80fa283 100644
25182 --- a/arch/x86/kernel/setup_percpu.c
25183 +++ b/arch/x86/kernel/setup_percpu.c
25184 @@ -21,19 +21,17 @@
25185 #include <asm/cpu.h>
25186 #include <asm/stackprotector.h>
25187
25188 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25189 +#ifdef CONFIG_SMP
25190 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25191 EXPORT_PER_CPU_SYMBOL(cpu_number);
25192 +#endif
25193
25194 -#ifdef CONFIG_X86_64
25195 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25196 -#else
25197 -#define BOOT_PERCPU_OFFSET 0
25198 -#endif
25199
25200 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25201 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25202
25203 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25204 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25205 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25206 };
25207 EXPORT_SYMBOL(__per_cpu_offset);
25208 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25209 {
25210 #ifdef CONFIG_NEED_MULTIPLE_NODES
25211 pg_data_t *last = NULL;
25212 - unsigned int cpu;
25213 + int cpu;
25214
25215 for_each_possible_cpu(cpu) {
25216 int node = early_cpu_to_node(cpu);
25217 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25218 {
25219 #ifdef CONFIG_X86_32
25220 struct desc_struct gdt;
25221 + unsigned long base = per_cpu_offset(cpu);
25222
25223 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25224 - 0x2 | DESCTYPE_S, 0x8);
25225 - gdt.s = 1;
25226 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25227 + 0x83 | DESCTYPE_S, 0xC);
25228 write_gdt_entry(get_cpu_gdt_table(cpu),
25229 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25230 #endif
25231 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25232 /* alrighty, percpu areas up and running */
25233 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25234 for_each_possible_cpu(cpu) {
25235 +#ifdef CONFIG_CC_STACKPROTECTOR
25236 +#ifdef CONFIG_X86_32
25237 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25238 +#endif
25239 +#endif
25240 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25241 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25242 per_cpu(cpu_number, cpu) = cpu;
25243 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25244 */
25245 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25246 #endif
25247 +#ifdef CONFIG_CC_STACKPROTECTOR
25248 +#ifdef CONFIG_X86_32
25249 + if (!cpu)
25250 + per_cpu(stack_canary.canary, cpu) = canary;
25251 +#endif
25252 +#endif
25253 /*
25254 * Up to this point, the boot CPU has been using .init.data
25255 * area. Reload any changed state for the boot CPU.
25256 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25257 index d859eea..44e17c4 100644
25258 --- a/arch/x86/kernel/signal.c
25259 +++ b/arch/x86/kernel/signal.c
25260 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25261 * Align the stack pointer according to the i386 ABI,
25262 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25263 */
25264 - sp = ((sp + 4) & -16ul) - 4;
25265 + sp = ((sp - 12) & -16ul) - 4;
25266 #else /* !CONFIG_X86_32 */
25267 sp = round_down(sp, 16) - 8;
25268 #endif
25269 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25270 }
25271
25272 if (current->mm->context.vdso)
25273 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25274 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25275 else
25276 - restorer = &frame->retcode;
25277 + restorer = (void __user *)&frame->retcode;
25278 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25279 restorer = ksig->ka.sa.sa_restorer;
25280
25281 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25282 * reasons and because gdb uses it as a signature to notice
25283 * signal handler stack frames.
25284 */
25285 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25286 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25287
25288 if (err)
25289 return -EFAULT;
25290 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25291 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25292
25293 /* Set up to return from userspace. */
25294 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25295 + if (current->mm->context.vdso)
25296 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25297 + else
25298 + restorer = (void __user *)&frame->retcode;
25299 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25300 restorer = ksig->ka.sa.sa_restorer;
25301 put_user_ex(restorer, &frame->pretcode);
25302 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25303 * reasons and because gdb uses it as a signature to notice
25304 * signal handler stack frames.
25305 */
25306 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25307 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25308 } put_user_catch(err);
25309
25310 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25311 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25312 {
25313 int usig = signr_convert(ksig->sig);
25314 sigset_t *set = sigmask_to_save();
25315 - compat_sigset_t *cset = (compat_sigset_t *) set;
25316 + sigset_t sigcopy;
25317 + compat_sigset_t *cset;
25318 +
25319 + sigcopy = *set;
25320 +
25321 + cset = (compat_sigset_t *) &sigcopy;
25322
25323 /* Set up the stack frame */
25324 if (is_ia32_frame()) {
25325 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25326 } else if (is_x32_frame()) {
25327 return x32_setup_rt_frame(ksig, cset, regs);
25328 } else {
25329 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25330 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25331 }
25332 }
25333
25334 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25335 index cdaa347..f5af55d 100644
25336 --- a/arch/x86/kernel/smp.c
25337 +++ b/arch/x86/kernel/smp.c
25338 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25339
25340 __setup("nonmi_ipi", nonmi_ipi_setup);
25341
25342 -struct smp_ops smp_ops = {
25343 +struct smp_ops smp_ops __read_only = {
25344 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25345 .smp_prepare_cpus = native_smp_prepare_cpus,
25346 .smp_cpus_done = native_smp_cpus_done,
25347 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25348 index aecc98a..0244a53 100644
25349 --- a/arch/x86/kernel/smpboot.c
25350 +++ b/arch/x86/kernel/smpboot.c
25351 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25352
25353 enable_start_cpu0 = 0;
25354
25355 -#ifdef CONFIG_X86_32
25356 - /* switch away from the initial page table */
25357 - load_cr3(swapper_pg_dir);
25358 - __flush_tlb_all();
25359 -#endif
25360 -
25361 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25362 barrier();
25363 +
25364 + /* switch away from the initial page table */
25365 +#ifdef CONFIG_PAX_PER_CPU_PGD
25366 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25367 + __flush_tlb_all();
25368 +#elif defined(CONFIG_X86_32)
25369 + load_cr3(swapper_pg_dir);
25370 + __flush_tlb_all();
25371 +#endif
25372 +
25373 /*
25374 * Check TSC synchronization with the BP:
25375 */
25376 @@ -748,6 +752,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25377 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25378 (THREAD_SIZE + task_stack_page(idle))) - 1);
25379 per_cpu(current_task, cpu) = idle;
25380 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25381
25382 #ifdef CONFIG_X86_32
25383 /* Stack for startup_32 can be just as for start_secondary onwards */
25384 @@ -755,11 +760,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25385 #else
25386 clear_tsk_thread_flag(idle, TIF_FORK);
25387 initial_gs = per_cpu_offset(cpu);
25388 - per_cpu(kernel_stack, cpu) =
25389 - (unsigned long)task_stack_page(idle) -
25390 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25391 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25392 #endif
25393 +
25394 + pax_open_kernel();
25395 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25396 + pax_close_kernel();
25397 +
25398 initial_code = (unsigned long)start_secondary;
25399 stack_start = idle->thread.sp;
25400
25401 @@ -908,6 +915,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25402 /* the FPU context is blank, nobody can own it */
25403 __cpu_disable_lazy_restore(cpu);
25404
25405 +#ifdef CONFIG_PAX_PER_CPU_PGD
25406 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25407 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25408 + KERNEL_PGD_PTRS);
25409 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25410 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25411 + KERNEL_PGD_PTRS);
25412 +#endif
25413 +
25414 err = do_boot_cpu(apicid, cpu, tidle);
25415 if (err) {
25416 pr_debug("do_boot_cpu failed %d\n", err);
25417 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25418 index 9b4d51d..5d28b58 100644
25419 --- a/arch/x86/kernel/step.c
25420 +++ b/arch/x86/kernel/step.c
25421 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25422 struct desc_struct *desc;
25423 unsigned long base;
25424
25425 - seg &= ~7UL;
25426 + seg >>= 3;
25427
25428 mutex_lock(&child->mm->context.lock);
25429 - if (unlikely((seg >> 3) >= child->mm->context.size))
25430 + if (unlikely(seg >= child->mm->context.size))
25431 addr = -1L; /* bogus selector, access would fault */
25432 else {
25433 desc = child->mm->context.ldt + seg;
25434 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25435 addr += base;
25436 }
25437 mutex_unlock(&child->mm->context.lock);
25438 - }
25439 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25440 + addr = ktla_ktva(addr);
25441
25442 return addr;
25443 }
25444 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25445 unsigned char opcode[15];
25446 unsigned long addr = convert_ip_to_linear(child, regs);
25447
25448 + if (addr == -EINVAL)
25449 + return 0;
25450 +
25451 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25452 for (i = 0; i < copied; i++) {
25453 switch (opcode[i]) {
25454 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25455 new file mode 100644
25456 index 0000000..5877189
25457 --- /dev/null
25458 +++ b/arch/x86/kernel/sys_i386_32.c
25459 @@ -0,0 +1,189 @@
25460 +/*
25461 + * This file contains various random system calls that
25462 + * have a non-standard calling sequence on the Linux/i386
25463 + * platform.
25464 + */
25465 +
25466 +#include <linux/errno.h>
25467 +#include <linux/sched.h>
25468 +#include <linux/mm.h>
25469 +#include <linux/fs.h>
25470 +#include <linux/smp.h>
25471 +#include <linux/sem.h>
25472 +#include <linux/msg.h>
25473 +#include <linux/shm.h>
25474 +#include <linux/stat.h>
25475 +#include <linux/syscalls.h>
25476 +#include <linux/mman.h>
25477 +#include <linux/file.h>
25478 +#include <linux/utsname.h>
25479 +#include <linux/ipc.h>
25480 +#include <linux/elf.h>
25481 +
25482 +#include <linux/uaccess.h>
25483 +#include <linux/unistd.h>
25484 +
25485 +#include <asm/syscalls.h>
25486 +
25487 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25488 +{
25489 + unsigned long pax_task_size = TASK_SIZE;
25490 +
25491 +#ifdef CONFIG_PAX_SEGMEXEC
25492 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25493 + pax_task_size = SEGMEXEC_TASK_SIZE;
25494 +#endif
25495 +
25496 + if (flags & MAP_FIXED)
25497 + if (len > pax_task_size || addr > pax_task_size - len)
25498 + return -EINVAL;
25499 +
25500 + return 0;
25501 +}
25502 +
25503 +/*
25504 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25505 + */
25506 +static unsigned long get_align_mask(void)
25507 +{
25508 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25509 + return 0;
25510 +
25511 + if (!(current->flags & PF_RANDOMIZE))
25512 + return 0;
25513 +
25514 + return va_align.mask;
25515 +}
25516 +
25517 +unsigned long
25518 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25519 + unsigned long len, unsigned long pgoff, unsigned long flags)
25520 +{
25521 + struct mm_struct *mm = current->mm;
25522 + struct vm_area_struct *vma;
25523 + unsigned long pax_task_size = TASK_SIZE;
25524 + struct vm_unmapped_area_info info;
25525 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25526 +
25527 +#ifdef CONFIG_PAX_SEGMEXEC
25528 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25529 + pax_task_size = SEGMEXEC_TASK_SIZE;
25530 +#endif
25531 +
25532 + pax_task_size -= PAGE_SIZE;
25533 +
25534 + if (len > pax_task_size)
25535 + return -ENOMEM;
25536 +
25537 + if (flags & MAP_FIXED)
25538 + return addr;
25539 +
25540 +#ifdef CONFIG_PAX_RANDMMAP
25541 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25542 +#endif
25543 +
25544 + if (addr) {
25545 + addr = PAGE_ALIGN(addr);
25546 + if (pax_task_size - len >= addr) {
25547 + vma = find_vma(mm, addr);
25548 + if (check_heap_stack_gap(vma, addr, len, offset))
25549 + return addr;
25550 + }
25551 + }
25552 +
25553 + info.flags = 0;
25554 + info.length = len;
25555 + info.align_mask = filp ? get_align_mask() : 0;
25556 + info.align_offset = pgoff << PAGE_SHIFT;
25557 + info.threadstack_offset = offset;
25558 +
25559 +#ifdef CONFIG_PAX_PAGEEXEC
25560 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25561 + info.low_limit = 0x00110000UL;
25562 + info.high_limit = mm->start_code;
25563 +
25564 +#ifdef CONFIG_PAX_RANDMMAP
25565 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25566 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25567 +#endif
25568 +
25569 + if (info.low_limit < info.high_limit) {
25570 + addr = vm_unmapped_area(&info);
25571 + if (!IS_ERR_VALUE(addr))
25572 + return addr;
25573 + }
25574 + } else
25575 +#endif
25576 +
25577 + info.low_limit = mm->mmap_base;
25578 + info.high_limit = pax_task_size;
25579 +
25580 + return vm_unmapped_area(&info);
25581 +}
25582 +
25583 +unsigned long
25584 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25585 + const unsigned long len, const unsigned long pgoff,
25586 + const unsigned long flags)
25587 +{
25588 + struct vm_area_struct *vma;
25589 + struct mm_struct *mm = current->mm;
25590 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25591 + struct vm_unmapped_area_info info;
25592 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25593 +
25594 +#ifdef CONFIG_PAX_SEGMEXEC
25595 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25596 + pax_task_size = SEGMEXEC_TASK_SIZE;
25597 +#endif
25598 +
25599 + pax_task_size -= PAGE_SIZE;
25600 +
25601 + /* requested length too big for entire address space */
25602 + if (len > pax_task_size)
25603 + return -ENOMEM;
25604 +
25605 + if (flags & MAP_FIXED)
25606 + return addr;
25607 +
25608 +#ifdef CONFIG_PAX_PAGEEXEC
25609 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25610 + goto bottomup;
25611 +#endif
25612 +
25613 +#ifdef CONFIG_PAX_RANDMMAP
25614 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25615 +#endif
25616 +
25617 + /* requesting a specific address */
25618 + if (addr) {
25619 + addr = PAGE_ALIGN(addr);
25620 + if (pax_task_size - len >= addr) {
25621 + vma = find_vma(mm, addr);
25622 + if (check_heap_stack_gap(vma, addr, len, offset))
25623 + return addr;
25624 + }
25625 + }
25626 +
25627 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25628 + info.length = len;
25629 + info.low_limit = PAGE_SIZE;
25630 + info.high_limit = mm->mmap_base;
25631 + info.align_mask = filp ? get_align_mask() : 0;
25632 + info.align_offset = pgoff << PAGE_SHIFT;
25633 + info.threadstack_offset = offset;
25634 +
25635 + addr = vm_unmapped_area(&info);
25636 + if (!(addr & ~PAGE_MASK))
25637 + return addr;
25638 + VM_BUG_ON(addr != -ENOMEM);
25639 +
25640 +bottomup:
25641 + /*
25642 + * A failed mmap() very likely causes application failure,
25643 + * so fall back to the bottom-up function here. This scenario
25644 + * can happen with large stack limits and large mmap()
25645 + * allocations.
25646 + */
25647 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25648 +}
25649 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25650 index 30277e2..5664a29 100644
25651 --- a/arch/x86/kernel/sys_x86_64.c
25652 +++ b/arch/x86/kernel/sys_x86_64.c
25653 @@ -81,8 +81,8 @@ out:
25654 return error;
25655 }
25656
25657 -static void find_start_end(unsigned long flags, unsigned long *begin,
25658 - unsigned long *end)
25659 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25660 + unsigned long *begin, unsigned long *end)
25661 {
25662 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25663 unsigned long new_begin;
25664 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25665 *begin = new_begin;
25666 }
25667 } else {
25668 - *begin = current->mm->mmap_legacy_base;
25669 + *begin = mm->mmap_legacy_base;
25670 *end = TASK_SIZE;
25671 }
25672 }
25673 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25674 struct vm_area_struct *vma;
25675 struct vm_unmapped_area_info info;
25676 unsigned long begin, end;
25677 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25678
25679 if (flags & MAP_FIXED)
25680 return addr;
25681
25682 - find_start_end(flags, &begin, &end);
25683 + find_start_end(mm, flags, &begin, &end);
25684
25685 if (len > end)
25686 return -ENOMEM;
25687
25688 +#ifdef CONFIG_PAX_RANDMMAP
25689 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25690 +#endif
25691 +
25692 if (addr) {
25693 addr = PAGE_ALIGN(addr);
25694 vma = find_vma(mm, addr);
25695 - if (end - len >= addr &&
25696 - (!vma || addr + len <= vma->vm_start))
25697 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25698 return addr;
25699 }
25700
25701 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25702 info.high_limit = end;
25703 info.align_mask = filp ? get_align_mask() : 0;
25704 info.align_offset = pgoff << PAGE_SHIFT;
25705 + info.threadstack_offset = offset;
25706 return vm_unmapped_area(&info);
25707 }
25708
25709 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25710 struct mm_struct *mm = current->mm;
25711 unsigned long addr = addr0;
25712 struct vm_unmapped_area_info info;
25713 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25714
25715 /* requested length too big for entire address space */
25716 if (len > TASK_SIZE)
25717 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25718 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25719 goto bottomup;
25720
25721 +#ifdef CONFIG_PAX_RANDMMAP
25722 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25723 +#endif
25724 +
25725 /* requesting a specific address */
25726 if (addr) {
25727 addr = PAGE_ALIGN(addr);
25728 vma = find_vma(mm, addr);
25729 - if (TASK_SIZE - len >= addr &&
25730 - (!vma || addr + len <= vma->vm_start))
25731 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25732 return addr;
25733 }
25734
25735 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25736 info.high_limit = mm->mmap_base;
25737 info.align_mask = filp ? get_align_mask() : 0;
25738 info.align_offset = pgoff << PAGE_SHIFT;
25739 + info.threadstack_offset = offset;
25740 addr = vm_unmapped_area(&info);
25741 if (!(addr & ~PAGE_MASK))
25742 return addr;
25743 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25744 index addf7b5..f960685 100644
25745 --- a/arch/x86/kernel/tboot.c
25746 +++ b/arch/x86/kernel/tboot.c
25747 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25748
25749 void tboot_shutdown(u32 shutdown_type)
25750 {
25751 - void (*shutdown)(void);
25752 + void (* __noreturn shutdown)(void);
25753
25754 if (!tboot_enabled())
25755 return;
25756 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25757
25758 switch_to_tboot_pt();
25759
25760 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25761 + shutdown = (void *)tboot->shutdown_entry;
25762 shutdown();
25763
25764 /* should not reach here */
25765 @@ -301,7 +301,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
25766 return 0;
25767 }
25768
25769 -static atomic_t ap_wfs_count;
25770 +static atomic_unchecked_t ap_wfs_count;
25771
25772 static int tboot_wait_for_aps(int num_aps)
25773 {
25774 @@ -325,9 +325,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25775 {
25776 switch (action) {
25777 case CPU_DYING:
25778 - atomic_inc(&ap_wfs_count);
25779 + atomic_inc_unchecked(&ap_wfs_count);
25780 if (num_online_cpus() == 1)
25781 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25782 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25783 return NOTIFY_BAD;
25784 break;
25785 }
25786 @@ -413,7 +413,7 @@ static __init int tboot_late_init(void)
25787
25788 tboot_create_trampoline();
25789
25790 - atomic_set(&ap_wfs_count, 0);
25791 + atomic_set_unchecked(&ap_wfs_count, 0);
25792 register_hotcpu_notifier(&tboot_cpu_notifier);
25793
25794 #ifdef CONFIG_DEBUG_FS
25795 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25796 index 24d3c91..d06b473 100644
25797 --- a/arch/x86/kernel/time.c
25798 +++ b/arch/x86/kernel/time.c
25799 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25800 {
25801 unsigned long pc = instruction_pointer(regs);
25802
25803 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25804 + if (!user_mode(regs) && in_lock_functions(pc)) {
25805 #ifdef CONFIG_FRAME_POINTER
25806 - return *(unsigned long *)(regs->bp + sizeof(long));
25807 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25808 #else
25809 unsigned long *sp =
25810 (unsigned long *)kernel_stack_pointer(regs);
25811 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25812 * or above a saved flags. Eflags has bits 22-31 zero,
25813 * kernel addresses don't.
25814 */
25815 +
25816 +#ifdef CONFIG_PAX_KERNEXEC
25817 + return ktla_ktva(sp[0]);
25818 +#else
25819 if (sp[0] >> 22)
25820 return sp[0];
25821 if (sp[1] >> 22)
25822 return sp[1];
25823 #endif
25824 +
25825 +#endif
25826 }
25827 return pc;
25828 }
25829 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25830 index f7fec09..9991981 100644
25831 --- a/arch/x86/kernel/tls.c
25832 +++ b/arch/x86/kernel/tls.c
25833 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25834 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25835 return -EINVAL;
25836
25837 +#ifdef CONFIG_PAX_SEGMEXEC
25838 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25839 + return -EINVAL;
25840 +#endif
25841 +
25842 set_tls_desc(p, idx, &info, 1);
25843
25844 return 0;
25845 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25846
25847 if (kbuf)
25848 info = kbuf;
25849 - else if (__copy_from_user(infobuf, ubuf, count))
25850 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25851 return -EFAULT;
25852 else
25853 info = infobuf;
25854 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25855 index 1c113db..287b42e 100644
25856 --- a/arch/x86/kernel/tracepoint.c
25857 +++ b/arch/x86/kernel/tracepoint.c
25858 @@ -9,11 +9,11 @@
25859 #include <linux/atomic.h>
25860
25861 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25862 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25863 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25864 (unsigned long) trace_idt_table };
25865
25866 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25867 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25868 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25869
25870 static int trace_irq_vector_refcount;
25871 static DEFINE_MUTEX(irq_vector_mutex);
25872 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25873 index 1b23a1c..910de0d 100644
25874 --- a/arch/x86/kernel/traps.c
25875 +++ b/arch/x86/kernel/traps.c
25876 @@ -65,7 +65,7 @@
25877 #include <asm/proto.h>
25878
25879 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25880 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25881 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25882 #else
25883 #include <asm/processor-flags.h>
25884 #include <asm/setup.h>
25885 @@ -74,7 +74,7 @@ asmlinkage int system_call(void);
25886 #endif
25887
25888 /* Must be page-aligned because the real IDT is used in a fixmap. */
25889 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25890 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25891
25892 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25893 EXPORT_SYMBOL_GPL(used_vectors);
25894 @@ -106,11 +106,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25895 }
25896
25897 static int __kprobes
25898 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25899 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25900 struct pt_regs *regs, long error_code)
25901 {
25902 #ifdef CONFIG_X86_32
25903 - if (regs->flags & X86_VM_MASK) {
25904 + if (v8086_mode(regs)) {
25905 /*
25906 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25907 * On nmi (interrupt 2), do_trap should not be called.
25908 @@ -123,12 +123,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25909 return -1;
25910 }
25911 #endif
25912 - if (!user_mode(regs)) {
25913 + if (!user_mode_novm(regs)) {
25914 if (!fixup_exception(regs)) {
25915 tsk->thread.error_code = error_code;
25916 tsk->thread.trap_nr = trapnr;
25917 +
25918 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25919 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25920 + str = "PAX: suspicious stack segment fault";
25921 +#endif
25922 +
25923 die(str, regs, error_code);
25924 }
25925 +
25926 +#ifdef CONFIG_PAX_REFCOUNT
25927 + if (trapnr == 4)
25928 + pax_report_refcount_overflow(regs);
25929 +#endif
25930 +
25931 return 0;
25932 }
25933
25934 @@ -136,7 +148,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25935 }
25936
25937 static void __kprobes
25938 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25939 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25940 long error_code, siginfo_t *info)
25941 {
25942 struct task_struct *tsk = current;
25943 @@ -160,7 +172,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25944 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25945 printk_ratelimit()) {
25946 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25947 - tsk->comm, tsk->pid, str,
25948 + tsk->comm, task_pid_nr(tsk), str,
25949 regs->ip, regs->sp, error_code);
25950 print_vma_addr(" in ", regs->ip);
25951 pr_cont("\n");
25952 @@ -276,7 +288,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25953 conditional_sti(regs);
25954
25955 #ifdef CONFIG_X86_32
25956 - if (regs->flags & X86_VM_MASK) {
25957 + if (v8086_mode(regs)) {
25958 local_irq_enable();
25959 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25960 goto exit;
25961 @@ -284,18 +296,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25962 #endif
25963
25964 tsk = current;
25965 - if (!user_mode(regs)) {
25966 + if (!user_mode_novm(regs)) {
25967 if (fixup_exception(regs))
25968 goto exit;
25969
25970 tsk->thread.error_code = error_code;
25971 tsk->thread.trap_nr = X86_TRAP_GP;
25972 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25973 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25974 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25975 +
25976 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25977 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25978 + die("PAX: suspicious general protection fault", regs, error_code);
25979 + else
25980 +#endif
25981 +
25982 die("general protection fault", regs, error_code);
25983 + }
25984 goto exit;
25985 }
25986
25987 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25988 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25989 + struct mm_struct *mm = tsk->mm;
25990 + unsigned long limit;
25991 +
25992 + down_write(&mm->mmap_sem);
25993 + limit = mm->context.user_cs_limit;
25994 + if (limit < TASK_SIZE) {
25995 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
25996 + up_write(&mm->mmap_sem);
25997 + return;
25998 + }
25999 + up_write(&mm->mmap_sem);
26000 + }
26001 +#endif
26002 +
26003 tsk->thread.error_code = error_code;
26004 tsk->thread.trap_nr = X86_TRAP_GP;
26005
26006 @@ -453,7 +489,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26007 /* It's safe to allow irq's after DR6 has been saved */
26008 preempt_conditional_sti(regs);
26009
26010 - if (regs->flags & X86_VM_MASK) {
26011 + if (v8086_mode(regs)) {
26012 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26013 X86_TRAP_DB);
26014 preempt_conditional_cli(regs);
26015 @@ -468,7 +504,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26016 * We already checked v86 mode above, so we can check for kernel mode
26017 * by just checking the CPL of CS.
26018 */
26019 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26020 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26021 tsk->thread.debugreg6 &= ~DR_STEP;
26022 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26023 regs->flags &= ~X86_EFLAGS_TF;
26024 @@ -500,7 +536,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26025 return;
26026 conditional_sti(regs);
26027
26028 - if (!user_mode_vm(regs))
26029 + if (!user_mode(regs))
26030 {
26031 if (!fixup_exception(regs)) {
26032 task->thread.error_code = error_code;
26033 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26034 index 2ed8459..7cf329f 100644
26035 --- a/arch/x86/kernel/uprobes.c
26036 +++ b/arch/x86/kernel/uprobes.c
26037 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26038 int ret = NOTIFY_DONE;
26039
26040 /* We are only interested in userspace traps */
26041 - if (regs && !user_mode_vm(regs))
26042 + if (regs && !user_mode(regs))
26043 return NOTIFY_DONE;
26044
26045 switch (val) {
26046 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26047
26048 if (ncopied != rasize) {
26049 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26050 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26051 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26052
26053 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26054 }
26055 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26056 index b9242ba..50c5edd 100644
26057 --- a/arch/x86/kernel/verify_cpu.S
26058 +++ b/arch/x86/kernel/verify_cpu.S
26059 @@ -20,6 +20,7 @@
26060 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26061 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26062 * arch/x86/kernel/head_32.S: processor startup
26063 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26064 *
26065 * verify_cpu, returns the status of longmode and SSE in register %eax.
26066 * 0: Success 1: Failure
26067 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26068 index e8edcf5..27f9344 100644
26069 --- a/arch/x86/kernel/vm86_32.c
26070 +++ b/arch/x86/kernel/vm86_32.c
26071 @@ -44,6 +44,7 @@
26072 #include <linux/ptrace.h>
26073 #include <linux/audit.h>
26074 #include <linux/stddef.h>
26075 +#include <linux/grsecurity.h>
26076
26077 #include <asm/uaccess.h>
26078 #include <asm/io.h>
26079 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26080 do_exit(SIGSEGV);
26081 }
26082
26083 - tss = &per_cpu(init_tss, get_cpu());
26084 + tss = init_tss + get_cpu();
26085 current->thread.sp0 = current->thread.saved_sp0;
26086 current->thread.sysenter_cs = __KERNEL_CS;
26087 load_sp0(tss, &current->thread);
26088 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26089
26090 if (tsk->thread.saved_sp0)
26091 return -EPERM;
26092 +
26093 +#ifdef CONFIG_GRKERNSEC_VM86
26094 + if (!capable(CAP_SYS_RAWIO)) {
26095 + gr_handle_vm86();
26096 + return -EPERM;
26097 + }
26098 +#endif
26099 +
26100 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26101 offsetof(struct kernel_vm86_struct, vm86plus) -
26102 sizeof(info.regs));
26103 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26104 int tmp;
26105 struct vm86plus_struct __user *v86;
26106
26107 +#ifdef CONFIG_GRKERNSEC_VM86
26108 + if (!capable(CAP_SYS_RAWIO)) {
26109 + gr_handle_vm86();
26110 + return -EPERM;
26111 + }
26112 +#endif
26113 +
26114 tsk = current;
26115 switch (cmd) {
26116 case VM86_REQUEST_IRQ:
26117 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26118 tsk->thread.saved_fs = info->regs32->fs;
26119 tsk->thread.saved_gs = get_user_gs(info->regs32);
26120
26121 - tss = &per_cpu(init_tss, get_cpu());
26122 + tss = init_tss + get_cpu();
26123 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26124 if (cpu_has_sep)
26125 tsk->thread.sysenter_cs = 0;
26126 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26127 goto cannot_handle;
26128 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26129 goto cannot_handle;
26130 - intr_ptr = (unsigned long __user *) (i << 2);
26131 + intr_ptr = (__force unsigned long __user *) (i << 2);
26132 if (get_user(segoffs, intr_ptr))
26133 goto cannot_handle;
26134 if ((segoffs >> 16) == BIOSSEG)
26135 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26136 index 10c4f30..65408b9 100644
26137 --- a/arch/x86/kernel/vmlinux.lds.S
26138 +++ b/arch/x86/kernel/vmlinux.lds.S
26139 @@ -26,6 +26,13 @@
26140 #include <asm/page_types.h>
26141 #include <asm/cache.h>
26142 #include <asm/boot.h>
26143 +#include <asm/segment.h>
26144 +
26145 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26146 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26147 +#else
26148 +#define __KERNEL_TEXT_OFFSET 0
26149 +#endif
26150
26151 #undef i386 /* in case the preprocessor is a 32bit one */
26152
26153 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26154
26155 PHDRS {
26156 text PT_LOAD FLAGS(5); /* R_E */
26157 +#ifdef CONFIG_X86_32
26158 + module PT_LOAD FLAGS(5); /* R_E */
26159 +#endif
26160 +#ifdef CONFIG_XEN
26161 + rodata PT_LOAD FLAGS(5); /* R_E */
26162 +#else
26163 + rodata PT_LOAD FLAGS(4); /* R__ */
26164 +#endif
26165 data PT_LOAD FLAGS(6); /* RW_ */
26166 -#ifdef CONFIG_X86_64
26167 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26168 #ifdef CONFIG_SMP
26169 percpu PT_LOAD FLAGS(6); /* RW_ */
26170 #endif
26171 + text.init PT_LOAD FLAGS(5); /* R_E */
26172 + text.exit PT_LOAD FLAGS(5); /* R_E */
26173 init PT_LOAD FLAGS(7); /* RWE */
26174 -#endif
26175 note PT_NOTE FLAGS(0); /* ___ */
26176 }
26177
26178 SECTIONS
26179 {
26180 #ifdef CONFIG_X86_32
26181 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26182 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26183 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26184 #else
26185 - . = __START_KERNEL;
26186 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26187 + . = __START_KERNEL;
26188 #endif
26189
26190 /* Text and read-only data */
26191 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26192 - _text = .;
26193 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26194 /* bootstrapping code */
26195 +#ifdef CONFIG_X86_32
26196 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26197 +#else
26198 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26199 +#endif
26200 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26201 + _text = .;
26202 HEAD_TEXT
26203 . = ALIGN(8);
26204 _stext = .;
26205 @@ -104,13 +124,47 @@ SECTIONS
26206 IRQENTRY_TEXT
26207 *(.fixup)
26208 *(.gnu.warning)
26209 - /* End of text section */
26210 - _etext = .;
26211 } :text = 0x9090
26212
26213 - NOTES :text :note
26214 + . += __KERNEL_TEXT_OFFSET;
26215
26216 - EXCEPTION_TABLE(16) :text = 0x9090
26217 +#ifdef CONFIG_X86_32
26218 + . = ALIGN(PAGE_SIZE);
26219 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26220 +
26221 +#ifdef CONFIG_PAX_KERNEXEC
26222 + MODULES_EXEC_VADDR = .;
26223 + BYTE(0)
26224 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26225 + . = ALIGN(HPAGE_SIZE) - 1;
26226 + MODULES_EXEC_END = .;
26227 +#endif
26228 +
26229 + } :module
26230 +#endif
26231 +
26232 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26233 + /* End of text section */
26234 + BYTE(0)
26235 + _etext = . - __KERNEL_TEXT_OFFSET;
26236 + }
26237 +
26238 +#ifdef CONFIG_X86_32
26239 + . = ALIGN(PAGE_SIZE);
26240 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26241 + . = ALIGN(PAGE_SIZE);
26242 + *(.empty_zero_page)
26243 + *(.initial_pg_fixmap)
26244 + *(.initial_pg_pmd)
26245 + *(.initial_page_table)
26246 + *(.swapper_pg_dir)
26247 + } :rodata
26248 +#endif
26249 +
26250 + . = ALIGN(PAGE_SIZE);
26251 + NOTES :rodata :note
26252 +
26253 + EXCEPTION_TABLE(16) :rodata
26254
26255 #if defined(CONFIG_DEBUG_RODATA)
26256 /* .text should occupy whole number of pages */
26257 @@ -122,16 +176,20 @@ SECTIONS
26258
26259 /* Data */
26260 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26261 +
26262 +#ifdef CONFIG_PAX_KERNEXEC
26263 + . = ALIGN(HPAGE_SIZE);
26264 +#else
26265 + . = ALIGN(PAGE_SIZE);
26266 +#endif
26267 +
26268 /* Start of data section */
26269 _sdata = .;
26270
26271 /* init_task */
26272 INIT_TASK_DATA(THREAD_SIZE)
26273
26274 -#ifdef CONFIG_X86_32
26275 - /* 32 bit has nosave before _edata */
26276 NOSAVE_DATA
26277 -#endif
26278
26279 PAGE_ALIGNED_DATA(PAGE_SIZE)
26280
26281 @@ -172,12 +230,19 @@ SECTIONS
26282 #endif /* CONFIG_X86_64 */
26283
26284 /* Init code and data - will be freed after init */
26285 - . = ALIGN(PAGE_SIZE);
26286 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26287 + BYTE(0)
26288 +
26289 +#ifdef CONFIG_PAX_KERNEXEC
26290 + . = ALIGN(HPAGE_SIZE);
26291 +#else
26292 + . = ALIGN(PAGE_SIZE);
26293 +#endif
26294 +
26295 __init_begin = .; /* paired with __init_end */
26296 - }
26297 + } :init.begin
26298
26299 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26300 +#ifdef CONFIG_SMP
26301 /*
26302 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26303 * output PHDR, so the next output section - .init.text - should
26304 @@ -186,12 +251,27 @@ SECTIONS
26305 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26306 #endif
26307
26308 - INIT_TEXT_SECTION(PAGE_SIZE)
26309 -#ifdef CONFIG_X86_64
26310 - :init
26311 -#endif
26312 + . = ALIGN(PAGE_SIZE);
26313 + init_begin = .;
26314 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26315 + VMLINUX_SYMBOL(_sinittext) = .;
26316 + INIT_TEXT
26317 + VMLINUX_SYMBOL(_einittext) = .;
26318 + . = ALIGN(PAGE_SIZE);
26319 + } :text.init
26320
26321 - INIT_DATA_SECTION(16)
26322 + /*
26323 + * .exit.text is discard at runtime, not link time, to deal with
26324 + * references from .altinstructions and .eh_frame
26325 + */
26326 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26327 + EXIT_TEXT
26328 + . = ALIGN(16);
26329 + } :text.exit
26330 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26331 +
26332 + . = ALIGN(PAGE_SIZE);
26333 + INIT_DATA_SECTION(16) :init
26334
26335 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26336 __x86_cpu_dev_start = .;
26337 @@ -253,19 +333,12 @@ SECTIONS
26338 }
26339
26340 . = ALIGN(8);
26341 - /*
26342 - * .exit.text is discard at runtime, not link time, to deal with
26343 - * references from .altinstructions and .eh_frame
26344 - */
26345 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26346 - EXIT_TEXT
26347 - }
26348
26349 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26350 EXIT_DATA
26351 }
26352
26353 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26354 +#ifndef CONFIG_SMP
26355 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26356 #endif
26357
26358 @@ -284,16 +357,10 @@ SECTIONS
26359 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26360 __smp_locks = .;
26361 *(.smp_locks)
26362 - . = ALIGN(PAGE_SIZE);
26363 __smp_locks_end = .;
26364 + . = ALIGN(PAGE_SIZE);
26365 }
26366
26367 -#ifdef CONFIG_X86_64
26368 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26369 - NOSAVE_DATA
26370 - }
26371 -#endif
26372 -
26373 /* BSS */
26374 . = ALIGN(PAGE_SIZE);
26375 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26376 @@ -309,6 +376,7 @@ SECTIONS
26377 __brk_base = .;
26378 . += 64 * 1024; /* 64k alignment slop space */
26379 *(.brk_reservation) /* areas brk users have reserved */
26380 + . = ALIGN(HPAGE_SIZE);
26381 __brk_limit = .;
26382 }
26383
26384 @@ -335,13 +403,12 @@ SECTIONS
26385 * for the boot processor.
26386 */
26387 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26388 -INIT_PER_CPU(gdt_page);
26389 INIT_PER_CPU(irq_stack_union);
26390
26391 /*
26392 * Build-time check on the image size:
26393 */
26394 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26395 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26396 "kernel image bigger than KERNEL_IMAGE_SIZE");
26397
26398 #ifdef CONFIG_SMP
26399 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26400 index 1f96f93..d5c8f7a 100644
26401 --- a/arch/x86/kernel/vsyscall_64.c
26402 +++ b/arch/x86/kernel/vsyscall_64.c
26403 @@ -56,15 +56,13 @@
26404 DEFINE_VVAR(int, vgetcpu_mode);
26405 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26406
26407 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26408 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26409
26410 static int __init vsyscall_setup(char *str)
26411 {
26412 if (str) {
26413 if (!strcmp("emulate", str))
26414 vsyscall_mode = EMULATE;
26415 - else if (!strcmp("native", str))
26416 - vsyscall_mode = NATIVE;
26417 else if (!strcmp("none", str))
26418 vsyscall_mode = NONE;
26419 else
26420 @@ -323,8 +321,7 @@ do_ret:
26421 return true;
26422
26423 sigsegv:
26424 - force_sig(SIGSEGV, current);
26425 - return true;
26426 + do_group_exit(SIGKILL);
26427 }
26428
26429 /*
26430 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26431 extern char __vvar_page;
26432 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26433
26434 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26435 - vsyscall_mode == NATIVE
26436 - ? PAGE_KERNEL_VSYSCALL
26437 - : PAGE_KERNEL_VVAR);
26438 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26439 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26440 (unsigned long)VSYSCALL_START);
26441
26442 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26443 index b014d94..e775258 100644
26444 --- a/arch/x86/kernel/x8664_ksyms_64.c
26445 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26446 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26447 EXPORT_SYMBOL(copy_user_generic_unrolled);
26448 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26449 EXPORT_SYMBOL(__copy_user_nocache);
26450 -EXPORT_SYMBOL(_copy_from_user);
26451 -EXPORT_SYMBOL(_copy_to_user);
26452
26453 EXPORT_SYMBOL(copy_page);
26454 EXPORT_SYMBOL(clear_page);
26455 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26456 #ifndef CONFIG_PARAVIRT
26457 EXPORT_SYMBOL(native_load_gs_index);
26458 #endif
26459 +
26460 +#ifdef CONFIG_PAX_PER_CPU_PGD
26461 +EXPORT_SYMBOL(cpu_pgd);
26462 +#endif
26463 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26464 index 5f24c71..1dadf09 100644
26465 --- a/arch/x86/kernel/x86_init.c
26466 +++ b/arch/x86/kernel/x86_init.c
26467 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26468 static void default_nmi_init(void) { };
26469 static int default_i8042_detect(void) { return 1; };
26470
26471 -struct x86_platform_ops x86_platform = {
26472 +struct x86_platform_ops x86_platform __read_only = {
26473 .calibrate_tsc = native_calibrate_tsc,
26474 .get_wallclock = mach_get_cmos_time,
26475 .set_wallclock = mach_set_rtc_mmss,
26476 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
26477 };
26478
26479 EXPORT_SYMBOL_GPL(x86_platform);
26480 -struct x86_msi_ops x86_msi = {
26481 +struct x86_msi_ops x86_msi __read_only = {
26482 .setup_msi_irqs = native_setup_msi_irqs,
26483 .compose_msi_msg = native_compose_msi_msg,
26484 .teardown_msi_irq = native_teardown_msi_irq,
26485 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
26486 .setup_hpet_msi = default_setup_hpet_msi,
26487 };
26488
26489 -struct x86_io_apic_ops x86_io_apic_ops = {
26490 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26491 .init = native_io_apic_init_mappings,
26492 .read = native_io_apic_read,
26493 .write = native_io_apic_write,
26494 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26495 index 422fd82..c3687ca 100644
26496 --- a/arch/x86/kernel/xsave.c
26497 +++ b/arch/x86/kernel/xsave.c
26498 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26499 {
26500 int err;
26501
26502 + buf = (struct xsave_struct __user *)____m(buf);
26503 if (use_xsave())
26504 err = xsave_user(buf);
26505 else if (use_fxsr())
26506 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26507 */
26508 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26509 {
26510 + buf = (void __user *)____m(buf);
26511 if (use_xsave()) {
26512 if ((unsigned long)buf % 64 || fx_only) {
26513 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26514 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26515 index a20ecb5..d0e2194 100644
26516 --- a/arch/x86/kvm/cpuid.c
26517 +++ b/arch/x86/kvm/cpuid.c
26518 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26519 struct kvm_cpuid2 *cpuid,
26520 struct kvm_cpuid_entry2 __user *entries)
26521 {
26522 - int r;
26523 + int r, i;
26524
26525 r = -E2BIG;
26526 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26527 goto out;
26528 r = -EFAULT;
26529 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26530 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26531 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26532 goto out;
26533 + for (i = 0; i < cpuid->nent; ++i) {
26534 + struct kvm_cpuid_entry2 cpuid_entry;
26535 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26536 + goto out;
26537 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26538 + }
26539 vcpu->arch.cpuid_nent = cpuid->nent;
26540 kvm_apic_set_version(vcpu);
26541 kvm_x86_ops->cpuid_update(vcpu);
26542 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26543 struct kvm_cpuid2 *cpuid,
26544 struct kvm_cpuid_entry2 __user *entries)
26545 {
26546 - int r;
26547 + int r, i;
26548
26549 r = -E2BIG;
26550 if (cpuid->nent < vcpu->arch.cpuid_nent)
26551 goto out;
26552 r = -EFAULT;
26553 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26554 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26555 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26556 goto out;
26557 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26558 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26559 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26560 + goto out;
26561 + }
26562 return 0;
26563
26564 out:
26565 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26566 index afc1124..3e431f2 100644
26567 --- a/arch/x86/kvm/lapic.c
26568 +++ b/arch/x86/kvm/lapic.c
26569 @@ -55,7 +55,7 @@
26570 #define APIC_BUS_CYCLE_NS 1
26571
26572 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26573 -#define apic_debug(fmt, arg...)
26574 +#define apic_debug(fmt, arg...) do {} while (0)
26575
26576 #define APIC_LVT_NUM 6
26577 /* 14 is the version for Xeon and Pentium 8.4.8*/
26578 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26579 index 7769699..c8aca4a7f 100644
26580 --- a/arch/x86/kvm/paging_tmpl.h
26581 +++ b/arch/x86/kvm/paging_tmpl.h
26582 @@ -208,7 +208,7 @@ retry_walk:
26583 if (unlikely(kvm_is_error_hva(host_addr)))
26584 goto error;
26585
26586 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26587 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26588 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26589 goto error;
26590 walker->ptep_user[walker->level - 1] = ptep_user;
26591 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26592 index c0bc803..6837a50 100644
26593 --- a/arch/x86/kvm/svm.c
26594 +++ b/arch/x86/kvm/svm.c
26595 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26596 int cpu = raw_smp_processor_id();
26597
26598 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26599 +
26600 + pax_open_kernel();
26601 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26602 + pax_close_kernel();
26603 +
26604 load_TR_desc();
26605 }
26606
26607 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26608 #endif
26609 #endif
26610
26611 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26612 + __set_fs(current_thread_info()->addr_limit);
26613 +#endif
26614 +
26615 reload_tss(vcpu);
26616
26617 local_irq_disable();
26618 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26619 index 064d0be..f5f758e 100644
26620 --- a/arch/x86/kvm/vmx.c
26621 +++ b/arch/x86/kvm/vmx.c
26622 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26623 #endif
26624 }
26625
26626 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26627 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26628 {
26629 vmcs_writel(field, vmcs_readl(field) & ~mask);
26630 }
26631
26632 -static void vmcs_set_bits(unsigned long field, u32 mask)
26633 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26634 {
26635 vmcs_writel(field, vmcs_readl(field) | mask);
26636 }
26637 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
26638 struct desc_struct *descs;
26639
26640 descs = (void *)gdt->address;
26641 +
26642 + pax_open_kernel();
26643 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26644 + pax_close_kernel();
26645 +
26646 load_TR_desc();
26647 }
26648
26649 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26650 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26651 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26652
26653 +#ifdef CONFIG_PAX_PER_CPU_PGD
26654 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26655 +#endif
26656 +
26657 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26658 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26659 vmx->loaded_vmcs->cpu = cpu;
26660 @@ -2940,8 +2948,11 @@ static __init int hardware_setup(void)
26661 if (!cpu_has_vmx_flexpriority())
26662 flexpriority_enabled = 0;
26663
26664 - if (!cpu_has_vmx_tpr_shadow())
26665 - kvm_x86_ops->update_cr8_intercept = NULL;
26666 + if (!cpu_has_vmx_tpr_shadow()) {
26667 + pax_open_kernel();
26668 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26669 + pax_close_kernel();
26670 + }
26671
26672 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26673 kvm_disable_largepages();
26674 @@ -2952,13 +2963,15 @@ static __init int hardware_setup(void)
26675 if (!cpu_has_vmx_apicv())
26676 enable_apicv = 0;
26677
26678 + pax_open_kernel();
26679 if (enable_apicv)
26680 - kvm_x86_ops->update_cr8_intercept = NULL;
26681 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26682 else {
26683 - kvm_x86_ops->hwapic_irr_update = NULL;
26684 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26685 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26686 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26687 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26688 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26689 }
26690 + pax_close_kernel();
26691
26692 if (nested)
26693 nested_vmx_setup_ctls_msrs();
26694 @@ -4081,7 +4094,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26695
26696 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26697 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26698 +
26699 +#ifndef CONFIG_PAX_PER_CPU_PGD
26700 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26701 +#endif
26702
26703 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26704 #ifdef CONFIG_X86_64
26705 @@ -4103,7 +4119,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26706 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26707 vmx->host_idt_base = dt.address;
26708
26709 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26710 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26711
26712 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26713 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26714 @@ -7039,6 +7055,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26715 "jmp 2f \n\t"
26716 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26717 "2: "
26718 +
26719 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26720 + "ljmp %[cs],$3f\n\t"
26721 + "3: "
26722 +#endif
26723 +
26724 /* Save guest registers, load host registers, keep flags */
26725 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26726 "pop %0 \n\t"
26727 @@ -7091,6 +7113,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26728 #endif
26729 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26730 [wordsize]"i"(sizeof(ulong))
26731 +
26732 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26733 + ,[cs]"i"(__KERNEL_CS)
26734 +#endif
26735 +
26736 : "cc", "memory"
26737 #ifdef CONFIG_X86_64
26738 , "rax", "rbx", "rdi", "rsi"
26739 @@ -7104,7 +7131,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26740 if (debugctlmsr)
26741 update_debugctlmsr(debugctlmsr);
26742
26743 -#ifndef CONFIG_X86_64
26744 +#ifdef CONFIG_X86_32
26745 /*
26746 * The sysexit path does not restore ds/es, so we must set them to
26747 * a reasonable value ourselves.
26748 @@ -7113,8 +7140,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26749 * may be executed in interrupt context, which saves and restore segments
26750 * around it, nullifying its effect.
26751 */
26752 - loadsegment(ds, __USER_DS);
26753 - loadsegment(es, __USER_DS);
26754 + loadsegment(ds, __KERNEL_DS);
26755 + loadsegment(es, __KERNEL_DS);
26756 + loadsegment(ss, __KERNEL_DS);
26757 +
26758 +#ifdef CONFIG_PAX_KERNEXEC
26759 + loadsegment(fs, __KERNEL_PERCPU);
26760 +#endif
26761 +
26762 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26763 + __set_fs(current_thread_info()->addr_limit);
26764 +#endif
26765 +
26766 #endif
26767
26768 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26769 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26770 index d21bce5..fdae9f1 100644
26771 --- a/arch/x86/kvm/x86.c
26772 +++ b/arch/x86/kvm/x86.c
26773 @@ -1766,8 +1766,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26774 {
26775 struct kvm *kvm = vcpu->kvm;
26776 int lm = is_long_mode(vcpu);
26777 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26778 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26779 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26780 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26781 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26782 : kvm->arch.xen_hvm_config.blob_size_32;
26783 u32 page_num = data & ~PAGE_MASK;
26784 @@ -2650,6 +2650,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26785 if (n < msr_list.nmsrs)
26786 goto out;
26787 r = -EFAULT;
26788 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26789 + goto out;
26790 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26791 num_msrs_to_save * sizeof(u32)))
26792 goto out;
26793 @@ -5344,7 +5346,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26794 };
26795 #endif
26796
26797 -int kvm_arch_init(void *opaque)
26798 +int kvm_arch_init(const void *opaque)
26799 {
26800 int r;
26801 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
26802 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26803 index 6a22c19..1763f04 100644
26804 --- a/arch/x86/lguest/boot.c
26805 +++ b/arch/x86/lguest/boot.c
26806 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26807 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26808 * Launcher to reboot us.
26809 */
26810 -static void lguest_restart(char *reason)
26811 +static __noreturn void lguest_restart(char *reason)
26812 {
26813 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26814 + BUG();
26815 }
26816
26817 /*G:050
26818 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26819 index 00933d5..3a64af9 100644
26820 --- a/arch/x86/lib/atomic64_386_32.S
26821 +++ b/arch/x86/lib/atomic64_386_32.S
26822 @@ -48,6 +48,10 @@ BEGIN(read)
26823 movl (v), %eax
26824 movl 4(v), %edx
26825 RET_ENDP
26826 +BEGIN(read_unchecked)
26827 + movl (v), %eax
26828 + movl 4(v), %edx
26829 +RET_ENDP
26830 #undef v
26831
26832 #define v %esi
26833 @@ -55,6 +59,10 @@ BEGIN(set)
26834 movl %ebx, (v)
26835 movl %ecx, 4(v)
26836 RET_ENDP
26837 +BEGIN(set_unchecked)
26838 + movl %ebx, (v)
26839 + movl %ecx, 4(v)
26840 +RET_ENDP
26841 #undef v
26842
26843 #define v %esi
26844 @@ -70,6 +78,20 @@ RET_ENDP
26845 BEGIN(add)
26846 addl %eax, (v)
26847 adcl %edx, 4(v)
26848 +
26849 +#ifdef CONFIG_PAX_REFCOUNT
26850 + jno 0f
26851 + subl %eax, (v)
26852 + sbbl %edx, 4(v)
26853 + int $4
26854 +0:
26855 + _ASM_EXTABLE(0b, 0b)
26856 +#endif
26857 +
26858 +RET_ENDP
26859 +BEGIN(add_unchecked)
26860 + addl %eax, (v)
26861 + adcl %edx, 4(v)
26862 RET_ENDP
26863 #undef v
26864
26865 @@ -77,6 +99,24 @@ RET_ENDP
26866 BEGIN(add_return)
26867 addl (v), %eax
26868 adcl 4(v), %edx
26869 +
26870 +#ifdef CONFIG_PAX_REFCOUNT
26871 + into
26872 +1234:
26873 + _ASM_EXTABLE(1234b, 2f)
26874 +#endif
26875 +
26876 + movl %eax, (v)
26877 + movl %edx, 4(v)
26878 +
26879 +#ifdef CONFIG_PAX_REFCOUNT
26880 +2:
26881 +#endif
26882 +
26883 +RET_ENDP
26884 +BEGIN(add_return_unchecked)
26885 + addl (v), %eax
26886 + adcl 4(v), %edx
26887 movl %eax, (v)
26888 movl %edx, 4(v)
26889 RET_ENDP
26890 @@ -86,6 +126,20 @@ RET_ENDP
26891 BEGIN(sub)
26892 subl %eax, (v)
26893 sbbl %edx, 4(v)
26894 +
26895 +#ifdef CONFIG_PAX_REFCOUNT
26896 + jno 0f
26897 + addl %eax, (v)
26898 + adcl %edx, 4(v)
26899 + int $4
26900 +0:
26901 + _ASM_EXTABLE(0b, 0b)
26902 +#endif
26903 +
26904 +RET_ENDP
26905 +BEGIN(sub_unchecked)
26906 + subl %eax, (v)
26907 + sbbl %edx, 4(v)
26908 RET_ENDP
26909 #undef v
26910
26911 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26912 sbbl $0, %edx
26913 addl (v), %eax
26914 adcl 4(v), %edx
26915 +
26916 +#ifdef CONFIG_PAX_REFCOUNT
26917 + into
26918 +1234:
26919 + _ASM_EXTABLE(1234b, 2f)
26920 +#endif
26921 +
26922 + movl %eax, (v)
26923 + movl %edx, 4(v)
26924 +
26925 +#ifdef CONFIG_PAX_REFCOUNT
26926 +2:
26927 +#endif
26928 +
26929 +RET_ENDP
26930 +BEGIN(sub_return_unchecked)
26931 + negl %edx
26932 + negl %eax
26933 + sbbl $0, %edx
26934 + addl (v), %eax
26935 + adcl 4(v), %edx
26936 movl %eax, (v)
26937 movl %edx, 4(v)
26938 RET_ENDP
26939 @@ -105,6 +180,20 @@ RET_ENDP
26940 BEGIN(inc)
26941 addl $1, (v)
26942 adcl $0, 4(v)
26943 +
26944 +#ifdef CONFIG_PAX_REFCOUNT
26945 + jno 0f
26946 + subl $1, (v)
26947 + sbbl $0, 4(v)
26948 + int $4
26949 +0:
26950 + _ASM_EXTABLE(0b, 0b)
26951 +#endif
26952 +
26953 +RET_ENDP
26954 +BEGIN(inc_unchecked)
26955 + addl $1, (v)
26956 + adcl $0, 4(v)
26957 RET_ENDP
26958 #undef v
26959
26960 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26961 movl 4(v), %edx
26962 addl $1, %eax
26963 adcl $0, %edx
26964 +
26965 +#ifdef CONFIG_PAX_REFCOUNT
26966 + into
26967 +1234:
26968 + _ASM_EXTABLE(1234b, 2f)
26969 +#endif
26970 +
26971 + movl %eax, (v)
26972 + movl %edx, 4(v)
26973 +
26974 +#ifdef CONFIG_PAX_REFCOUNT
26975 +2:
26976 +#endif
26977 +
26978 +RET_ENDP
26979 +BEGIN(inc_return_unchecked)
26980 + movl (v), %eax
26981 + movl 4(v), %edx
26982 + addl $1, %eax
26983 + adcl $0, %edx
26984 movl %eax, (v)
26985 movl %edx, 4(v)
26986 RET_ENDP
26987 @@ -123,6 +232,20 @@ RET_ENDP
26988 BEGIN(dec)
26989 subl $1, (v)
26990 sbbl $0, 4(v)
26991 +
26992 +#ifdef CONFIG_PAX_REFCOUNT
26993 + jno 0f
26994 + addl $1, (v)
26995 + adcl $0, 4(v)
26996 + int $4
26997 +0:
26998 + _ASM_EXTABLE(0b, 0b)
26999 +#endif
27000 +
27001 +RET_ENDP
27002 +BEGIN(dec_unchecked)
27003 + subl $1, (v)
27004 + sbbl $0, 4(v)
27005 RET_ENDP
27006 #undef v
27007
27008 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27009 movl 4(v), %edx
27010 subl $1, %eax
27011 sbbl $0, %edx
27012 +
27013 +#ifdef CONFIG_PAX_REFCOUNT
27014 + into
27015 +1234:
27016 + _ASM_EXTABLE(1234b, 2f)
27017 +#endif
27018 +
27019 + movl %eax, (v)
27020 + movl %edx, 4(v)
27021 +
27022 +#ifdef CONFIG_PAX_REFCOUNT
27023 +2:
27024 +#endif
27025 +
27026 +RET_ENDP
27027 +BEGIN(dec_return_unchecked)
27028 + movl (v), %eax
27029 + movl 4(v), %edx
27030 + subl $1, %eax
27031 + sbbl $0, %edx
27032 movl %eax, (v)
27033 movl %edx, 4(v)
27034 RET_ENDP
27035 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27036 adcl %edx, %edi
27037 addl (v), %eax
27038 adcl 4(v), %edx
27039 +
27040 +#ifdef CONFIG_PAX_REFCOUNT
27041 + into
27042 +1234:
27043 + _ASM_EXTABLE(1234b, 2f)
27044 +#endif
27045 +
27046 cmpl %eax, %ecx
27047 je 3f
27048 1:
27049 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27050 1:
27051 addl $1, %eax
27052 adcl $0, %edx
27053 +
27054 +#ifdef CONFIG_PAX_REFCOUNT
27055 + into
27056 +1234:
27057 + _ASM_EXTABLE(1234b, 2f)
27058 +#endif
27059 +
27060 movl %eax, (v)
27061 movl %edx, 4(v)
27062 movl $1, %eax
27063 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27064 movl 4(v), %edx
27065 subl $1, %eax
27066 sbbl $0, %edx
27067 +
27068 +#ifdef CONFIG_PAX_REFCOUNT
27069 + into
27070 +1234:
27071 + _ASM_EXTABLE(1234b, 1f)
27072 +#endif
27073 +
27074 js 1f
27075 movl %eax, (v)
27076 movl %edx, 4(v)
27077 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27078 index f5cc9eb..51fa319 100644
27079 --- a/arch/x86/lib/atomic64_cx8_32.S
27080 +++ b/arch/x86/lib/atomic64_cx8_32.S
27081 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27082 CFI_STARTPROC
27083
27084 read64 %ecx
27085 + pax_force_retaddr
27086 ret
27087 CFI_ENDPROC
27088 ENDPROC(atomic64_read_cx8)
27089
27090 +ENTRY(atomic64_read_unchecked_cx8)
27091 + CFI_STARTPROC
27092 +
27093 + read64 %ecx
27094 + pax_force_retaddr
27095 + ret
27096 + CFI_ENDPROC
27097 +ENDPROC(atomic64_read_unchecked_cx8)
27098 +
27099 ENTRY(atomic64_set_cx8)
27100 CFI_STARTPROC
27101
27102 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27103 cmpxchg8b (%esi)
27104 jne 1b
27105
27106 + pax_force_retaddr
27107 ret
27108 CFI_ENDPROC
27109 ENDPROC(atomic64_set_cx8)
27110
27111 +ENTRY(atomic64_set_unchecked_cx8)
27112 + CFI_STARTPROC
27113 +
27114 +1:
27115 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27116 + * are atomic on 586 and newer */
27117 + cmpxchg8b (%esi)
27118 + jne 1b
27119 +
27120 + pax_force_retaddr
27121 + ret
27122 + CFI_ENDPROC
27123 +ENDPROC(atomic64_set_unchecked_cx8)
27124 +
27125 ENTRY(atomic64_xchg_cx8)
27126 CFI_STARTPROC
27127
27128 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27129 cmpxchg8b (%esi)
27130 jne 1b
27131
27132 + pax_force_retaddr
27133 ret
27134 CFI_ENDPROC
27135 ENDPROC(atomic64_xchg_cx8)
27136
27137 -.macro addsub_return func ins insc
27138 -ENTRY(atomic64_\func\()_return_cx8)
27139 +.macro addsub_return func ins insc unchecked=""
27140 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27141 CFI_STARTPROC
27142 SAVE ebp
27143 SAVE ebx
27144 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27145 movl %edx, %ecx
27146 \ins\()l %esi, %ebx
27147 \insc\()l %edi, %ecx
27148 +
27149 +.ifb \unchecked
27150 +#ifdef CONFIG_PAX_REFCOUNT
27151 + into
27152 +2:
27153 + _ASM_EXTABLE(2b, 3f)
27154 +#endif
27155 +.endif
27156 +
27157 LOCK_PREFIX
27158 cmpxchg8b (%ebp)
27159 jne 1b
27160 -
27161 -10:
27162 movl %ebx, %eax
27163 movl %ecx, %edx
27164 +
27165 +.ifb \unchecked
27166 +#ifdef CONFIG_PAX_REFCOUNT
27167 +3:
27168 +#endif
27169 +.endif
27170 +
27171 RESTORE edi
27172 RESTORE esi
27173 RESTORE ebx
27174 RESTORE ebp
27175 + pax_force_retaddr
27176 ret
27177 CFI_ENDPROC
27178 -ENDPROC(atomic64_\func\()_return_cx8)
27179 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27180 .endm
27181
27182 addsub_return add add adc
27183 addsub_return sub sub sbb
27184 +addsub_return add add adc _unchecked
27185 +addsub_return sub sub sbb _unchecked
27186
27187 -.macro incdec_return func ins insc
27188 -ENTRY(atomic64_\func\()_return_cx8)
27189 +.macro incdec_return func ins insc unchecked=""
27190 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27191 CFI_STARTPROC
27192 SAVE ebx
27193
27194 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27195 movl %edx, %ecx
27196 \ins\()l $1, %ebx
27197 \insc\()l $0, %ecx
27198 +
27199 +.ifb \unchecked
27200 +#ifdef CONFIG_PAX_REFCOUNT
27201 + into
27202 +2:
27203 + _ASM_EXTABLE(2b, 3f)
27204 +#endif
27205 +.endif
27206 +
27207 LOCK_PREFIX
27208 cmpxchg8b (%esi)
27209 jne 1b
27210
27211 -10:
27212 movl %ebx, %eax
27213 movl %ecx, %edx
27214 +
27215 +.ifb \unchecked
27216 +#ifdef CONFIG_PAX_REFCOUNT
27217 +3:
27218 +#endif
27219 +.endif
27220 +
27221 RESTORE ebx
27222 + pax_force_retaddr
27223 ret
27224 CFI_ENDPROC
27225 -ENDPROC(atomic64_\func\()_return_cx8)
27226 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27227 .endm
27228
27229 incdec_return inc add adc
27230 incdec_return dec sub sbb
27231 +incdec_return inc add adc _unchecked
27232 +incdec_return dec sub sbb _unchecked
27233
27234 ENTRY(atomic64_dec_if_positive_cx8)
27235 CFI_STARTPROC
27236 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27237 movl %edx, %ecx
27238 subl $1, %ebx
27239 sbb $0, %ecx
27240 +
27241 +#ifdef CONFIG_PAX_REFCOUNT
27242 + into
27243 +1234:
27244 + _ASM_EXTABLE(1234b, 2f)
27245 +#endif
27246 +
27247 js 2f
27248 LOCK_PREFIX
27249 cmpxchg8b (%esi)
27250 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27251 movl %ebx, %eax
27252 movl %ecx, %edx
27253 RESTORE ebx
27254 + pax_force_retaddr
27255 ret
27256 CFI_ENDPROC
27257 ENDPROC(atomic64_dec_if_positive_cx8)
27258 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27259 movl %edx, %ecx
27260 addl %ebp, %ebx
27261 adcl %edi, %ecx
27262 +
27263 +#ifdef CONFIG_PAX_REFCOUNT
27264 + into
27265 +1234:
27266 + _ASM_EXTABLE(1234b, 3f)
27267 +#endif
27268 +
27269 LOCK_PREFIX
27270 cmpxchg8b (%esi)
27271 jne 1b
27272 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27273 CFI_ADJUST_CFA_OFFSET -8
27274 RESTORE ebx
27275 RESTORE ebp
27276 + pax_force_retaddr
27277 ret
27278 4:
27279 cmpl %edx, 4(%esp)
27280 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27281 xorl %ecx, %ecx
27282 addl $1, %ebx
27283 adcl %edx, %ecx
27284 +
27285 +#ifdef CONFIG_PAX_REFCOUNT
27286 + into
27287 +1234:
27288 + _ASM_EXTABLE(1234b, 3f)
27289 +#endif
27290 +
27291 LOCK_PREFIX
27292 cmpxchg8b (%esi)
27293 jne 1b
27294 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27295 movl $1, %eax
27296 3:
27297 RESTORE ebx
27298 + pax_force_retaddr
27299 ret
27300 CFI_ENDPROC
27301 ENDPROC(atomic64_inc_not_zero_cx8)
27302 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27303 index e78b8ee..7e173a8 100644
27304 --- a/arch/x86/lib/checksum_32.S
27305 +++ b/arch/x86/lib/checksum_32.S
27306 @@ -29,7 +29,8 @@
27307 #include <asm/dwarf2.h>
27308 #include <asm/errno.h>
27309 #include <asm/asm.h>
27310 -
27311 +#include <asm/segment.h>
27312 +
27313 /*
27314 * computes a partial checksum, e.g. for TCP/UDP fragments
27315 */
27316 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27317
27318 #define ARGBASE 16
27319 #define FP 12
27320 -
27321 -ENTRY(csum_partial_copy_generic)
27322 +
27323 +ENTRY(csum_partial_copy_generic_to_user)
27324 CFI_STARTPROC
27325 +
27326 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27327 + pushl_cfi %gs
27328 + popl_cfi %es
27329 + jmp csum_partial_copy_generic
27330 +#endif
27331 +
27332 +ENTRY(csum_partial_copy_generic_from_user)
27333 +
27334 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27335 + pushl_cfi %gs
27336 + popl_cfi %ds
27337 +#endif
27338 +
27339 +ENTRY(csum_partial_copy_generic)
27340 subl $4,%esp
27341 CFI_ADJUST_CFA_OFFSET 4
27342 pushl_cfi %edi
27343 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27344 jmp 4f
27345 SRC(1: movw (%esi), %bx )
27346 addl $2, %esi
27347 -DST( movw %bx, (%edi) )
27348 +DST( movw %bx, %es:(%edi) )
27349 addl $2, %edi
27350 addw %bx, %ax
27351 adcl $0, %eax
27352 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27353 SRC(1: movl (%esi), %ebx )
27354 SRC( movl 4(%esi), %edx )
27355 adcl %ebx, %eax
27356 -DST( movl %ebx, (%edi) )
27357 +DST( movl %ebx, %es:(%edi) )
27358 adcl %edx, %eax
27359 -DST( movl %edx, 4(%edi) )
27360 +DST( movl %edx, %es:4(%edi) )
27361
27362 SRC( movl 8(%esi), %ebx )
27363 SRC( movl 12(%esi), %edx )
27364 adcl %ebx, %eax
27365 -DST( movl %ebx, 8(%edi) )
27366 +DST( movl %ebx, %es:8(%edi) )
27367 adcl %edx, %eax
27368 -DST( movl %edx, 12(%edi) )
27369 +DST( movl %edx, %es:12(%edi) )
27370
27371 SRC( movl 16(%esi), %ebx )
27372 SRC( movl 20(%esi), %edx )
27373 adcl %ebx, %eax
27374 -DST( movl %ebx, 16(%edi) )
27375 +DST( movl %ebx, %es:16(%edi) )
27376 adcl %edx, %eax
27377 -DST( movl %edx, 20(%edi) )
27378 +DST( movl %edx, %es:20(%edi) )
27379
27380 SRC( movl 24(%esi), %ebx )
27381 SRC( movl 28(%esi), %edx )
27382 adcl %ebx, %eax
27383 -DST( movl %ebx, 24(%edi) )
27384 +DST( movl %ebx, %es:24(%edi) )
27385 adcl %edx, %eax
27386 -DST( movl %edx, 28(%edi) )
27387 +DST( movl %edx, %es:28(%edi) )
27388
27389 lea 32(%esi), %esi
27390 lea 32(%edi), %edi
27391 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27392 shrl $2, %edx # This clears CF
27393 SRC(3: movl (%esi), %ebx )
27394 adcl %ebx, %eax
27395 -DST( movl %ebx, (%edi) )
27396 +DST( movl %ebx, %es:(%edi) )
27397 lea 4(%esi), %esi
27398 lea 4(%edi), %edi
27399 dec %edx
27400 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27401 jb 5f
27402 SRC( movw (%esi), %cx )
27403 leal 2(%esi), %esi
27404 -DST( movw %cx, (%edi) )
27405 +DST( movw %cx, %es:(%edi) )
27406 leal 2(%edi), %edi
27407 je 6f
27408 shll $16,%ecx
27409 SRC(5: movb (%esi), %cl )
27410 -DST( movb %cl, (%edi) )
27411 +DST( movb %cl, %es:(%edi) )
27412 6: addl %ecx, %eax
27413 adcl $0, %eax
27414 7:
27415 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27416
27417 6001:
27418 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27419 - movl $-EFAULT, (%ebx)
27420 + movl $-EFAULT, %ss:(%ebx)
27421
27422 # zero the complete destination - computing the rest
27423 # is too much work
27424 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27425
27426 6002:
27427 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27428 - movl $-EFAULT,(%ebx)
27429 + movl $-EFAULT,%ss:(%ebx)
27430 jmp 5000b
27431
27432 .previous
27433
27434 + pushl_cfi %ss
27435 + popl_cfi %ds
27436 + pushl_cfi %ss
27437 + popl_cfi %es
27438 popl_cfi %ebx
27439 CFI_RESTORE ebx
27440 popl_cfi %esi
27441 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27442 popl_cfi %ecx # equivalent to addl $4,%esp
27443 ret
27444 CFI_ENDPROC
27445 -ENDPROC(csum_partial_copy_generic)
27446 +ENDPROC(csum_partial_copy_generic_to_user)
27447
27448 #else
27449
27450 /* Version for PentiumII/PPro */
27451
27452 #define ROUND1(x) \
27453 + nop; nop; nop; \
27454 SRC(movl x(%esi), %ebx ) ; \
27455 addl %ebx, %eax ; \
27456 - DST(movl %ebx, x(%edi) ) ;
27457 + DST(movl %ebx, %es:x(%edi)) ;
27458
27459 #define ROUND(x) \
27460 + nop; nop; nop; \
27461 SRC(movl x(%esi), %ebx ) ; \
27462 adcl %ebx, %eax ; \
27463 - DST(movl %ebx, x(%edi) ) ;
27464 + DST(movl %ebx, %es:x(%edi)) ;
27465
27466 #define ARGBASE 12
27467 -
27468 -ENTRY(csum_partial_copy_generic)
27469 +
27470 +ENTRY(csum_partial_copy_generic_to_user)
27471 CFI_STARTPROC
27472 +
27473 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27474 + pushl_cfi %gs
27475 + popl_cfi %es
27476 + jmp csum_partial_copy_generic
27477 +#endif
27478 +
27479 +ENTRY(csum_partial_copy_generic_from_user)
27480 +
27481 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27482 + pushl_cfi %gs
27483 + popl_cfi %ds
27484 +#endif
27485 +
27486 +ENTRY(csum_partial_copy_generic)
27487 pushl_cfi %ebx
27488 CFI_REL_OFFSET ebx, 0
27489 pushl_cfi %edi
27490 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27491 subl %ebx, %edi
27492 lea -1(%esi),%edx
27493 andl $-32,%edx
27494 - lea 3f(%ebx,%ebx), %ebx
27495 + lea 3f(%ebx,%ebx,2), %ebx
27496 testl %esi, %esi
27497 jmp *%ebx
27498 1: addl $64,%esi
27499 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27500 jb 5f
27501 SRC( movw (%esi), %dx )
27502 leal 2(%esi), %esi
27503 -DST( movw %dx, (%edi) )
27504 +DST( movw %dx, %es:(%edi) )
27505 leal 2(%edi), %edi
27506 je 6f
27507 shll $16,%edx
27508 5:
27509 SRC( movb (%esi), %dl )
27510 -DST( movb %dl, (%edi) )
27511 +DST( movb %dl, %es:(%edi) )
27512 6: addl %edx, %eax
27513 adcl $0, %eax
27514 7:
27515 .section .fixup, "ax"
27516 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27517 - movl $-EFAULT, (%ebx)
27518 + movl $-EFAULT, %ss:(%ebx)
27519 # zero the complete destination (computing the rest is too much work)
27520 movl ARGBASE+8(%esp),%edi # dst
27521 movl ARGBASE+12(%esp),%ecx # len
27522 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27523 rep; stosb
27524 jmp 7b
27525 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27526 - movl $-EFAULT, (%ebx)
27527 + movl $-EFAULT, %ss:(%ebx)
27528 jmp 7b
27529 .previous
27530
27531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27532 + pushl_cfi %ss
27533 + popl_cfi %ds
27534 + pushl_cfi %ss
27535 + popl_cfi %es
27536 +#endif
27537 +
27538 popl_cfi %esi
27539 CFI_RESTORE esi
27540 popl_cfi %edi
27541 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27542 CFI_RESTORE ebx
27543 ret
27544 CFI_ENDPROC
27545 -ENDPROC(csum_partial_copy_generic)
27546 +ENDPROC(csum_partial_copy_generic_to_user)
27547
27548 #undef ROUND
27549 #undef ROUND1
27550 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27551 index f2145cf..cea889d 100644
27552 --- a/arch/x86/lib/clear_page_64.S
27553 +++ b/arch/x86/lib/clear_page_64.S
27554 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27555 movl $4096/8,%ecx
27556 xorl %eax,%eax
27557 rep stosq
27558 + pax_force_retaddr
27559 ret
27560 CFI_ENDPROC
27561 ENDPROC(clear_page_c)
27562 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27563 movl $4096,%ecx
27564 xorl %eax,%eax
27565 rep stosb
27566 + pax_force_retaddr
27567 ret
27568 CFI_ENDPROC
27569 ENDPROC(clear_page_c_e)
27570 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27571 leaq 64(%rdi),%rdi
27572 jnz .Lloop
27573 nop
27574 + pax_force_retaddr
27575 ret
27576 CFI_ENDPROC
27577 .Lclear_page_end:
27578 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27579
27580 #include <asm/cpufeature.h>
27581
27582 - .section .altinstr_replacement,"ax"
27583 + .section .altinstr_replacement,"a"
27584 1: .byte 0xeb /* jmp <disp8> */
27585 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27586 2: .byte 0xeb /* jmp <disp8> */
27587 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27588 index 1e572c5..2a162cd 100644
27589 --- a/arch/x86/lib/cmpxchg16b_emu.S
27590 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27591 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27592
27593 popf
27594 mov $1, %al
27595 + pax_force_retaddr
27596 ret
27597
27598 not_same:
27599 popf
27600 xor %al,%al
27601 + pax_force_retaddr
27602 ret
27603
27604 CFI_ENDPROC
27605 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27606 index 176cca6..1166c50 100644
27607 --- a/arch/x86/lib/copy_page_64.S
27608 +++ b/arch/x86/lib/copy_page_64.S
27609 @@ -9,6 +9,7 @@ copy_page_rep:
27610 CFI_STARTPROC
27611 movl $4096/8, %ecx
27612 rep movsq
27613 + pax_force_retaddr
27614 ret
27615 CFI_ENDPROC
27616 ENDPROC(copy_page_rep)
27617 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27618
27619 ENTRY(copy_page)
27620 CFI_STARTPROC
27621 - subq $2*8, %rsp
27622 - CFI_ADJUST_CFA_OFFSET 2*8
27623 + subq $3*8, %rsp
27624 + CFI_ADJUST_CFA_OFFSET 3*8
27625 movq %rbx, (%rsp)
27626 CFI_REL_OFFSET rbx, 0
27627 movq %r12, 1*8(%rsp)
27628 CFI_REL_OFFSET r12, 1*8
27629 + movq %r13, 2*8(%rsp)
27630 + CFI_REL_OFFSET r13, 2*8
27631
27632 movl $(4096/64)-5, %ecx
27633 .p2align 4
27634 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27635 movq 0x8*2(%rsi), %rdx
27636 movq 0x8*3(%rsi), %r8
27637 movq 0x8*4(%rsi), %r9
27638 - movq 0x8*5(%rsi), %r10
27639 + movq 0x8*5(%rsi), %r13
27640 movq 0x8*6(%rsi), %r11
27641 movq 0x8*7(%rsi), %r12
27642
27643 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27644 movq %rdx, 0x8*2(%rdi)
27645 movq %r8, 0x8*3(%rdi)
27646 movq %r9, 0x8*4(%rdi)
27647 - movq %r10, 0x8*5(%rdi)
27648 + movq %r13, 0x8*5(%rdi)
27649 movq %r11, 0x8*6(%rdi)
27650 movq %r12, 0x8*7(%rdi)
27651
27652 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27653 movq 0x8*2(%rsi), %rdx
27654 movq 0x8*3(%rsi), %r8
27655 movq 0x8*4(%rsi), %r9
27656 - movq 0x8*5(%rsi), %r10
27657 + movq 0x8*5(%rsi), %r13
27658 movq 0x8*6(%rsi), %r11
27659 movq 0x8*7(%rsi), %r12
27660
27661 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27662 movq %rdx, 0x8*2(%rdi)
27663 movq %r8, 0x8*3(%rdi)
27664 movq %r9, 0x8*4(%rdi)
27665 - movq %r10, 0x8*5(%rdi)
27666 + movq %r13, 0x8*5(%rdi)
27667 movq %r11, 0x8*6(%rdi)
27668 movq %r12, 0x8*7(%rdi)
27669
27670 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27671 CFI_RESTORE rbx
27672 movq 1*8(%rsp), %r12
27673 CFI_RESTORE r12
27674 - addq $2*8, %rsp
27675 - CFI_ADJUST_CFA_OFFSET -2*8
27676 + movq 2*8(%rsp), %r13
27677 + CFI_RESTORE r13
27678 + addq $3*8, %rsp
27679 + CFI_ADJUST_CFA_OFFSET -3*8
27680 + pax_force_retaddr
27681 ret
27682 .Lcopy_page_end:
27683 CFI_ENDPROC
27684 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27685
27686 #include <asm/cpufeature.h>
27687
27688 - .section .altinstr_replacement,"ax"
27689 + .section .altinstr_replacement,"a"
27690 1: .byte 0xeb /* jmp <disp8> */
27691 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27692 2:
27693 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27694 index a30ca15..6b3f4e1 100644
27695 --- a/arch/x86/lib/copy_user_64.S
27696 +++ b/arch/x86/lib/copy_user_64.S
27697 @@ -18,31 +18,7 @@
27698 #include <asm/alternative-asm.h>
27699 #include <asm/asm.h>
27700 #include <asm/smap.h>
27701 -
27702 -/*
27703 - * By placing feature2 after feature1 in altinstructions section, we logically
27704 - * implement:
27705 - * If CPU has feature2, jmp to alt2 is used
27706 - * else if CPU has feature1, jmp to alt1 is used
27707 - * else jmp to orig is used.
27708 - */
27709 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27710 -0:
27711 - .byte 0xe9 /* 32bit jump */
27712 - .long \orig-1f /* by default jump to orig */
27713 -1:
27714 - .section .altinstr_replacement,"ax"
27715 -2: .byte 0xe9 /* near jump with 32bit immediate */
27716 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27717 -3: .byte 0xe9 /* near jump with 32bit immediate */
27718 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27719 - .previous
27720 -
27721 - .section .altinstructions,"a"
27722 - altinstruction_entry 0b,2b,\feature1,5,5
27723 - altinstruction_entry 0b,3b,\feature2,5,5
27724 - .previous
27725 - .endm
27726 +#include <asm/pgtable.h>
27727
27728 .macro ALIGN_DESTINATION
27729 #ifdef FIX_ALIGNMENT
27730 @@ -70,52 +46,6 @@
27731 #endif
27732 .endm
27733
27734 -/* Standard copy_to_user with segment limit checking */
27735 -ENTRY(_copy_to_user)
27736 - CFI_STARTPROC
27737 - GET_THREAD_INFO(%rax)
27738 - movq %rdi,%rcx
27739 - addq %rdx,%rcx
27740 - jc bad_to_user
27741 - cmpq TI_addr_limit(%rax),%rcx
27742 - ja bad_to_user
27743 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27744 - copy_user_generic_unrolled,copy_user_generic_string, \
27745 - copy_user_enhanced_fast_string
27746 - CFI_ENDPROC
27747 -ENDPROC(_copy_to_user)
27748 -
27749 -/* Standard copy_from_user with segment limit checking */
27750 -ENTRY(_copy_from_user)
27751 - CFI_STARTPROC
27752 - GET_THREAD_INFO(%rax)
27753 - movq %rsi,%rcx
27754 - addq %rdx,%rcx
27755 - jc bad_from_user
27756 - cmpq TI_addr_limit(%rax),%rcx
27757 - ja bad_from_user
27758 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27759 - copy_user_generic_unrolled,copy_user_generic_string, \
27760 - copy_user_enhanced_fast_string
27761 - CFI_ENDPROC
27762 -ENDPROC(_copy_from_user)
27763 -
27764 - .section .fixup,"ax"
27765 - /* must zero dest */
27766 -ENTRY(bad_from_user)
27767 -bad_from_user:
27768 - CFI_STARTPROC
27769 - movl %edx,%ecx
27770 - xorl %eax,%eax
27771 - rep
27772 - stosb
27773 -bad_to_user:
27774 - movl %edx,%eax
27775 - ret
27776 - CFI_ENDPROC
27777 -ENDPROC(bad_from_user)
27778 - .previous
27779 -
27780 /*
27781 * copy_user_generic_unrolled - memory copy with exception handling.
27782 * This version is for CPUs like P4 that don't have efficient micro
27783 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27784 */
27785 ENTRY(copy_user_generic_unrolled)
27786 CFI_STARTPROC
27787 + ASM_PAX_OPEN_USERLAND
27788 ASM_STAC
27789 cmpl $8,%edx
27790 jb 20f /* less then 8 bytes, go to byte copy loop */
27791 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27792 jz 17f
27793 1: movq (%rsi),%r8
27794 2: movq 1*8(%rsi),%r9
27795 -3: movq 2*8(%rsi),%r10
27796 +3: movq 2*8(%rsi),%rax
27797 4: movq 3*8(%rsi),%r11
27798 5: movq %r8,(%rdi)
27799 6: movq %r9,1*8(%rdi)
27800 -7: movq %r10,2*8(%rdi)
27801 +7: movq %rax,2*8(%rdi)
27802 8: movq %r11,3*8(%rdi)
27803 9: movq 4*8(%rsi),%r8
27804 10: movq 5*8(%rsi),%r9
27805 -11: movq 6*8(%rsi),%r10
27806 +11: movq 6*8(%rsi),%rax
27807 12: movq 7*8(%rsi),%r11
27808 13: movq %r8,4*8(%rdi)
27809 14: movq %r9,5*8(%rdi)
27810 -15: movq %r10,6*8(%rdi)
27811 +15: movq %rax,6*8(%rdi)
27812 16: movq %r11,7*8(%rdi)
27813 leaq 64(%rsi),%rsi
27814 leaq 64(%rdi),%rdi
27815 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27816 jnz 21b
27817 23: xor %eax,%eax
27818 ASM_CLAC
27819 + ASM_PAX_CLOSE_USERLAND
27820 + pax_force_retaddr
27821 ret
27822
27823 .section .fixup,"ax"
27824 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27825 */
27826 ENTRY(copy_user_generic_string)
27827 CFI_STARTPROC
27828 + ASM_PAX_OPEN_USERLAND
27829 ASM_STAC
27830 andl %edx,%edx
27831 jz 4f
27832 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27833 movsb
27834 4: xorl %eax,%eax
27835 ASM_CLAC
27836 + ASM_PAX_CLOSE_USERLAND
27837 + pax_force_retaddr
27838 ret
27839
27840 .section .fixup,"ax"
27841 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27842 */
27843 ENTRY(copy_user_enhanced_fast_string)
27844 CFI_STARTPROC
27845 + ASM_PAX_OPEN_USERLAND
27846 ASM_STAC
27847 andl %edx,%edx
27848 jz 2f
27849 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27850 movsb
27851 2: xorl %eax,%eax
27852 ASM_CLAC
27853 + ASM_PAX_CLOSE_USERLAND
27854 + pax_force_retaddr
27855 ret
27856
27857 .section .fixup,"ax"
27858 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27859 index 6a4f43c..55d26f2 100644
27860 --- a/arch/x86/lib/copy_user_nocache_64.S
27861 +++ b/arch/x86/lib/copy_user_nocache_64.S
27862 @@ -8,6 +8,7 @@
27863
27864 #include <linux/linkage.h>
27865 #include <asm/dwarf2.h>
27866 +#include <asm/alternative-asm.h>
27867
27868 #define FIX_ALIGNMENT 1
27869
27870 @@ -16,6 +17,7 @@
27871 #include <asm/thread_info.h>
27872 #include <asm/asm.h>
27873 #include <asm/smap.h>
27874 +#include <asm/pgtable.h>
27875
27876 .macro ALIGN_DESTINATION
27877 #ifdef FIX_ALIGNMENT
27878 @@ -49,6 +51,16 @@
27879 */
27880 ENTRY(__copy_user_nocache)
27881 CFI_STARTPROC
27882 +
27883 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27884 + mov pax_user_shadow_base,%rcx
27885 + cmp %rcx,%rsi
27886 + jae 1f
27887 + add %rcx,%rsi
27888 +1:
27889 +#endif
27890 +
27891 + ASM_PAX_OPEN_USERLAND
27892 ASM_STAC
27893 cmpl $8,%edx
27894 jb 20f /* less then 8 bytes, go to byte copy loop */
27895 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27896 jz 17f
27897 1: movq (%rsi),%r8
27898 2: movq 1*8(%rsi),%r9
27899 -3: movq 2*8(%rsi),%r10
27900 +3: movq 2*8(%rsi),%rax
27901 4: movq 3*8(%rsi),%r11
27902 5: movnti %r8,(%rdi)
27903 6: movnti %r9,1*8(%rdi)
27904 -7: movnti %r10,2*8(%rdi)
27905 +7: movnti %rax,2*8(%rdi)
27906 8: movnti %r11,3*8(%rdi)
27907 9: movq 4*8(%rsi),%r8
27908 10: movq 5*8(%rsi),%r9
27909 -11: movq 6*8(%rsi),%r10
27910 +11: movq 6*8(%rsi),%rax
27911 12: movq 7*8(%rsi),%r11
27912 13: movnti %r8,4*8(%rdi)
27913 14: movnti %r9,5*8(%rdi)
27914 -15: movnti %r10,6*8(%rdi)
27915 +15: movnti %rax,6*8(%rdi)
27916 16: movnti %r11,7*8(%rdi)
27917 leaq 64(%rsi),%rsi
27918 leaq 64(%rdi),%rdi
27919 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27920 jnz 21b
27921 23: xorl %eax,%eax
27922 ASM_CLAC
27923 + ASM_PAX_CLOSE_USERLAND
27924 sfence
27925 + pax_force_retaddr
27926 ret
27927
27928 .section .fixup,"ax"
27929 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27930 index 2419d5f..953ee51 100644
27931 --- a/arch/x86/lib/csum-copy_64.S
27932 +++ b/arch/x86/lib/csum-copy_64.S
27933 @@ -9,6 +9,7 @@
27934 #include <asm/dwarf2.h>
27935 #include <asm/errno.h>
27936 #include <asm/asm.h>
27937 +#include <asm/alternative-asm.h>
27938
27939 /*
27940 * Checksum copy with exception handling.
27941 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27942 CFI_RESTORE rbp
27943 addq $7*8, %rsp
27944 CFI_ADJUST_CFA_OFFSET -7*8
27945 + pax_force_retaddr 0, 1
27946 ret
27947 CFI_RESTORE_STATE
27948
27949 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27950 index 7609e0e..b449b98 100644
27951 --- a/arch/x86/lib/csum-wrappers_64.c
27952 +++ b/arch/x86/lib/csum-wrappers_64.c
27953 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27954 len -= 2;
27955 }
27956 }
27957 + pax_open_userland();
27958 stac();
27959 - isum = csum_partial_copy_generic((__force const void *)src,
27960 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27961 dst, len, isum, errp, NULL);
27962 clac();
27963 + pax_close_userland();
27964 if (unlikely(*errp))
27965 goto out_err;
27966
27967 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27968 }
27969
27970 *errp = 0;
27971 + pax_open_userland();
27972 stac();
27973 - ret = csum_partial_copy_generic(src, (void __force *)dst,
27974 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27975 len, isum, NULL, errp);
27976 clac();
27977 + pax_close_userland();
27978 return ret;
27979 }
27980 EXPORT_SYMBOL(csum_partial_copy_to_user);
27981 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
27982 index a451235..1daa956 100644
27983 --- a/arch/x86/lib/getuser.S
27984 +++ b/arch/x86/lib/getuser.S
27985 @@ -33,17 +33,40 @@
27986 #include <asm/thread_info.h>
27987 #include <asm/asm.h>
27988 #include <asm/smap.h>
27989 +#include <asm/segment.h>
27990 +#include <asm/pgtable.h>
27991 +#include <asm/alternative-asm.h>
27992 +
27993 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27994 +#define __copyuser_seg gs;
27995 +#else
27996 +#define __copyuser_seg
27997 +#endif
27998
27999 .text
28000 ENTRY(__get_user_1)
28001 CFI_STARTPROC
28002 +
28003 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28004 GET_THREAD_INFO(%_ASM_DX)
28005 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28006 jae bad_get_user
28007 ASM_STAC
28008 -1: movzbl (%_ASM_AX),%edx
28009 +
28010 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28011 + mov pax_user_shadow_base,%_ASM_DX
28012 + cmp %_ASM_DX,%_ASM_AX
28013 + jae 1234f
28014 + add %_ASM_DX,%_ASM_AX
28015 +1234:
28016 +#endif
28017 +
28018 +#endif
28019 +
28020 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28021 xor %eax,%eax
28022 ASM_CLAC
28023 + pax_force_retaddr
28024 ret
28025 CFI_ENDPROC
28026 ENDPROC(__get_user_1)
28027 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28028 ENTRY(__get_user_2)
28029 CFI_STARTPROC
28030 add $1,%_ASM_AX
28031 +
28032 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28033 jc bad_get_user
28034 GET_THREAD_INFO(%_ASM_DX)
28035 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28036 jae bad_get_user
28037 ASM_STAC
28038 -2: movzwl -1(%_ASM_AX),%edx
28039 +
28040 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28041 + mov pax_user_shadow_base,%_ASM_DX
28042 + cmp %_ASM_DX,%_ASM_AX
28043 + jae 1234f
28044 + add %_ASM_DX,%_ASM_AX
28045 +1234:
28046 +#endif
28047 +
28048 +#endif
28049 +
28050 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28051 xor %eax,%eax
28052 ASM_CLAC
28053 + pax_force_retaddr
28054 ret
28055 CFI_ENDPROC
28056 ENDPROC(__get_user_2)
28057 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28058 ENTRY(__get_user_4)
28059 CFI_STARTPROC
28060 add $3,%_ASM_AX
28061 +
28062 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28063 jc bad_get_user
28064 GET_THREAD_INFO(%_ASM_DX)
28065 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28066 jae bad_get_user
28067 ASM_STAC
28068 -3: movl -3(%_ASM_AX),%edx
28069 +
28070 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28071 + mov pax_user_shadow_base,%_ASM_DX
28072 + cmp %_ASM_DX,%_ASM_AX
28073 + jae 1234f
28074 + add %_ASM_DX,%_ASM_AX
28075 +1234:
28076 +#endif
28077 +
28078 +#endif
28079 +
28080 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28081 xor %eax,%eax
28082 ASM_CLAC
28083 + pax_force_retaddr
28084 ret
28085 CFI_ENDPROC
28086 ENDPROC(__get_user_4)
28087 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28088 GET_THREAD_INFO(%_ASM_DX)
28089 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28090 jae bad_get_user
28091 +
28092 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28093 + mov pax_user_shadow_base,%_ASM_DX
28094 + cmp %_ASM_DX,%_ASM_AX
28095 + jae 1234f
28096 + add %_ASM_DX,%_ASM_AX
28097 +1234:
28098 +#endif
28099 +
28100 ASM_STAC
28101 4: movq -7(%_ASM_AX),%rdx
28102 xor %eax,%eax
28103 ASM_CLAC
28104 + pax_force_retaddr
28105 ret
28106 #else
28107 add $7,%_ASM_AX
28108 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28109 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28110 jae bad_get_user_8
28111 ASM_STAC
28112 -4: movl -7(%_ASM_AX),%edx
28113 -5: movl -3(%_ASM_AX),%ecx
28114 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28115 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28116 xor %eax,%eax
28117 ASM_CLAC
28118 + pax_force_retaddr
28119 ret
28120 #endif
28121 CFI_ENDPROC
28122 @@ -113,6 +175,7 @@ bad_get_user:
28123 xor %edx,%edx
28124 mov $(-EFAULT),%_ASM_AX
28125 ASM_CLAC
28126 + pax_force_retaddr
28127 ret
28128 CFI_ENDPROC
28129 END(bad_get_user)
28130 @@ -124,6 +187,7 @@ bad_get_user_8:
28131 xor %ecx,%ecx
28132 mov $(-EFAULT),%_ASM_AX
28133 ASM_CLAC
28134 + pax_force_retaddr
28135 ret
28136 CFI_ENDPROC
28137 END(bad_get_user_8)
28138 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28139 index 54fcffe..7be149e 100644
28140 --- a/arch/x86/lib/insn.c
28141 +++ b/arch/x86/lib/insn.c
28142 @@ -20,8 +20,10 @@
28143
28144 #ifdef __KERNEL__
28145 #include <linux/string.h>
28146 +#include <asm/pgtable_types.h>
28147 #else
28148 #include <string.h>
28149 +#define ktla_ktva(addr) addr
28150 #endif
28151 #include <asm/inat.h>
28152 #include <asm/insn.h>
28153 @@ -53,8 +55,8 @@
28154 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28155 {
28156 memset(insn, 0, sizeof(*insn));
28157 - insn->kaddr = kaddr;
28158 - insn->next_byte = kaddr;
28159 + insn->kaddr = ktla_ktva(kaddr);
28160 + insn->next_byte = ktla_ktva(kaddr);
28161 insn->x86_64 = x86_64 ? 1 : 0;
28162 insn->opnd_bytes = 4;
28163 if (x86_64)
28164 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28165 index 05a95e7..326f2fa 100644
28166 --- a/arch/x86/lib/iomap_copy_64.S
28167 +++ b/arch/x86/lib/iomap_copy_64.S
28168 @@ -17,6 +17,7 @@
28169
28170 #include <linux/linkage.h>
28171 #include <asm/dwarf2.h>
28172 +#include <asm/alternative-asm.h>
28173
28174 /*
28175 * override generic version in lib/iomap_copy.c
28176 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28177 CFI_STARTPROC
28178 movl %edx,%ecx
28179 rep movsd
28180 + pax_force_retaddr
28181 ret
28182 CFI_ENDPROC
28183 ENDPROC(__iowrite32_copy)
28184 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28185 index 56313a3..9b59269 100644
28186 --- a/arch/x86/lib/memcpy_64.S
28187 +++ b/arch/x86/lib/memcpy_64.S
28188 @@ -24,7 +24,7 @@
28189 * This gets patched over the unrolled variant (below) via the
28190 * alternative instructions framework:
28191 */
28192 - .section .altinstr_replacement, "ax", @progbits
28193 + .section .altinstr_replacement, "a", @progbits
28194 .Lmemcpy_c:
28195 movq %rdi, %rax
28196 movq %rdx, %rcx
28197 @@ -33,6 +33,7 @@
28198 rep movsq
28199 movl %edx, %ecx
28200 rep movsb
28201 + pax_force_retaddr
28202 ret
28203 .Lmemcpy_e:
28204 .previous
28205 @@ -44,11 +45,12 @@
28206 * This gets patched over the unrolled variant (below) via the
28207 * alternative instructions framework:
28208 */
28209 - .section .altinstr_replacement, "ax", @progbits
28210 + .section .altinstr_replacement, "a", @progbits
28211 .Lmemcpy_c_e:
28212 movq %rdi, %rax
28213 movq %rdx, %rcx
28214 rep movsb
28215 + pax_force_retaddr
28216 ret
28217 .Lmemcpy_e_e:
28218 .previous
28219 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28220 */
28221 movq 0*8(%rsi), %r8
28222 movq 1*8(%rsi), %r9
28223 - movq 2*8(%rsi), %r10
28224 + movq 2*8(%rsi), %rcx
28225 movq 3*8(%rsi), %r11
28226 leaq 4*8(%rsi), %rsi
28227
28228 movq %r8, 0*8(%rdi)
28229 movq %r9, 1*8(%rdi)
28230 - movq %r10, 2*8(%rdi)
28231 + movq %rcx, 2*8(%rdi)
28232 movq %r11, 3*8(%rdi)
28233 leaq 4*8(%rdi), %rdi
28234 jae .Lcopy_forward_loop
28235 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28236 subq $0x20, %rdx
28237 movq -1*8(%rsi), %r8
28238 movq -2*8(%rsi), %r9
28239 - movq -3*8(%rsi), %r10
28240 + movq -3*8(%rsi), %rcx
28241 movq -4*8(%rsi), %r11
28242 leaq -4*8(%rsi), %rsi
28243 movq %r8, -1*8(%rdi)
28244 movq %r9, -2*8(%rdi)
28245 - movq %r10, -3*8(%rdi)
28246 + movq %rcx, -3*8(%rdi)
28247 movq %r11, -4*8(%rdi)
28248 leaq -4*8(%rdi), %rdi
28249 jae .Lcopy_backward_loop
28250 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28251 */
28252 movq 0*8(%rsi), %r8
28253 movq 1*8(%rsi), %r9
28254 - movq -2*8(%rsi, %rdx), %r10
28255 + movq -2*8(%rsi, %rdx), %rcx
28256 movq -1*8(%rsi, %rdx), %r11
28257 movq %r8, 0*8(%rdi)
28258 movq %r9, 1*8(%rdi)
28259 - movq %r10, -2*8(%rdi, %rdx)
28260 + movq %rcx, -2*8(%rdi, %rdx)
28261 movq %r11, -1*8(%rdi, %rdx)
28262 + pax_force_retaddr
28263 retq
28264 .p2align 4
28265 .Lless_16bytes:
28266 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28267 movq -1*8(%rsi, %rdx), %r9
28268 movq %r8, 0*8(%rdi)
28269 movq %r9, -1*8(%rdi, %rdx)
28270 + pax_force_retaddr
28271 retq
28272 .p2align 4
28273 .Lless_8bytes:
28274 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28275 movl -4(%rsi, %rdx), %r8d
28276 movl %ecx, (%rdi)
28277 movl %r8d, -4(%rdi, %rdx)
28278 + pax_force_retaddr
28279 retq
28280 .p2align 4
28281 .Lless_3bytes:
28282 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28283 movb %cl, (%rdi)
28284
28285 .Lend:
28286 + pax_force_retaddr
28287 retq
28288 CFI_ENDPROC
28289 ENDPROC(memcpy)
28290 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28291 index 65268a6..5aa7815 100644
28292 --- a/arch/x86/lib/memmove_64.S
28293 +++ b/arch/x86/lib/memmove_64.S
28294 @@ -61,13 +61,13 @@ ENTRY(memmove)
28295 5:
28296 sub $0x20, %rdx
28297 movq 0*8(%rsi), %r11
28298 - movq 1*8(%rsi), %r10
28299 + movq 1*8(%rsi), %rcx
28300 movq 2*8(%rsi), %r9
28301 movq 3*8(%rsi), %r8
28302 leaq 4*8(%rsi), %rsi
28303
28304 movq %r11, 0*8(%rdi)
28305 - movq %r10, 1*8(%rdi)
28306 + movq %rcx, 1*8(%rdi)
28307 movq %r9, 2*8(%rdi)
28308 movq %r8, 3*8(%rdi)
28309 leaq 4*8(%rdi), %rdi
28310 @@ -81,10 +81,10 @@ ENTRY(memmove)
28311 4:
28312 movq %rdx, %rcx
28313 movq -8(%rsi, %rdx), %r11
28314 - lea -8(%rdi, %rdx), %r10
28315 + lea -8(%rdi, %rdx), %r9
28316 shrq $3, %rcx
28317 rep movsq
28318 - movq %r11, (%r10)
28319 + movq %r11, (%r9)
28320 jmp 13f
28321 .Lmemmove_end_forward:
28322
28323 @@ -95,14 +95,14 @@ ENTRY(memmove)
28324 7:
28325 movq %rdx, %rcx
28326 movq (%rsi), %r11
28327 - movq %rdi, %r10
28328 + movq %rdi, %r9
28329 leaq -8(%rsi, %rdx), %rsi
28330 leaq -8(%rdi, %rdx), %rdi
28331 shrq $3, %rcx
28332 std
28333 rep movsq
28334 cld
28335 - movq %r11, (%r10)
28336 + movq %r11, (%r9)
28337 jmp 13f
28338
28339 /*
28340 @@ -127,13 +127,13 @@ ENTRY(memmove)
28341 8:
28342 subq $0x20, %rdx
28343 movq -1*8(%rsi), %r11
28344 - movq -2*8(%rsi), %r10
28345 + movq -2*8(%rsi), %rcx
28346 movq -3*8(%rsi), %r9
28347 movq -4*8(%rsi), %r8
28348 leaq -4*8(%rsi), %rsi
28349
28350 movq %r11, -1*8(%rdi)
28351 - movq %r10, -2*8(%rdi)
28352 + movq %rcx, -2*8(%rdi)
28353 movq %r9, -3*8(%rdi)
28354 movq %r8, -4*8(%rdi)
28355 leaq -4*8(%rdi), %rdi
28356 @@ -151,11 +151,11 @@ ENTRY(memmove)
28357 * Move data from 16 bytes to 31 bytes.
28358 */
28359 movq 0*8(%rsi), %r11
28360 - movq 1*8(%rsi), %r10
28361 + movq 1*8(%rsi), %rcx
28362 movq -2*8(%rsi, %rdx), %r9
28363 movq -1*8(%rsi, %rdx), %r8
28364 movq %r11, 0*8(%rdi)
28365 - movq %r10, 1*8(%rdi)
28366 + movq %rcx, 1*8(%rdi)
28367 movq %r9, -2*8(%rdi, %rdx)
28368 movq %r8, -1*8(%rdi, %rdx)
28369 jmp 13f
28370 @@ -167,9 +167,9 @@ ENTRY(memmove)
28371 * Move data from 8 bytes to 15 bytes.
28372 */
28373 movq 0*8(%rsi), %r11
28374 - movq -1*8(%rsi, %rdx), %r10
28375 + movq -1*8(%rsi, %rdx), %r9
28376 movq %r11, 0*8(%rdi)
28377 - movq %r10, -1*8(%rdi, %rdx)
28378 + movq %r9, -1*8(%rdi, %rdx)
28379 jmp 13f
28380 10:
28381 cmpq $4, %rdx
28382 @@ -178,9 +178,9 @@ ENTRY(memmove)
28383 * Move data from 4 bytes to 7 bytes.
28384 */
28385 movl (%rsi), %r11d
28386 - movl -4(%rsi, %rdx), %r10d
28387 + movl -4(%rsi, %rdx), %r9d
28388 movl %r11d, (%rdi)
28389 - movl %r10d, -4(%rdi, %rdx)
28390 + movl %r9d, -4(%rdi, %rdx)
28391 jmp 13f
28392 11:
28393 cmp $2, %rdx
28394 @@ -189,9 +189,9 @@ ENTRY(memmove)
28395 * Move data from 2 bytes to 3 bytes.
28396 */
28397 movw (%rsi), %r11w
28398 - movw -2(%rsi, %rdx), %r10w
28399 + movw -2(%rsi, %rdx), %r9w
28400 movw %r11w, (%rdi)
28401 - movw %r10w, -2(%rdi, %rdx)
28402 + movw %r9w, -2(%rdi, %rdx)
28403 jmp 13f
28404 12:
28405 cmp $1, %rdx
28406 @@ -202,14 +202,16 @@ ENTRY(memmove)
28407 movb (%rsi), %r11b
28408 movb %r11b, (%rdi)
28409 13:
28410 + pax_force_retaddr
28411 retq
28412 CFI_ENDPROC
28413
28414 - .section .altinstr_replacement,"ax"
28415 + .section .altinstr_replacement,"a"
28416 .Lmemmove_begin_forward_efs:
28417 /* Forward moving data. */
28418 movq %rdx, %rcx
28419 rep movsb
28420 + pax_force_retaddr
28421 retq
28422 .Lmemmove_end_forward_efs:
28423 .previous
28424 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28425 index 2dcb380..50a78bc 100644
28426 --- a/arch/x86/lib/memset_64.S
28427 +++ b/arch/x86/lib/memset_64.S
28428 @@ -16,7 +16,7 @@
28429 *
28430 * rax original destination
28431 */
28432 - .section .altinstr_replacement, "ax", @progbits
28433 + .section .altinstr_replacement, "a", @progbits
28434 .Lmemset_c:
28435 movq %rdi,%r9
28436 movq %rdx,%rcx
28437 @@ -30,6 +30,7 @@
28438 movl %edx,%ecx
28439 rep stosb
28440 movq %r9,%rax
28441 + pax_force_retaddr
28442 ret
28443 .Lmemset_e:
28444 .previous
28445 @@ -45,13 +46,14 @@
28446 *
28447 * rax original destination
28448 */
28449 - .section .altinstr_replacement, "ax", @progbits
28450 + .section .altinstr_replacement, "a", @progbits
28451 .Lmemset_c_e:
28452 movq %rdi,%r9
28453 movb %sil,%al
28454 movq %rdx,%rcx
28455 rep stosb
28456 movq %r9,%rax
28457 + pax_force_retaddr
28458 ret
28459 .Lmemset_e_e:
28460 .previous
28461 @@ -59,7 +61,7 @@
28462 ENTRY(memset)
28463 ENTRY(__memset)
28464 CFI_STARTPROC
28465 - movq %rdi,%r10
28466 + movq %rdi,%r11
28467
28468 /* expand byte value */
28469 movzbl %sil,%ecx
28470 @@ -117,7 +119,8 @@ ENTRY(__memset)
28471 jnz .Lloop_1
28472
28473 .Lende:
28474 - movq %r10,%rax
28475 + movq %r11,%rax
28476 + pax_force_retaddr
28477 ret
28478
28479 CFI_RESTORE_STATE
28480 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28481 index c9f2d9b..e7fd2c0 100644
28482 --- a/arch/x86/lib/mmx_32.c
28483 +++ b/arch/x86/lib/mmx_32.c
28484 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28485 {
28486 void *p;
28487 int i;
28488 + unsigned long cr0;
28489
28490 if (unlikely(in_interrupt()))
28491 return __memcpy(to, from, len);
28492 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28493 kernel_fpu_begin();
28494
28495 __asm__ __volatile__ (
28496 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28497 - " prefetch 64(%0)\n"
28498 - " prefetch 128(%0)\n"
28499 - " prefetch 192(%0)\n"
28500 - " prefetch 256(%0)\n"
28501 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28502 + " prefetch 64(%1)\n"
28503 + " prefetch 128(%1)\n"
28504 + " prefetch 192(%1)\n"
28505 + " prefetch 256(%1)\n"
28506 "2: \n"
28507 ".section .fixup, \"ax\"\n"
28508 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28509 + "3: \n"
28510 +
28511 +#ifdef CONFIG_PAX_KERNEXEC
28512 + " movl %%cr0, %0\n"
28513 + " movl %0, %%eax\n"
28514 + " andl $0xFFFEFFFF, %%eax\n"
28515 + " movl %%eax, %%cr0\n"
28516 +#endif
28517 +
28518 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28519 +
28520 +#ifdef CONFIG_PAX_KERNEXEC
28521 + " movl %0, %%cr0\n"
28522 +#endif
28523 +
28524 " jmp 2b\n"
28525 ".previous\n"
28526 _ASM_EXTABLE(1b, 3b)
28527 - : : "r" (from));
28528 + : "=&r" (cr0) : "r" (from) : "ax");
28529
28530 for ( ; i > 5; i--) {
28531 __asm__ __volatile__ (
28532 - "1: prefetch 320(%0)\n"
28533 - "2: movq (%0), %%mm0\n"
28534 - " movq 8(%0), %%mm1\n"
28535 - " movq 16(%0), %%mm2\n"
28536 - " movq 24(%0), %%mm3\n"
28537 - " movq %%mm0, (%1)\n"
28538 - " movq %%mm1, 8(%1)\n"
28539 - " movq %%mm2, 16(%1)\n"
28540 - " movq %%mm3, 24(%1)\n"
28541 - " movq 32(%0), %%mm0\n"
28542 - " movq 40(%0), %%mm1\n"
28543 - " movq 48(%0), %%mm2\n"
28544 - " movq 56(%0), %%mm3\n"
28545 - " movq %%mm0, 32(%1)\n"
28546 - " movq %%mm1, 40(%1)\n"
28547 - " movq %%mm2, 48(%1)\n"
28548 - " movq %%mm3, 56(%1)\n"
28549 + "1: prefetch 320(%1)\n"
28550 + "2: movq (%1), %%mm0\n"
28551 + " movq 8(%1), %%mm1\n"
28552 + " movq 16(%1), %%mm2\n"
28553 + " movq 24(%1), %%mm3\n"
28554 + " movq %%mm0, (%2)\n"
28555 + " movq %%mm1, 8(%2)\n"
28556 + " movq %%mm2, 16(%2)\n"
28557 + " movq %%mm3, 24(%2)\n"
28558 + " movq 32(%1), %%mm0\n"
28559 + " movq 40(%1), %%mm1\n"
28560 + " movq 48(%1), %%mm2\n"
28561 + " movq 56(%1), %%mm3\n"
28562 + " movq %%mm0, 32(%2)\n"
28563 + " movq %%mm1, 40(%2)\n"
28564 + " movq %%mm2, 48(%2)\n"
28565 + " movq %%mm3, 56(%2)\n"
28566 ".section .fixup, \"ax\"\n"
28567 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28568 + "3:\n"
28569 +
28570 +#ifdef CONFIG_PAX_KERNEXEC
28571 + " movl %%cr0, %0\n"
28572 + " movl %0, %%eax\n"
28573 + " andl $0xFFFEFFFF, %%eax\n"
28574 + " movl %%eax, %%cr0\n"
28575 +#endif
28576 +
28577 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28578 +
28579 +#ifdef CONFIG_PAX_KERNEXEC
28580 + " movl %0, %%cr0\n"
28581 +#endif
28582 +
28583 " jmp 2b\n"
28584 ".previous\n"
28585 _ASM_EXTABLE(1b, 3b)
28586 - : : "r" (from), "r" (to) : "memory");
28587 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28588
28589 from += 64;
28590 to += 64;
28591 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28592 static void fast_copy_page(void *to, void *from)
28593 {
28594 int i;
28595 + unsigned long cr0;
28596
28597 kernel_fpu_begin();
28598
28599 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28600 * but that is for later. -AV
28601 */
28602 __asm__ __volatile__(
28603 - "1: prefetch (%0)\n"
28604 - " prefetch 64(%0)\n"
28605 - " prefetch 128(%0)\n"
28606 - " prefetch 192(%0)\n"
28607 - " prefetch 256(%0)\n"
28608 + "1: prefetch (%1)\n"
28609 + " prefetch 64(%1)\n"
28610 + " prefetch 128(%1)\n"
28611 + " prefetch 192(%1)\n"
28612 + " prefetch 256(%1)\n"
28613 "2: \n"
28614 ".section .fixup, \"ax\"\n"
28615 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28616 + "3: \n"
28617 +
28618 +#ifdef CONFIG_PAX_KERNEXEC
28619 + " movl %%cr0, %0\n"
28620 + " movl %0, %%eax\n"
28621 + " andl $0xFFFEFFFF, %%eax\n"
28622 + " movl %%eax, %%cr0\n"
28623 +#endif
28624 +
28625 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28626 +
28627 +#ifdef CONFIG_PAX_KERNEXEC
28628 + " movl %0, %%cr0\n"
28629 +#endif
28630 +
28631 " jmp 2b\n"
28632 ".previous\n"
28633 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28634 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28635
28636 for (i = 0; i < (4096-320)/64; i++) {
28637 __asm__ __volatile__ (
28638 - "1: prefetch 320(%0)\n"
28639 - "2: movq (%0), %%mm0\n"
28640 - " movntq %%mm0, (%1)\n"
28641 - " movq 8(%0), %%mm1\n"
28642 - " movntq %%mm1, 8(%1)\n"
28643 - " movq 16(%0), %%mm2\n"
28644 - " movntq %%mm2, 16(%1)\n"
28645 - " movq 24(%0), %%mm3\n"
28646 - " movntq %%mm3, 24(%1)\n"
28647 - " movq 32(%0), %%mm4\n"
28648 - " movntq %%mm4, 32(%1)\n"
28649 - " movq 40(%0), %%mm5\n"
28650 - " movntq %%mm5, 40(%1)\n"
28651 - " movq 48(%0), %%mm6\n"
28652 - " movntq %%mm6, 48(%1)\n"
28653 - " movq 56(%0), %%mm7\n"
28654 - " movntq %%mm7, 56(%1)\n"
28655 + "1: prefetch 320(%1)\n"
28656 + "2: movq (%1), %%mm0\n"
28657 + " movntq %%mm0, (%2)\n"
28658 + " movq 8(%1), %%mm1\n"
28659 + " movntq %%mm1, 8(%2)\n"
28660 + " movq 16(%1), %%mm2\n"
28661 + " movntq %%mm2, 16(%2)\n"
28662 + " movq 24(%1), %%mm3\n"
28663 + " movntq %%mm3, 24(%2)\n"
28664 + " movq 32(%1), %%mm4\n"
28665 + " movntq %%mm4, 32(%2)\n"
28666 + " movq 40(%1), %%mm5\n"
28667 + " movntq %%mm5, 40(%2)\n"
28668 + " movq 48(%1), %%mm6\n"
28669 + " movntq %%mm6, 48(%2)\n"
28670 + " movq 56(%1), %%mm7\n"
28671 + " movntq %%mm7, 56(%2)\n"
28672 ".section .fixup, \"ax\"\n"
28673 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28674 + "3:\n"
28675 +
28676 +#ifdef CONFIG_PAX_KERNEXEC
28677 + " movl %%cr0, %0\n"
28678 + " movl %0, %%eax\n"
28679 + " andl $0xFFFEFFFF, %%eax\n"
28680 + " movl %%eax, %%cr0\n"
28681 +#endif
28682 +
28683 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28684 +
28685 +#ifdef CONFIG_PAX_KERNEXEC
28686 + " movl %0, %%cr0\n"
28687 +#endif
28688 +
28689 " jmp 2b\n"
28690 ".previous\n"
28691 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28692 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28693
28694 from += 64;
28695 to += 64;
28696 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28697 static void fast_copy_page(void *to, void *from)
28698 {
28699 int i;
28700 + unsigned long cr0;
28701
28702 kernel_fpu_begin();
28703
28704 __asm__ __volatile__ (
28705 - "1: prefetch (%0)\n"
28706 - " prefetch 64(%0)\n"
28707 - " prefetch 128(%0)\n"
28708 - " prefetch 192(%0)\n"
28709 - " prefetch 256(%0)\n"
28710 + "1: prefetch (%1)\n"
28711 + " prefetch 64(%1)\n"
28712 + " prefetch 128(%1)\n"
28713 + " prefetch 192(%1)\n"
28714 + " prefetch 256(%1)\n"
28715 "2: \n"
28716 ".section .fixup, \"ax\"\n"
28717 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28718 + "3: \n"
28719 +
28720 +#ifdef CONFIG_PAX_KERNEXEC
28721 + " movl %%cr0, %0\n"
28722 + " movl %0, %%eax\n"
28723 + " andl $0xFFFEFFFF, %%eax\n"
28724 + " movl %%eax, %%cr0\n"
28725 +#endif
28726 +
28727 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28728 +
28729 +#ifdef CONFIG_PAX_KERNEXEC
28730 + " movl %0, %%cr0\n"
28731 +#endif
28732 +
28733 " jmp 2b\n"
28734 ".previous\n"
28735 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28736 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28737
28738 for (i = 0; i < 4096/64; i++) {
28739 __asm__ __volatile__ (
28740 - "1: prefetch 320(%0)\n"
28741 - "2: movq (%0), %%mm0\n"
28742 - " movq 8(%0), %%mm1\n"
28743 - " movq 16(%0), %%mm2\n"
28744 - " movq 24(%0), %%mm3\n"
28745 - " movq %%mm0, (%1)\n"
28746 - " movq %%mm1, 8(%1)\n"
28747 - " movq %%mm2, 16(%1)\n"
28748 - " movq %%mm3, 24(%1)\n"
28749 - " movq 32(%0), %%mm0\n"
28750 - " movq 40(%0), %%mm1\n"
28751 - " movq 48(%0), %%mm2\n"
28752 - " movq 56(%0), %%mm3\n"
28753 - " movq %%mm0, 32(%1)\n"
28754 - " movq %%mm1, 40(%1)\n"
28755 - " movq %%mm2, 48(%1)\n"
28756 - " movq %%mm3, 56(%1)\n"
28757 + "1: prefetch 320(%1)\n"
28758 + "2: movq (%1), %%mm0\n"
28759 + " movq 8(%1), %%mm1\n"
28760 + " movq 16(%1), %%mm2\n"
28761 + " movq 24(%1), %%mm3\n"
28762 + " movq %%mm0, (%2)\n"
28763 + " movq %%mm1, 8(%2)\n"
28764 + " movq %%mm2, 16(%2)\n"
28765 + " movq %%mm3, 24(%2)\n"
28766 + " movq 32(%1), %%mm0\n"
28767 + " movq 40(%1), %%mm1\n"
28768 + " movq 48(%1), %%mm2\n"
28769 + " movq 56(%1), %%mm3\n"
28770 + " movq %%mm0, 32(%2)\n"
28771 + " movq %%mm1, 40(%2)\n"
28772 + " movq %%mm2, 48(%2)\n"
28773 + " movq %%mm3, 56(%2)\n"
28774 ".section .fixup, \"ax\"\n"
28775 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28776 + "3:\n"
28777 +
28778 +#ifdef CONFIG_PAX_KERNEXEC
28779 + " movl %%cr0, %0\n"
28780 + " movl %0, %%eax\n"
28781 + " andl $0xFFFEFFFF, %%eax\n"
28782 + " movl %%eax, %%cr0\n"
28783 +#endif
28784 +
28785 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28786 +
28787 +#ifdef CONFIG_PAX_KERNEXEC
28788 + " movl %0, %%cr0\n"
28789 +#endif
28790 +
28791 " jmp 2b\n"
28792 ".previous\n"
28793 _ASM_EXTABLE(1b, 3b)
28794 - : : "r" (from), "r" (to) : "memory");
28795 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28796
28797 from += 64;
28798 to += 64;
28799 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28800 index f6d13ee..aca5f0b 100644
28801 --- a/arch/x86/lib/msr-reg.S
28802 +++ b/arch/x86/lib/msr-reg.S
28803 @@ -3,6 +3,7 @@
28804 #include <asm/dwarf2.h>
28805 #include <asm/asm.h>
28806 #include <asm/msr.h>
28807 +#include <asm/alternative-asm.h>
28808
28809 #ifdef CONFIG_X86_64
28810 /*
28811 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28812 CFI_STARTPROC
28813 pushq_cfi %rbx
28814 pushq_cfi %rbp
28815 - movq %rdi, %r10 /* Save pointer */
28816 + movq %rdi, %r9 /* Save pointer */
28817 xorl %r11d, %r11d /* Return value */
28818 movl (%rdi), %eax
28819 movl 4(%rdi), %ecx
28820 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28821 movl 28(%rdi), %edi
28822 CFI_REMEMBER_STATE
28823 1: \op
28824 -2: movl %eax, (%r10)
28825 +2: movl %eax, (%r9)
28826 movl %r11d, %eax /* Return value */
28827 - movl %ecx, 4(%r10)
28828 - movl %edx, 8(%r10)
28829 - movl %ebx, 12(%r10)
28830 - movl %ebp, 20(%r10)
28831 - movl %esi, 24(%r10)
28832 - movl %edi, 28(%r10)
28833 + movl %ecx, 4(%r9)
28834 + movl %edx, 8(%r9)
28835 + movl %ebx, 12(%r9)
28836 + movl %ebp, 20(%r9)
28837 + movl %esi, 24(%r9)
28838 + movl %edi, 28(%r9)
28839 popq_cfi %rbp
28840 popq_cfi %rbx
28841 + pax_force_retaddr
28842 ret
28843 3:
28844 CFI_RESTORE_STATE
28845 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28846 index fc6ba17..d4d989d 100644
28847 --- a/arch/x86/lib/putuser.S
28848 +++ b/arch/x86/lib/putuser.S
28849 @@ -16,7 +16,9 @@
28850 #include <asm/errno.h>
28851 #include <asm/asm.h>
28852 #include <asm/smap.h>
28853 -
28854 +#include <asm/segment.h>
28855 +#include <asm/pgtable.h>
28856 +#include <asm/alternative-asm.h>
28857
28858 /*
28859 * __put_user_X
28860 @@ -30,57 +32,125 @@
28861 * as they get called from within inline assembly.
28862 */
28863
28864 -#define ENTER CFI_STARTPROC ; \
28865 - GET_THREAD_INFO(%_ASM_BX)
28866 -#define EXIT ASM_CLAC ; \
28867 - ret ; \
28868 +#define ENTER CFI_STARTPROC
28869 +#define EXIT ASM_CLAC ; \
28870 + pax_force_retaddr ; \
28871 + ret ; \
28872 CFI_ENDPROC
28873
28874 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28875 +#define _DEST %_ASM_CX,%_ASM_BX
28876 +#else
28877 +#define _DEST %_ASM_CX
28878 +#endif
28879 +
28880 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28881 +#define __copyuser_seg gs;
28882 +#else
28883 +#define __copyuser_seg
28884 +#endif
28885 +
28886 .text
28887 ENTRY(__put_user_1)
28888 ENTER
28889 +
28890 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28891 + GET_THREAD_INFO(%_ASM_BX)
28892 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28893 jae bad_put_user
28894 ASM_STAC
28895 -1: movb %al,(%_ASM_CX)
28896 +
28897 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28898 + mov pax_user_shadow_base,%_ASM_BX
28899 + cmp %_ASM_BX,%_ASM_CX
28900 + jb 1234f
28901 + xor %ebx,%ebx
28902 +1234:
28903 +#endif
28904 +
28905 +#endif
28906 +
28907 +1: __copyuser_seg movb %al,(_DEST)
28908 xor %eax,%eax
28909 EXIT
28910 ENDPROC(__put_user_1)
28911
28912 ENTRY(__put_user_2)
28913 ENTER
28914 +
28915 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28916 + GET_THREAD_INFO(%_ASM_BX)
28917 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28918 sub $1,%_ASM_BX
28919 cmp %_ASM_BX,%_ASM_CX
28920 jae bad_put_user
28921 ASM_STAC
28922 -2: movw %ax,(%_ASM_CX)
28923 +
28924 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28925 + mov pax_user_shadow_base,%_ASM_BX
28926 + cmp %_ASM_BX,%_ASM_CX
28927 + jb 1234f
28928 + xor %ebx,%ebx
28929 +1234:
28930 +#endif
28931 +
28932 +#endif
28933 +
28934 +2: __copyuser_seg movw %ax,(_DEST)
28935 xor %eax,%eax
28936 EXIT
28937 ENDPROC(__put_user_2)
28938
28939 ENTRY(__put_user_4)
28940 ENTER
28941 +
28942 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28943 + GET_THREAD_INFO(%_ASM_BX)
28944 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28945 sub $3,%_ASM_BX
28946 cmp %_ASM_BX,%_ASM_CX
28947 jae bad_put_user
28948 ASM_STAC
28949 -3: movl %eax,(%_ASM_CX)
28950 +
28951 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28952 + mov pax_user_shadow_base,%_ASM_BX
28953 + cmp %_ASM_BX,%_ASM_CX
28954 + jb 1234f
28955 + xor %ebx,%ebx
28956 +1234:
28957 +#endif
28958 +
28959 +#endif
28960 +
28961 +3: __copyuser_seg movl %eax,(_DEST)
28962 xor %eax,%eax
28963 EXIT
28964 ENDPROC(__put_user_4)
28965
28966 ENTRY(__put_user_8)
28967 ENTER
28968 +
28969 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28970 + GET_THREAD_INFO(%_ASM_BX)
28971 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28972 sub $7,%_ASM_BX
28973 cmp %_ASM_BX,%_ASM_CX
28974 jae bad_put_user
28975 ASM_STAC
28976 -4: mov %_ASM_AX,(%_ASM_CX)
28977 +
28978 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28979 + mov pax_user_shadow_base,%_ASM_BX
28980 + cmp %_ASM_BX,%_ASM_CX
28981 + jb 1234f
28982 + xor %ebx,%ebx
28983 +1234:
28984 +#endif
28985 +
28986 +#endif
28987 +
28988 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
28989 #ifdef CONFIG_X86_32
28990 -5: movl %edx,4(%_ASM_CX)
28991 +5: __copyuser_seg movl %edx,4(_DEST)
28992 #endif
28993 xor %eax,%eax
28994 EXIT
28995 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
28996 index 1cad221..de671ee 100644
28997 --- a/arch/x86/lib/rwlock.S
28998 +++ b/arch/x86/lib/rwlock.S
28999 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29000 FRAME
29001 0: LOCK_PREFIX
29002 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29003 +
29004 +#ifdef CONFIG_PAX_REFCOUNT
29005 + jno 1234f
29006 + LOCK_PREFIX
29007 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29008 + int $4
29009 +1234:
29010 + _ASM_EXTABLE(1234b, 1234b)
29011 +#endif
29012 +
29013 1: rep; nop
29014 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29015 jne 1b
29016 LOCK_PREFIX
29017 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29018 +
29019 +#ifdef CONFIG_PAX_REFCOUNT
29020 + jno 1234f
29021 + LOCK_PREFIX
29022 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29023 + int $4
29024 +1234:
29025 + _ASM_EXTABLE(1234b, 1234b)
29026 +#endif
29027 +
29028 jnz 0b
29029 ENDFRAME
29030 + pax_force_retaddr
29031 ret
29032 CFI_ENDPROC
29033 END(__write_lock_failed)
29034 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29035 FRAME
29036 0: LOCK_PREFIX
29037 READ_LOCK_SIZE(inc) (%__lock_ptr)
29038 +
29039 +#ifdef CONFIG_PAX_REFCOUNT
29040 + jno 1234f
29041 + LOCK_PREFIX
29042 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29043 + int $4
29044 +1234:
29045 + _ASM_EXTABLE(1234b, 1234b)
29046 +#endif
29047 +
29048 1: rep; nop
29049 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29050 js 1b
29051 LOCK_PREFIX
29052 READ_LOCK_SIZE(dec) (%__lock_ptr)
29053 +
29054 +#ifdef CONFIG_PAX_REFCOUNT
29055 + jno 1234f
29056 + LOCK_PREFIX
29057 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29058 + int $4
29059 +1234:
29060 + _ASM_EXTABLE(1234b, 1234b)
29061 +#endif
29062 +
29063 js 0b
29064 ENDFRAME
29065 + pax_force_retaddr
29066 ret
29067 CFI_ENDPROC
29068 END(__read_lock_failed)
29069 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29070 index 5dff5f0..cadebf4 100644
29071 --- a/arch/x86/lib/rwsem.S
29072 +++ b/arch/x86/lib/rwsem.S
29073 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29074 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29075 CFI_RESTORE __ASM_REG(dx)
29076 restore_common_regs
29077 + pax_force_retaddr
29078 ret
29079 CFI_ENDPROC
29080 ENDPROC(call_rwsem_down_read_failed)
29081 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29082 movq %rax,%rdi
29083 call rwsem_down_write_failed
29084 restore_common_regs
29085 + pax_force_retaddr
29086 ret
29087 CFI_ENDPROC
29088 ENDPROC(call_rwsem_down_write_failed)
29089 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29090 movq %rax,%rdi
29091 call rwsem_wake
29092 restore_common_regs
29093 -1: ret
29094 +1: pax_force_retaddr
29095 + ret
29096 CFI_ENDPROC
29097 ENDPROC(call_rwsem_wake)
29098
29099 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29100 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29101 CFI_RESTORE __ASM_REG(dx)
29102 restore_common_regs
29103 + pax_force_retaddr
29104 ret
29105 CFI_ENDPROC
29106 ENDPROC(call_rwsem_downgrade_wake)
29107 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29108 index a63efd6..ccecad8 100644
29109 --- a/arch/x86/lib/thunk_64.S
29110 +++ b/arch/x86/lib/thunk_64.S
29111 @@ -8,6 +8,7 @@
29112 #include <linux/linkage.h>
29113 #include <asm/dwarf2.h>
29114 #include <asm/calling.h>
29115 +#include <asm/alternative-asm.h>
29116
29117 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29118 .macro THUNK name, func, put_ret_addr_in_rdi=0
29119 @@ -41,5 +42,6 @@
29120 SAVE_ARGS
29121 restore:
29122 RESTORE_ARGS
29123 + pax_force_retaddr
29124 ret
29125 CFI_ENDPROC
29126 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29127 index 3eb18ac..6890bc3 100644
29128 --- a/arch/x86/lib/usercopy_32.c
29129 +++ b/arch/x86/lib/usercopy_32.c
29130 @@ -42,11 +42,13 @@ do { \
29131 int __d0; \
29132 might_fault(); \
29133 __asm__ __volatile__( \
29134 + __COPYUSER_SET_ES \
29135 ASM_STAC "\n" \
29136 "0: rep; stosl\n" \
29137 " movl %2,%0\n" \
29138 "1: rep; stosb\n" \
29139 "2: " ASM_CLAC "\n" \
29140 + __COPYUSER_RESTORE_ES \
29141 ".section .fixup,\"ax\"\n" \
29142 "3: lea 0(%2,%0,4),%0\n" \
29143 " jmp 2b\n" \
29144 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29145
29146 #ifdef CONFIG_X86_INTEL_USERCOPY
29147 static unsigned long
29148 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29149 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29150 {
29151 int d0, d1;
29152 __asm__ __volatile__(
29153 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29154 " .align 2,0x90\n"
29155 "3: movl 0(%4), %%eax\n"
29156 "4: movl 4(%4), %%edx\n"
29157 - "5: movl %%eax, 0(%3)\n"
29158 - "6: movl %%edx, 4(%3)\n"
29159 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29160 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29161 "7: movl 8(%4), %%eax\n"
29162 "8: movl 12(%4),%%edx\n"
29163 - "9: movl %%eax, 8(%3)\n"
29164 - "10: movl %%edx, 12(%3)\n"
29165 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29166 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29167 "11: movl 16(%4), %%eax\n"
29168 "12: movl 20(%4), %%edx\n"
29169 - "13: movl %%eax, 16(%3)\n"
29170 - "14: movl %%edx, 20(%3)\n"
29171 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29172 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29173 "15: movl 24(%4), %%eax\n"
29174 "16: movl 28(%4), %%edx\n"
29175 - "17: movl %%eax, 24(%3)\n"
29176 - "18: movl %%edx, 28(%3)\n"
29177 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29178 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29179 "19: movl 32(%4), %%eax\n"
29180 "20: movl 36(%4), %%edx\n"
29181 - "21: movl %%eax, 32(%3)\n"
29182 - "22: movl %%edx, 36(%3)\n"
29183 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29184 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29185 "23: movl 40(%4), %%eax\n"
29186 "24: movl 44(%4), %%edx\n"
29187 - "25: movl %%eax, 40(%3)\n"
29188 - "26: movl %%edx, 44(%3)\n"
29189 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29190 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29191 "27: movl 48(%4), %%eax\n"
29192 "28: movl 52(%4), %%edx\n"
29193 - "29: movl %%eax, 48(%3)\n"
29194 - "30: movl %%edx, 52(%3)\n"
29195 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29196 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29197 "31: movl 56(%4), %%eax\n"
29198 "32: movl 60(%4), %%edx\n"
29199 - "33: movl %%eax, 56(%3)\n"
29200 - "34: movl %%edx, 60(%3)\n"
29201 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29202 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29203 " addl $-64, %0\n"
29204 " addl $64, %4\n"
29205 " addl $64, %3\n"
29206 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29207 " shrl $2, %0\n"
29208 " andl $3, %%eax\n"
29209 " cld\n"
29210 + __COPYUSER_SET_ES
29211 "99: rep; movsl\n"
29212 "36: movl %%eax, %0\n"
29213 "37: rep; movsb\n"
29214 "100:\n"
29215 + __COPYUSER_RESTORE_ES
29216 ".section .fixup,\"ax\"\n"
29217 "101: lea 0(%%eax,%0,4),%0\n"
29218 " jmp 100b\n"
29219 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29220 }
29221
29222 static unsigned long
29223 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29224 +{
29225 + int d0, d1;
29226 + __asm__ __volatile__(
29227 + " .align 2,0x90\n"
29228 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29229 + " cmpl $67, %0\n"
29230 + " jbe 3f\n"
29231 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29232 + " .align 2,0x90\n"
29233 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29234 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29235 + "5: movl %%eax, 0(%3)\n"
29236 + "6: movl %%edx, 4(%3)\n"
29237 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29238 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29239 + "9: movl %%eax, 8(%3)\n"
29240 + "10: movl %%edx, 12(%3)\n"
29241 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29242 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29243 + "13: movl %%eax, 16(%3)\n"
29244 + "14: movl %%edx, 20(%3)\n"
29245 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29246 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29247 + "17: movl %%eax, 24(%3)\n"
29248 + "18: movl %%edx, 28(%3)\n"
29249 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29250 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29251 + "21: movl %%eax, 32(%3)\n"
29252 + "22: movl %%edx, 36(%3)\n"
29253 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29254 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29255 + "25: movl %%eax, 40(%3)\n"
29256 + "26: movl %%edx, 44(%3)\n"
29257 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29258 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29259 + "29: movl %%eax, 48(%3)\n"
29260 + "30: movl %%edx, 52(%3)\n"
29261 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29262 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29263 + "33: movl %%eax, 56(%3)\n"
29264 + "34: movl %%edx, 60(%3)\n"
29265 + " addl $-64, %0\n"
29266 + " addl $64, %4\n"
29267 + " addl $64, %3\n"
29268 + " cmpl $63, %0\n"
29269 + " ja 1b\n"
29270 + "35: movl %0, %%eax\n"
29271 + " shrl $2, %0\n"
29272 + " andl $3, %%eax\n"
29273 + " cld\n"
29274 + "99: rep; "__copyuser_seg" movsl\n"
29275 + "36: movl %%eax, %0\n"
29276 + "37: rep; "__copyuser_seg" movsb\n"
29277 + "100:\n"
29278 + ".section .fixup,\"ax\"\n"
29279 + "101: lea 0(%%eax,%0,4),%0\n"
29280 + " jmp 100b\n"
29281 + ".previous\n"
29282 + _ASM_EXTABLE(1b,100b)
29283 + _ASM_EXTABLE(2b,100b)
29284 + _ASM_EXTABLE(3b,100b)
29285 + _ASM_EXTABLE(4b,100b)
29286 + _ASM_EXTABLE(5b,100b)
29287 + _ASM_EXTABLE(6b,100b)
29288 + _ASM_EXTABLE(7b,100b)
29289 + _ASM_EXTABLE(8b,100b)
29290 + _ASM_EXTABLE(9b,100b)
29291 + _ASM_EXTABLE(10b,100b)
29292 + _ASM_EXTABLE(11b,100b)
29293 + _ASM_EXTABLE(12b,100b)
29294 + _ASM_EXTABLE(13b,100b)
29295 + _ASM_EXTABLE(14b,100b)
29296 + _ASM_EXTABLE(15b,100b)
29297 + _ASM_EXTABLE(16b,100b)
29298 + _ASM_EXTABLE(17b,100b)
29299 + _ASM_EXTABLE(18b,100b)
29300 + _ASM_EXTABLE(19b,100b)
29301 + _ASM_EXTABLE(20b,100b)
29302 + _ASM_EXTABLE(21b,100b)
29303 + _ASM_EXTABLE(22b,100b)
29304 + _ASM_EXTABLE(23b,100b)
29305 + _ASM_EXTABLE(24b,100b)
29306 + _ASM_EXTABLE(25b,100b)
29307 + _ASM_EXTABLE(26b,100b)
29308 + _ASM_EXTABLE(27b,100b)
29309 + _ASM_EXTABLE(28b,100b)
29310 + _ASM_EXTABLE(29b,100b)
29311 + _ASM_EXTABLE(30b,100b)
29312 + _ASM_EXTABLE(31b,100b)
29313 + _ASM_EXTABLE(32b,100b)
29314 + _ASM_EXTABLE(33b,100b)
29315 + _ASM_EXTABLE(34b,100b)
29316 + _ASM_EXTABLE(35b,100b)
29317 + _ASM_EXTABLE(36b,100b)
29318 + _ASM_EXTABLE(37b,100b)
29319 + _ASM_EXTABLE(99b,101b)
29320 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29321 + : "1"(to), "2"(from), "0"(size)
29322 + : "eax", "edx", "memory");
29323 + return size;
29324 +}
29325 +
29326 +static unsigned long __size_overflow(3)
29327 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29328 {
29329 int d0, d1;
29330 __asm__ __volatile__(
29331 " .align 2,0x90\n"
29332 - "0: movl 32(%4), %%eax\n"
29333 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29334 " cmpl $67, %0\n"
29335 " jbe 2f\n"
29336 - "1: movl 64(%4), %%eax\n"
29337 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29338 " .align 2,0x90\n"
29339 - "2: movl 0(%4), %%eax\n"
29340 - "21: movl 4(%4), %%edx\n"
29341 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29342 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29343 " movl %%eax, 0(%3)\n"
29344 " movl %%edx, 4(%3)\n"
29345 - "3: movl 8(%4), %%eax\n"
29346 - "31: movl 12(%4),%%edx\n"
29347 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29348 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29349 " movl %%eax, 8(%3)\n"
29350 " movl %%edx, 12(%3)\n"
29351 - "4: movl 16(%4), %%eax\n"
29352 - "41: movl 20(%4), %%edx\n"
29353 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29354 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29355 " movl %%eax, 16(%3)\n"
29356 " movl %%edx, 20(%3)\n"
29357 - "10: movl 24(%4), %%eax\n"
29358 - "51: movl 28(%4), %%edx\n"
29359 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29360 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29361 " movl %%eax, 24(%3)\n"
29362 " movl %%edx, 28(%3)\n"
29363 - "11: movl 32(%4), %%eax\n"
29364 - "61: movl 36(%4), %%edx\n"
29365 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29366 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29367 " movl %%eax, 32(%3)\n"
29368 " movl %%edx, 36(%3)\n"
29369 - "12: movl 40(%4), %%eax\n"
29370 - "71: movl 44(%4), %%edx\n"
29371 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29372 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29373 " movl %%eax, 40(%3)\n"
29374 " movl %%edx, 44(%3)\n"
29375 - "13: movl 48(%4), %%eax\n"
29376 - "81: movl 52(%4), %%edx\n"
29377 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29378 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29379 " movl %%eax, 48(%3)\n"
29380 " movl %%edx, 52(%3)\n"
29381 - "14: movl 56(%4), %%eax\n"
29382 - "91: movl 60(%4), %%edx\n"
29383 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29384 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29385 " movl %%eax, 56(%3)\n"
29386 " movl %%edx, 60(%3)\n"
29387 " addl $-64, %0\n"
29388 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29389 " shrl $2, %0\n"
29390 " andl $3, %%eax\n"
29391 " cld\n"
29392 - "6: rep; movsl\n"
29393 + "6: rep; "__copyuser_seg" movsl\n"
29394 " movl %%eax,%0\n"
29395 - "7: rep; movsb\n"
29396 + "7: rep; "__copyuser_seg" movsb\n"
29397 "8:\n"
29398 ".section .fixup,\"ax\"\n"
29399 "9: lea 0(%%eax,%0,4),%0\n"
29400 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29401 * hyoshiok@miraclelinux.com
29402 */
29403
29404 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29405 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
29406 const void __user *from, unsigned long size)
29407 {
29408 int d0, d1;
29409
29410 __asm__ __volatile__(
29411 " .align 2,0x90\n"
29412 - "0: movl 32(%4), %%eax\n"
29413 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29414 " cmpl $67, %0\n"
29415 " jbe 2f\n"
29416 - "1: movl 64(%4), %%eax\n"
29417 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29418 " .align 2,0x90\n"
29419 - "2: movl 0(%4), %%eax\n"
29420 - "21: movl 4(%4), %%edx\n"
29421 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29422 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29423 " movnti %%eax, 0(%3)\n"
29424 " movnti %%edx, 4(%3)\n"
29425 - "3: movl 8(%4), %%eax\n"
29426 - "31: movl 12(%4),%%edx\n"
29427 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29428 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29429 " movnti %%eax, 8(%3)\n"
29430 " movnti %%edx, 12(%3)\n"
29431 - "4: movl 16(%4), %%eax\n"
29432 - "41: movl 20(%4), %%edx\n"
29433 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29434 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29435 " movnti %%eax, 16(%3)\n"
29436 " movnti %%edx, 20(%3)\n"
29437 - "10: movl 24(%4), %%eax\n"
29438 - "51: movl 28(%4), %%edx\n"
29439 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29440 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29441 " movnti %%eax, 24(%3)\n"
29442 " movnti %%edx, 28(%3)\n"
29443 - "11: movl 32(%4), %%eax\n"
29444 - "61: movl 36(%4), %%edx\n"
29445 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29446 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29447 " movnti %%eax, 32(%3)\n"
29448 " movnti %%edx, 36(%3)\n"
29449 - "12: movl 40(%4), %%eax\n"
29450 - "71: movl 44(%4), %%edx\n"
29451 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29452 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29453 " movnti %%eax, 40(%3)\n"
29454 " movnti %%edx, 44(%3)\n"
29455 - "13: movl 48(%4), %%eax\n"
29456 - "81: movl 52(%4), %%edx\n"
29457 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29458 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29459 " movnti %%eax, 48(%3)\n"
29460 " movnti %%edx, 52(%3)\n"
29461 - "14: movl 56(%4), %%eax\n"
29462 - "91: movl 60(%4), %%edx\n"
29463 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29464 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29465 " movnti %%eax, 56(%3)\n"
29466 " movnti %%edx, 60(%3)\n"
29467 " addl $-64, %0\n"
29468 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29469 " shrl $2, %0\n"
29470 " andl $3, %%eax\n"
29471 " cld\n"
29472 - "6: rep; movsl\n"
29473 + "6: rep; "__copyuser_seg" movsl\n"
29474 " movl %%eax,%0\n"
29475 - "7: rep; movsb\n"
29476 + "7: rep; "__copyuser_seg" movsb\n"
29477 "8:\n"
29478 ".section .fixup,\"ax\"\n"
29479 "9: lea 0(%%eax,%0,4),%0\n"
29480 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29481 return size;
29482 }
29483
29484 -static unsigned long __copy_user_intel_nocache(void *to,
29485 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
29486 const void __user *from, unsigned long size)
29487 {
29488 int d0, d1;
29489
29490 __asm__ __volatile__(
29491 " .align 2,0x90\n"
29492 - "0: movl 32(%4), %%eax\n"
29493 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29494 " cmpl $67, %0\n"
29495 " jbe 2f\n"
29496 - "1: movl 64(%4), %%eax\n"
29497 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29498 " .align 2,0x90\n"
29499 - "2: movl 0(%4), %%eax\n"
29500 - "21: movl 4(%4), %%edx\n"
29501 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29502 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29503 " movnti %%eax, 0(%3)\n"
29504 " movnti %%edx, 4(%3)\n"
29505 - "3: movl 8(%4), %%eax\n"
29506 - "31: movl 12(%4),%%edx\n"
29507 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29508 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29509 " movnti %%eax, 8(%3)\n"
29510 " movnti %%edx, 12(%3)\n"
29511 - "4: movl 16(%4), %%eax\n"
29512 - "41: movl 20(%4), %%edx\n"
29513 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29514 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29515 " movnti %%eax, 16(%3)\n"
29516 " movnti %%edx, 20(%3)\n"
29517 - "10: movl 24(%4), %%eax\n"
29518 - "51: movl 28(%4), %%edx\n"
29519 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29520 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29521 " movnti %%eax, 24(%3)\n"
29522 " movnti %%edx, 28(%3)\n"
29523 - "11: movl 32(%4), %%eax\n"
29524 - "61: movl 36(%4), %%edx\n"
29525 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29526 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29527 " movnti %%eax, 32(%3)\n"
29528 " movnti %%edx, 36(%3)\n"
29529 - "12: movl 40(%4), %%eax\n"
29530 - "71: movl 44(%4), %%edx\n"
29531 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29532 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29533 " movnti %%eax, 40(%3)\n"
29534 " movnti %%edx, 44(%3)\n"
29535 - "13: movl 48(%4), %%eax\n"
29536 - "81: movl 52(%4), %%edx\n"
29537 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29538 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29539 " movnti %%eax, 48(%3)\n"
29540 " movnti %%edx, 52(%3)\n"
29541 - "14: movl 56(%4), %%eax\n"
29542 - "91: movl 60(%4), %%edx\n"
29543 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29544 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29545 " movnti %%eax, 56(%3)\n"
29546 " movnti %%edx, 60(%3)\n"
29547 " addl $-64, %0\n"
29548 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29549 " shrl $2, %0\n"
29550 " andl $3, %%eax\n"
29551 " cld\n"
29552 - "6: rep; movsl\n"
29553 + "6: rep; "__copyuser_seg" movsl\n"
29554 " movl %%eax,%0\n"
29555 - "7: rep; movsb\n"
29556 + "7: rep; "__copyuser_seg" movsb\n"
29557 "8:\n"
29558 ".section .fixup,\"ax\"\n"
29559 "9: lea 0(%%eax,%0,4),%0\n"
29560 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29561 */
29562 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29563 unsigned long size);
29564 -unsigned long __copy_user_intel(void __user *to, const void *from,
29565 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29566 + unsigned long size);
29567 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29568 unsigned long size);
29569 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29570 const void __user *from, unsigned long size);
29571 #endif /* CONFIG_X86_INTEL_USERCOPY */
29572
29573 /* Generic arbitrary sized copy. */
29574 -#define __copy_user(to, from, size) \
29575 +#define __copy_user(to, from, size, prefix, set, restore) \
29576 do { \
29577 int __d0, __d1, __d2; \
29578 __asm__ __volatile__( \
29579 + set \
29580 " cmp $7,%0\n" \
29581 " jbe 1f\n" \
29582 " movl %1,%0\n" \
29583 " negl %0\n" \
29584 " andl $7,%0\n" \
29585 " subl %0,%3\n" \
29586 - "4: rep; movsb\n" \
29587 + "4: rep; "prefix"movsb\n" \
29588 " movl %3,%0\n" \
29589 " shrl $2,%0\n" \
29590 " andl $3,%3\n" \
29591 " .align 2,0x90\n" \
29592 - "0: rep; movsl\n" \
29593 + "0: rep; "prefix"movsl\n" \
29594 " movl %3,%0\n" \
29595 - "1: rep; movsb\n" \
29596 + "1: rep; "prefix"movsb\n" \
29597 "2:\n" \
29598 + restore \
29599 ".section .fixup,\"ax\"\n" \
29600 "5: addl %3,%0\n" \
29601 " jmp 2b\n" \
29602 @@ -538,14 +650,14 @@ do { \
29603 " negl %0\n" \
29604 " andl $7,%0\n" \
29605 " subl %0,%3\n" \
29606 - "4: rep; movsb\n" \
29607 + "4: rep; "__copyuser_seg"movsb\n" \
29608 " movl %3,%0\n" \
29609 " shrl $2,%0\n" \
29610 " andl $3,%3\n" \
29611 " .align 2,0x90\n" \
29612 - "0: rep; movsl\n" \
29613 + "0: rep; "__copyuser_seg"movsl\n" \
29614 " movl %3,%0\n" \
29615 - "1: rep; movsb\n" \
29616 + "1: rep; "__copyuser_seg"movsb\n" \
29617 "2:\n" \
29618 ".section .fixup,\"ax\"\n" \
29619 "5: addl %3,%0\n" \
29620 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29621 {
29622 stac();
29623 if (movsl_is_ok(to, from, n))
29624 - __copy_user(to, from, n);
29625 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29626 else
29627 - n = __copy_user_intel(to, from, n);
29628 + n = __generic_copy_to_user_intel(to, from, n);
29629 clac();
29630 return n;
29631 }
29632 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29633 {
29634 stac();
29635 if (movsl_is_ok(to, from, n))
29636 - __copy_user(to, from, n);
29637 + __copy_user(to, from, n, __copyuser_seg, "", "");
29638 else
29639 - n = __copy_user_intel((void __user *)to,
29640 - (const void *)from, n);
29641 + n = __generic_copy_from_user_intel(to, from, n);
29642 clac();
29643 return n;
29644 }
29645 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29646 if (n > 64 && cpu_has_xmm2)
29647 n = __copy_user_intel_nocache(to, from, n);
29648 else
29649 - __copy_user(to, from, n);
29650 + __copy_user(to, from, n, __copyuser_seg, "", "");
29651 #else
29652 - __copy_user(to, from, n);
29653 + __copy_user(to, from, n, __copyuser_seg, "", "");
29654 #endif
29655 clac();
29656 return n;
29657 }
29658 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29659
29660 -/**
29661 - * copy_to_user: - Copy a block of data into user space.
29662 - * @to: Destination address, in user space.
29663 - * @from: Source address, in kernel space.
29664 - * @n: Number of bytes to copy.
29665 - *
29666 - * Context: User context only. This function may sleep.
29667 - *
29668 - * Copy data from kernel space to user space.
29669 - *
29670 - * Returns number of bytes that could not be copied.
29671 - * On success, this will be zero.
29672 - */
29673 -unsigned long
29674 -copy_to_user(void __user *to, const void *from, unsigned long n)
29675 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29676 +void __set_fs(mm_segment_t x)
29677 {
29678 - if (access_ok(VERIFY_WRITE, to, n))
29679 - n = __copy_to_user(to, from, n);
29680 - return n;
29681 + switch (x.seg) {
29682 + case 0:
29683 + loadsegment(gs, 0);
29684 + break;
29685 + case TASK_SIZE_MAX:
29686 + loadsegment(gs, __USER_DS);
29687 + break;
29688 + case -1UL:
29689 + loadsegment(gs, __KERNEL_DS);
29690 + break;
29691 + default:
29692 + BUG();
29693 + }
29694 }
29695 -EXPORT_SYMBOL(copy_to_user);
29696 +EXPORT_SYMBOL(__set_fs);
29697
29698 -/**
29699 - * copy_from_user: - Copy a block of data from user space.
29700 - * @to: Destination address, in kernel space.
29701 - * @from: Source address, in user space.
29702 - * @n: Number of bytes to copy.
29703 - *
29704 - * Context: User context only. This function may sleep.
29705 - *
29706 - * Copy data from user space to kernel space.
29707 - *
29708 - * Returns number of bytes that could not be copied.
29709 - * On success, this will be zero.
29710 - *
29711 - * If some data could not be copied, this function will pad the copied
29712 - * data to the requested size using zero bytes.
29713 - */
29714 -unsigned long
29715 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29716 +void set_fs(mm_segment_t x)
29717 {
29718 - if (access_ok(VERIFY_READ, from, n))
29719 - n = __copy_from_user(to, from, n);
29720 - else
29721 - memset(to, 0, n);
29722 - return n;
29723 + current_thread_info()->addr_limit = x;
29724 + __set_fs(x);
29725 }
29726 -EXPORT_SYMBOL(_copy_from_user);
29727 +EXPORT_SYMBOL(set_fs);
29728 +#endif
29729 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29730 index 906fea3..0194a18 100644
29731 --- a/arch/x86/lib/usercopy_64.c
29732 +++ b/arch/x86/lib/usercopy_64.c
29733 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29734 might_fault();
29735 /* no memory constraint because it doesn't change any memory gcc knows
29736 about */
29737 + pax_open_userland();
29738 stac();
29739 asm volatile(
29740 " testq %[size8],%[size8]\n"
29741 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29742 _ASM_EXTABLE(0b,3b)
29743 _ASM_EXTABLE(1b,2b)
29744 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29745 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29746 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29747 [zero] "r" (0UL), [eight] "r" (8UL));
29748 clac();
29749 + pax_close_userland();
29750 return size;
29751 }
29752 EXPORT_SYMBOL(__clear_user);
29753 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29754 }
29755 EXPORT_SYMBOL(clear_user);
29756
29757 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29758 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29759 {
29760 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29761 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29762 - }
29763 - return len;
29764 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29765 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29766 + return len;
29767 }
29768 EXPORT_SYMBOL(copy_in_user);
29769
29770 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29771 * it is not necessary to optimize tail handling.
29772 */
29773 unsigned long
29774 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29775 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29776 {
29777 char c;
29778 unsigned zero_len;
29779
29780 + clac();
29781 + pax_close_userland();
29782 for (; len; --len, to++) {
29783 if (__get_user_nocheck(c, from++, sizeof(char)))
29784 break;
29785 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29786 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29787 if (__put_user_nocheck(c, to++, sizeof(char)))
29788 break;
29789 - clac();
29790 return len;
29791 }
29792 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29793 index 23d8e5f..9ccc13a 100644
29794 --- a/arch/x86/mm/Makefile
29795 +++ b/arch/x86/mm/Makefile
29796 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29797 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29798
29799 obj-$(CONFIG_MEMTEST) += memtest.o
29800 +
29801 +quote:="
29802 +obj-$(CONFIG_X86_64) += uderef_64.o
29803 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29804 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29805 index 903ec1e..c4166b2 100644
29806 --- a/arch/x86/mm/extable.c
29807 +++ b/arch/x86/mm/extable.c
29808 @@ -6,12 +6,24 @@
29809 static inline unsigned long
29810 ex_insn_addr(const struct exception_table_entry *x)
29811 {
29812 - return (unsigned long)&x->insn + x->insn;
29813 + unsigned long reloc = 0;
29814 +
29815 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29816 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29817 +#endif
29818 +
29819 + return (unsigned long)&x->insn + x->insn + reloc;
29820 }
29821 static inline unsigned long
29822 ex_fixup_addr(const struct exception_table_entry *x)
29823 {
29824 - return (unsigned long)&x->fixup + x->fixup;
29825 + unsigned long reloc = 0;
29826 +
29827 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29828 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29829 +#endif
29830 +
29831 + return (unsigned long)&x->fixup + x->fixup + reloc;
29832 }
29833
29834 int fixup_exception(struct pt_regs *regs)
29835 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29836 unsigned long new_ip;
29837
29838 #ifdef CONFIG_PNPBIOS
29839 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29840 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29841 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29842 extern u32 pnp_bios_is_utter_crap;
29843 pnp_bios_is_utter_crap = 1;
29844 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29845 i += 4;
29846 p->fixup -= i;
29847 i += 4;
29848 +
29849 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29850 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29851 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29852 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29853 +#endif
29854 +
29855 }
29856 }
29857
29858 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29859 index 654be4a..a4a3da1 100644
29860 --- a/arch/x86/mm/fault.c
29861 +++ b/arch/x86/mm/fault.c
29862 @@ -14,11 +14,18 @@
29863 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29864 #include <linux/prefetch.h> /* prefetchw */
29865 #include <linux/context_tracking.h> /* exception_enter(), ... */
29866 +#include <linux/unistd.h>
29867 +#include <linux/compiler.h>
29868
29869 #include <asm/traps.h> /* dotraplinkage, ... */
29870 #include <asm/pgalloc.h> /* pgd_*(), ... */
29871 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29872 #include <asm/fixmap.h> /* VSYSCALL_START */
29873 +#include <asm/tlbflush.h>
29874 +
29875 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29876 +#include <asm/stacktrace.h>
29877 +#endif
29878
29879 /*
29880 * Page fault error code bits:
29881 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29882 int ret = 0;
29883
29884 /* kprobe_running() needs smp_processor_id() */
29885 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29886 + if (kprobes_built_in() && !user_mode(regs)) {
29887 preempt_disable();
29888 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29889 ret = 1;
29890 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29891 return !instr_lo || (instr_lo>>1) == 1;
29892 case 0x00:
29893 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29894 - if (probe_kernel_address(instr, opcode))
29895 + if (user_mode(regs)) {
29896 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29897 + return 0;
29898 + } else if (probe_kernel_address(instr, opcode))
29899 return 0;
29900
29901 *prefetch = (instr_lo == 0xF) &&
29902 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29903 while (instr < max_instr) {
29904 unsigned char opcode;
29905
29906 - if (probe_kernel_address(instr, opcode))
29907 + if (user_mode(regs)) {
29908 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29909 + break;
29910 + } else if (probe_kernel_address(instr, opcode))
29911 break;
29912
29913 instr++;
29914 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29915 force_sig_info(si_signo, &info, tsk);
29916 }
29917
29918 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29919 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29920 +#endif
29921 +
29922 +#ifdef CONFIG_PAX_EMUTRAMP
29923 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29924 +#endif
29925 +
29926 +#ifdef CONFIG_PAX_PAGEEXEC
29927 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29928 +{
29929 + pgd_t *pgd;
29930 + pud_t *pud;
29931 + pmd_t *pmd;
29932 +
29933 + pgd = pgd_offset(mm, address);
29934 + if (!pgd_present(*pgd))
29935 + return NULL;
29936 + pud = pud_offset(pgd, address);
29937 + if (!pud_present(*pud))
29938 + return NULL;
29939 + pmd = pmd_offset(pud, address);
29940 + if (!pmd_present(*pmd))
29941 + return NULL;
29942 + return pmd;
29943 +}
29944 +#endif
29945 +
29946 DEFINE_SPINLOCK(pgd_lock);
29947 LIST_HEAD(pgd_list);
29948
29949 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29950 for (address = VMALLOC_START & PMD_MASK;
29951 address >= TASK_SIZE && address < FIXADDR_TOP;
29952 address += PMD_SIZE) {
29953 +
29954 +#ifdef CONFIG_PAX_PER_CPU_PGD
29955 + unsigned long cpu;
29956 +#else
29957 struct page *page;
29958 +#endif
29959
29960 spin_lock(&pgd_lock);
29961 +
29962 +#ifdef CONFIG_PAX_PER_CPU_PGD
29963 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29964 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29965 + pmd_t *ret;
29966 +
29967 + ret = vmalloc_sync_one(pgd, address);
29968 + if (!ret)
29969 + break;
29970 + pgd = get_cpu_pgd(cpu, kernel);
29971 +#else
29972 list_for_each_entry(page, &pgd_list, lru) {
29973 + pgd_t *pgd;
29974 spinlock_t *pgt_lock;
29975 pmd_t *ret;
29976
29977 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29978 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29979
29980 spin_lock(pgt_lock);
29981 - ret = vmalloc_sync_one(page_address(page), address);
29982 + pgd = page_address(page);
29983 +#endif
29984 +
29985 + ret = vmalloc_sync_one(pgd, address);
29986 +
29987 +#ifndef CONFIG_PAX_PER_CPU_PGD
29988 spin_unlock(pgt_lock);
29989 +#endif
29990
29991 if (!ret)
29992 break;
29993 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29994 * an interrupt in the middle of a task switch..
29995 */
29996 pgd_paddr = read_cr3();
29997 +
29998 +#ifdef CONFIG_PAX_PER_CPU_PGD
29999 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
30000 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
30001 +#endif
30002 +
30003 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30004 if (!pmd_k)
30005 return -1;
30006 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30007 * happen within a race in page table update. In the later
30008 * case just flush:
30009 */
30010 - pgd = pgd_offset(current->active_mm, address);
30011 +
30012 pgd_ref = pgd_offset_k(address);
30013 if (pgd_none(*pgd_ref))
30014 return -1;
30015
30016 +#ifdef CONFIG_PAX_PER_CPU_PGD
30017 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30018 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30019 + if (pgd_none(*pgd)) {
30020 + set_pgd(pgd, *pgd_ref);
30021 + arch_flush_lazy_mmu_mode();
30022 + } else {
30023 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30024 + }
30025 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30026 +#else
30027 + pgd = pgd_offset(current->active_mm, address);
30028 +#endif
30029 +
30030 if (pgd_none(*pgd)) {
30031 set_pgd(pgd, *pgd_ref);
30032 arch_flush_lazy_mmu_mode();
30033 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30034 static int is_errata100(struct pt_regs *regs, unsigned long address)
30035 {
30036 #ifdef CONFIG_X86_64
30037 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30038 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30039 return 1;
30040 #endif
30041 return 0;
30042 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30043 }
30044
30045 static const char nx_warning[] = KERN_CRIT
30046 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30047 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30048
30049 static void
30050 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30051 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30052 if (!oops_may_print())
30053 return;
30054
30055 - if (error_code & PF_INSTR) {
30056 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30057 unsigned int level;
30058
30059 pte_t *pte = lookup_address(address, &level);
30060
30061 if (pte && pte_present(*pte) && !pte_exec(*pte))
30062 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30063 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30064 }
30065
30066 +#ifdef CONFIG_PAX_KERNEXEC
30067 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30068 + if (current->signal->curr_ip)
30069 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30070 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30071 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30072 + else
30073 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30074 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30075 + }
30076 +#endif
30077 +
30078 printk(KERN_ALERT "BUG: unable to handle kernel ");
30079 if (address < PAGE_SIZE)
30080 printk(KERN_CONT "NULL pointer dereference");
30081 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30082 return;
30083 }
30084 #endif
30085 +
30086 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30087 + if (pax_is_fetch_fault(regs, error_code, address)) {
30088 +
30089 +#ifdef CONFIG_PAX_EMUTRAMP
30090 + switch (pax_handle_fetch_fault(regs)) {
30091 + case 2:
30092 + return;
30093 + }
30094 +#endif
30095 +
30096 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30097 + do_group_exit(SIGKILL);
30098 + }
30099 +#endif
30100 +
30101 /* Kernel addresses are always protection faults: */
30102 if (address >= TASK_SIZE)
30103 error_code |= PF_PROT;
30104 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30105 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30106 printk(KERN_ERR
30107 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30108 - tsk->comm, tsk->pid, address);
30109 + tsk->comm, task_pid_nr(tsk), address);
30110 code = BUS_MCEERR_AR;
30111 }
30112 #endif
30113 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30114 return 1;
30115 }
30116
30117 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30118 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30119 +{
30120 + pte_t *pte;
30121 + pmd_t *pmd;
30122 + spinlock_t *ptl;
30123 + unsigned char pte_mask;
30124 +
30125 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30126 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30127 + return 0;
30128 +
30129 + /* PaX: it's our fault, let's handle it if we can */
30130 +
30131 + /* PaX: take a look at read faults before acquiring any locks */
30132 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30133 + /* instruction fetch attempt from a protected page in user mode */
30134 + up_read(&mm->mmap_sem);
30135 +
30136 +#ifdef CONFIG_PAX_EMUTRAMP
30137 + switch (pax_handle_fetch_fault(regs)) {
30138 + case 2:
30139 + return 1;
30140 + }
30141 +#endif
30142 +
30143 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30144 + do_group_exit(SIGKILL);
30145 + }
30146 +
30147 + pmd = pax_get_pmd(mm, address);
30148 + if (unlikely(!pmd))
30149 + return 0;
30150 +
30151 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30152 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30153 + pte_unmap_unlock(pte, ptl);
30154 + return 0;
30155 + }
30156 +
30157 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30158 + /* write attempt to a protected page in user mode */
30159 + pte_unmap_unlock(pte, ptl);
30160 + return 0;
30161 + }
30162 +
30163 +#ifdef CONFIG_SMP
30164 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30165 +#else
30166 + if (likely(address > get_limit(regs->cs)))
30167 +#endif
30168 + {
30169 + set_pte(pte, pte_mkread(*pte));
30170 + __flush_tlb_one(address);
30171 + pte_unmap_unlock(pte, ptl);
30172 + up_read(&mm->mmap_sem);
30173 + return 1;
30174 + }
30175 +
30176 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30177 +
30178 + /*
30179 + * PaX: fill DTLB with user rights and retry
30180 + */
30181 + __asm__ __volatile__ (
30182 + "orb %2,(%1)\n"
30183 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30184 +/*
30185 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30186 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30187 + * page fault when examined during a TLB load attempt. this is true not only
30188 + * for PTEs holding a non-present entry but also present entries that will
30189 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30190 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30191 + * for our target pages since their PTEs are simply not in the TLBs at all.
30192 +
30193 + * the best thing in omitting it is that we gain around 15-20% speed in the
30194 + * fast path of the page fault handler and can get rid of tracing since we
30195 + * can no longer flush unintended entries.
30196 + */
30197 + "invlpg (%0)\n"
30198 +#endif
30199 + __copyuser_seg"testb $0,(%0)\n"
30200 + "xorb %3,(%1)\n"
30201 + :
30202 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30203 + : "memory", "cc");
30204 + pte_unmap_unlock(pte, ptl);
30205 + up_read(&mm->mmap_sem);
30206 + return 1;
30207 +}
30208 +#endif
30209 +
30210 /*
30211 * Handle a spurious fault caused by a stale TLB entry.
30212 *
30213 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
30214 static inline int
30215 access_error(unsigned long error_code, struct vm_area_struct *vma)
30216 {
30217 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30218 + return 1;
30219 +
30220 if (error_code & PF_WRITE) {
30221 /* write, present and write, not present: */
30222 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30223 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30224 if (error_code & PF_USER)
30225 return false;
30226
30227 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30228 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30229 return false;
30230
30231 return true;
30232 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30233 {
30234 struct vm_area_struct *vma;
30235 struct task_struct *tsk;
30236 - unsigned long address;
30237 struct mm_struct *mm;
30238 int fault;
30239 int write = error_code & PF_WRITE;
30240 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
30241 (write ? FAULT_FLAG_WRITE : 0);
30242
30243 - tsk = current;
30244 - mm = tsk->mm;
30245 -
30246 /* Get the faulting address: */
30247 - address = read_cr2();
30248 + unsigned long address = read_cr2();
30249 +
30250 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30251 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30252 + if (!search_exception_tables(regs->ip)) {
30253 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30254 + bad_area_nosemaphore(regs, error_code, address);
30255 + return;
30256 + }
30257 + if (address < pax_user_shadow_base) {
30258 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30259 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30260 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30261 + } else
30262 + address -= pax_user_shadow_base;
30263 + }
30264 +#endif
30265 +
30266 + tsk = current;
30267 + mm = tsk->mm;
30268
30269 /*
30270 * Detect and handle instructions that would cause a page fault for
30271 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30272 * User-mode registers count as a user access even for any
30273 * potential system fault or CPU buglet:
30274 */
30275 - if (user_mode_vm(regs)) {
30276 + if (user_mode(regs)) {
30277 local_irq_enable();
30278 error_code |= PF_USER;
30279 } else {
30280 @@ -1142,6 +1365,11 @@ retry:
30281 might_sleep();
30282 }
30283
30284 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30285 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30286 + return;
30287 +#endif
30288 +
30289 vma = find_vma(mm, address);
30290 if (unlikely(!vma)) {
30291 bad_area(regs, error_code, address);
30292 @@ -1153,18 +1381,24 @@ retry:
30293 bad_area(regs, error_code, address);
30294 return;
30295 }
30296 - if (error_code & PF_USER) {
30297 - /*
30298 - * Accessing the stack below %sp is always a bug.
30299 - * The large cushion allows instructions like enter
30300 - * and pusha to work. ("enter $65535, $31" pushes
30301 - * 32 pointers and then decrements %sp by 65535.)
30302 - */
30303 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30304 - bad_area(regs, error_code, address);
30305 - return;
30306 - }
30307 + /*
30308 + * Accessing the stack below %sp is always a bug.
30309 + * The large cushion allows instructions like enter
30310 + * and pusha to work. ("enter $65535, $31" pushes
30311 + * 32 pointers and then decrements %sp by 65535.)
30312 + */
30313 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30314 + bad_area(regs, error_code, address);
30315 + return;
30316 }
30317 +
30318 +#ifdef CONFIG_PAX_SEGMEXEC
30319 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30320 + bad_area(regs, error_code, address);
30321 + return;
30322 + }
30323 +#endif
30324 +
30325 if (unlikely(expand_stack(vma, address))) {
30326 bad_area(regs, error_code, address);
30327 return;
30328 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30329 __do_page_fault(regs, error_code);
30330 exception_exit(prev_state);
30331 }
30332 +
30333 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30334 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30335 +{
30336 + struct mm_struct *mm = current->mm;
30337 + unsigned long ip = regs->ip;
30338 +
30339 + if (v8086_mode(regs))
30340 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30341 +
30342 +#ifdef CONFIG_PAX_PAGEEXEC
30343 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30344 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30345 + return true;
30346 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30347 + return true;
30348 + return false;
30349 + }
30350 +#endif
30351 +
30352 +#ifdef CONFIG_PAX_SEGMEXEC
30353 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30354 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30355 + return true;
30356 + return false;
30357 + }
30358 +#endif
30359 +
30360 + return false;
30361 +}
30362 +#endif
30363 +
30364 +#ifdef CONFIG_PAX_EMUTRAMP
30365 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30366 +{
30367 + int err;
30368 +
30369 + do { /* PaX: libffi trampoline emulation */
30370 + unsigned char mov, jmp;
30371 + unsigned int addr1, addr2;
30372 +
30373 +#ifdef CONFIG_X86_64
30374 + if ((regs->ip + 9) >> 32)
30375 + break;
30376 +#endif
30377 +
30378 + err = get_user(mov, (unsigned char __user *)regs->ip);
30379 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30380 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30381 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30382 +
30383 + if (err)
30384 + break;
30385 +
30386 + if (mov == 0xB8 && jmp == 0xE9) {
30387 + regs->ax = addr1;
30388 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30389 + return 2;
30390 + }
30391 + } while (0);
30392 +
30393 + do { /* PaX: gcc trampoline emulation #1 */
30394 + unsigned char mov1, mov2;
30395 + unsigned short jmp;
30396 + unsigned int addr1, addr2;
30397 +
30398 +#ifdef CONFIG_X86_64
30399 + if ((regs->ip + 11) >> 32)
30400 + break;
30401 +#endif
30402 +
30403 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30404 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30405 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30406 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30407 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30408 +
30409 + if (err)
30410 + break;
30411 +
30412 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30413 + regs->cx = addr1;
30414 + regs->ax = addr2;
30415 + regs->ip = addr2;
30416 + return 2;
30417 + }
30418 + } while (0);
30419 +
30420 + do { /* PaX: gcc trampoline emulation #2 */
30421 + unsigned char mov, jmp;
30422 + unsigned int addr1, addr2;
30423 +
30424 +#ifdef CONFIG_X86_64
30425 + if ((regs->ip + 9) >> 32)
30426 + break;
30427 +#endif
30428 +
30429 + err = get_user(mov, (unsigned char __user *)regs->ip);
30430 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30431 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30432 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30433 +
30434 + if (err)
30435 + break;
30436 +
30437 + if (mov == 0xB9 && jmp == 0xE9) {
30438 + regs->cx = addr1;
30439 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30440 + return 2;
30441 + }
30442 + } while (0);
30443 +
30444 + return 1; /* PaX in action */
30445 +}
30446 +
30447 +#ifdef CONFIG_X86_64
30448 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30449 +{
30450 + int err;
30451 +
30452 + do { /* PaX: libffi trampoline emulation */
30453 + unsigned short mov1, mov2, jmp1;
30454 + unsigned char stcclc, jmp2;
30455 + unsigned long addr1, addr2;
30456 +
30457 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30458 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30459 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30460 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30461 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30462 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30463 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30464 +
30465 + if (err)
30466 + break;
30467 +
30468 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30469 + regs->r11 = addr1;
30470 + regs->r10 = addr2;
30471 + if (stcclc == 0xF8)
30472 + regs->flags &= ~X86_EFLAGS_CF;
30473 + else
30474 + regs->flags |= X86_EFLAGS_CF;
30475 + regs->ip = addr1;
30476 + return 2;
30477 + }
30478 + } while (0);
30479 +
30480 + do { /* PaX: gcc trampoline emulation #1 */
30481 + unsigned short mov1, mov2, jmp1;
30482 + unsigned char jmp2;
30483 + unsigned int addr1;
30484 + unsigned long addr2;
30485 +
30486 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30487 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30488 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30489 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30490 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30491 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30492 +
30493 + if (err)
30494 + break;
30495 +
30496 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30497 + regs->r11 = addr1;
30498 + regs->r10 = addr2;
30499 + regs->ip = addr1;
30500 + return 2;
30501 + }
30502 + } while (0);
30503 +
30504 + do { /* PaX: gcc trampoline emulation #2 */
30505 + unsigned short mov1, mov2, jmp1;
30506 + unsigned char jmp2;
30507 + unsigned long addr1, addr2;
30508 +
30509 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30510 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30511 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30512 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30513 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30514 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30515 +
30516 + if (err)
30517 + break;
30518 +
30519 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30520 + regs->r11 = addr1;
30521 + regs->r10 = addr2;
30522 + regs->ip = addr1;
30523 + return 2;
30524 + }
30525 + } while (0);
30526 +
30527 + return 1; /* PaX in action */
30528 +}
30529 +#endif
30530 +
30531 +/*
30532 + * PaX: decide what to do with offenders (regs->ip = fault address)
30533 + *
30534 + * returns 1 when task should be killed
30535 + * 2 when gcc trampoline was detected
30536 + */
30537 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30538 +{
30539 + if (v8086_mode(regs))
30540 + return 1;
30541 +
30542 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30543 + return 1;
30544 +
30545 +#ifdef CONFIG_X86_32
30546 + return pax_handle_fetch_fault_32(regs);
30547 +#else
30548 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30549 + return pax_handle_fetch_fault_32(regs);
30550 + else
30551 + return pax_handle_fetch_fault_64(regs);
30552 +#endif
30553 +}
30554 +#endif
30555 +
30556 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30557 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30558 +{
30559 + long i;
30560 +
30561 + printk(KERN_ERR "PAX: bytes at PC: ");
30562 + for (i = 0; i < 20; i++) {
30563 + unsigned char c;
30564 + if (get_user(c, (unsigned char __force_user *)pc+i))
30565 + printk(KERN_CONT "?? ");
30566 + else
30567 + printk(KERN_CONT "%02x ", c);
30568 + }
30569 + printk("\n");
30570 +
30571 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30572 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30573 + unsigned long c;
30574 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30575 +#ifdef CONFIG_X86_32
30576 + printk(KERN_CONT "???????? ");
30577 +#else
30578 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30579 + printk(KERN_CONT "???????? ???????? ");
30580 + else
30581 + printk(KERN_CONT "???????????????? ");
30582 +#endif
30583 + } else {
30584 +#ifdef CONFIG_X86_64
30585 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30586 + printk(KERN_CONT "%08x ", (unsigned int)c);
30587 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30588 + } else
30589 +#endif
30590 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30591 + }
30592 + }
30593 + printk("\n");
30594 +}
30595 +#endif
30596 +
30597 +/**
30598 + * probe_kernel_write(): safely attempt to write to a location
30599 + * @dst: address to write to
30600 + * @src: pointer to the data that shall be written
30601 + * @size: size of the data chunk
30602 + *
30603 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30604 + * happens, handle that and return -EFAULT.
30605 + */
30606 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30607 +{
30608 + long ret;
30609 + mm_segment_t old_fs = get_fs();
30610 +
30611 + set_fs(KERNEL_DS);
30612 + pagefault_disable();
30613 + pax_open_kernel();
30614 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30615 + pax_close_kernel();
30616 + pagefault_enable();
30617 + set_fs(old_fs);
30618 +
30619 + return ret ? -EFAULT : 0;
30620 +}
30621 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30622 index dd74e46..7d26398 100644
30623 --- a/arch/x86/mm/gup.c
30624 +++ b/arch/x86/mm/gup.c
30625 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30626 addr = start;
30627 len = (unsigned long) nr_pages << PAGE_SHIFT;
30628 end = start + len;
30629 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30630 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30631 (void __user *)start, len)))
30632 return 0;
30633
30634 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30635 index 4500142..53a363c 100644
30636 --- a/arch/x86/mm/highmem_32.c
30637 +++ b/arch/x86/mm/highmem_32.c
30638 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30639 idx = type + KM_TYPE_NR*smp_processor_id();
30640 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30641 BUG_ON(!pte_none(*(kmap_pte-idx)));
30642 +
30643 + pax_open_kernel();
30644 set_pte(kmap_pte-idx, mk_pte(page, prot));
30645 + pax_close_kernel();
30646 +
30647 arch_flush_lazy_mmu_mode();
30648
30649 return (void *)vaddr;
30650 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30651 index 7e73e8c..11d3b86 100644
30652 --- a/arch/x86/mm/hugetlbpage.c
30653 +++ b/arch/x86/mm/hugetlbpage.c
30654 @@ -84,23 +84,30 @@ int pud_huge(pud_t pud)
30655 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30656 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30657 unsigned long addr, unsigned long len,
30658 - unsigned long pgoff, unsigned long flags)
30659 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30660 {
30661 struct hstate *h = hstate_file(file);
30662 struct vm_unmapped_area_info info;
30663 -
30664 +
30665 info.flags = 0;
30666 info.length = len;
30667 info.low_limit = TASK_UNMAPPED_BASE;
30668 +
30669 +#ifdef CONFIG_PAX_RANDMMAP
30670 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30671 + info.low_limit += current->mm->delta_mmap;
30672 +#endif
30673 +
30674 info.high_limit = TASK_SIZE;
30675 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30676 info.align_offset = 0;
30677 + info.threadstack_offset = offset;
30678 return vm_unmapped_area(&info);
30679 }
30680
30681 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30682 unsigned long addr0, unsigned long len,
30683 - unsigned long pgoff, unsigned long flags)
30684 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30685 {
30686 struct hstate *h = hstate_file(file);
30687 struct vm_unmapped_area_info info;
30688 @@ -112,6 +119,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30689 info.high_limit = current->mm->mmap_base;
30690 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30691 info.align_offset = 0;
30692 + info.threadstack_offset = offset;
30693 addr = vm_unmapped_area(&info);
30694
30695 /*
30696 @@ -124,6 +132,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30697 VM_BUG_ON(addr != -ENOMEM);
30698 info.flags = 0;
30699 info.low_limit = TASK_UNMAPPED_BASE;
30700 +
30701 +#ifdef CONFIG_PAX_RANDMMAP
30702 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30703 + info.low_limit += current->mm->delta_mmap;
30704 +#endif
30705 +
30706 info.high_limit = TASK_SIZE;
30707 addr = vm_unmapped_area(&info);
30708 }
30709 @@ -138,10 +152,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30710 struct hstate *h = hstate_file(file);
30711 struct mm_struct *mm = current->mm;
30712 struct vm_area_struct *vma;
30713 + unsigned long pax_task_size = TASK_SIZE;
30714 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30715
30716 if (len & ~huge_page_mask(h))
30717 return -EINVAL;
30718 - if (len > TASK_SIZE)
30719 +
30720 +#ifdef CONFIG_PAX_SEGMEXEC
30721 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30722 + pax_task_size = SEGMEXEC_TASK_SIZE;
30723 +#endif
30724 +
30725 + pax_task_size -= PAGE_SIZE;
30726 +
30727 + if (len > pax_task_size)
30728 return -ENOMEM;
30729
30730 if (flags & MAP_FIXED) {
30731 @@ -150,19 +174,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30732 return addr;
30733 }
30734
30735 +#ifdef CONFIG_PAX_RANDMMAP
30736 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30737 +#endif
30738 +
30739 if (addr) {
30740 addr = ALIGN(addr, huge_page_size(h));
30741 vma = find_vma(mm, addr);
30742 - if (TASK_SIZE - len >= addr &&
30743 - (!vma || addr + len <= vma->vm_start))
30744 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30745 return addr;
30746 }
30747 if (mm->get_unmapped_area == arch_get_unmapped_area)
30748 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30749 - pgoff, flags);
30750 + pgoff, flags, offset);
30751 else
30752 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30753 - pgoff, flags);
30754 + pgoff, flags, offset);
30755 }
30756
30757 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30758 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30759 index 04664cd..dae6e5d 100644
30760 --- a/arch/x86/mm/init.c
30761 +++ b/arch/x86/mm/init.c
30762 @@ -4,6 +4,7 @@
30763 #include <linux/swap.h>
30764 #include <linux/memblock.h>
30765 #include <linux/bootmem.h> /* for max_low_pfn */
30766 +#include <linux/tboot.h>
30767
30768 #include <asm/cacheflush.h>
30769 #include <asm/e820.h>
30770 @@ -17,6 +18,8 @@
30771 #include <asm/proto.h>
30772 #include <asm/dma.h> /* for MAX_DMA_PFN */
30773 #include <asm/microcode.h>
30774 +#include <asm/desc.h>
30775 +#include <asm/bios_ebda.h>
30776
30777 #include "mm_internal.h"
30778
30779 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30780 early_ioremap_page_table_range_init();
30781 #endif
30782
30783 +#ifdef CONFIG_PAX_PER_CPU_PGD
30784 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30785 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30786 + KERNEL_PGD_PTRS);
30787 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30788 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30789 + KERNEL_PGD_PTRS);
30790 + load_cr3(get_cpu_pgd(0, kernel));
30791 +#else
30792 load_cr3(swapper_pg_dir);
30793 +#endif
30794 +
30795 __flush_tlb_all();
30796
30797 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30798 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30799 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30800 * mmio resources as well as potential bios/acpi data regions.
30801 */
30802 +
30803 +#ifdef CONFIG_GRKERNSEC_KMEM
30804 +static unsigned int ebda_start __read_only;
30805 +static unsigned int ebda_end __read_only;
30806 +#endif
30807 +
30808 int devmem_is_allowed(unsigned long pagenr)
30809 {
30810 - if (pagenr < 256)
30811 +#ifdef CONFIG_GRKERNSEC_KMEM
30812 + /* allow BDA */
30813 + if (!pagenr)
30814 return 1;
30815 + /* allow EBDA */
30816 + if (pagenr >= ebda_start && pagenr < ebda_end)
30817 + return 1;
30818 + /* if tboot is in use, allow access to its hardcoded serial log range */
30819 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30820 + return 1;
30821 +#else
30822 + if (!pagenr)
30823 + return 1;
30824 +#ifdef CONFIG_VM86
30825 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30826 + return 1;
30827 +#endif
30828 +#endif
30829 +
30830 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30831 + return 1;
30832 +#ifdef CONFIG_GRKERNSEC_KMEM
30833 + /* throw out everything else below 1MB */
30834 + if (pagenr <= 256)
30835 + return 0;
30836 +#endif
30837 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30838 return 0;
30839 if (!page_is_ram(pagenr))
30840 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30841 #endif
30842 }
30843
30844 +#ifdef CONFIG_GRKERNSEC_KMEM
30845 +static inline void gr_init_ebda(void)
30846 +{
30847 + unsigned int ebda_addr;
30848 + unsigned int ebda_size = 0;
30849 +
30850 + ebda_addr = get_bios_ebda();
30851 + if (ebda_addr) {
30852 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30853 + ebda_size <<= 10;
30854 + }
30855 + if (ebda_addr && ebda_size) {
30856 + ebda_start = ebda_addr >> PAGE_SHIFT;
30857 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30858 + } else {
30859 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30860 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30861 + }
30862 +}
30863 +#else
30864 +static inline void gr_init_ebda(void) { }
30865 +#endif
30866 +
30867 void free_initmem(void)
30868 {
30869 +#ifdef CONFIG_PAX_KERNEXEC
30870 +#ifdef CONFIG_X86_32
30871 + /* PaX: limit KERNEL_CS to actual size */
30872 + unsigned long addr, limit;
30873 + struct desc_struct d;
30874 + int cpu;
30875 +#else
30876 + pgd_t *pgd;
30877 + pud_t *pud;
30878 + pmd_t *pmd;
30879 + unsigned long addr, end;
30880 +#endif
30881 +#endif
30882 +
30883 + gr_init_ebda();
30884 +
30885 +#ifdef CONFIG_PAX_KERNEXEC
30886 +#ifdef CONFIG_X86_32
30887 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30888 + limit = (limit - 1UL) >> PAGE_SHIFT;
30889 +
30890 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30891 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30892 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30893 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30894 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30895 + }
30896 +
30897 + /* PaX: make KERNEL_CS read-only */
30898 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30899 + if (!paravirt_enabled())
30900 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30901 +/*
30902 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30903 + pgd = pgd_offset_k(addr);
30904 + pud = pud_offset(pgd, addr);
30905 + pmd = pmd_offset(pud, addr);
30906 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30907 + }
30908 +*/
30909 +#ifdef CONFIG_X86_PAE
30910 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30911 +/*
30912 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30913 + pgd = pgd_offset_k(addr);
30914 + pud = pud_offset(pgd, addr);
30915 + pmd = pmd_offset(pud, addr);
30916 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30917 + }
30918 +*/
30919 +#endif
30920 +
30921 +#ifdef CONFIG_MODULES
30922 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30923 +#endif
30924 +
30925 +#else
30926 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30927 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30928 + pgd = pgd_offset_k(addr);
30929 + pud = pud_offset(pgd, addr);
30930 + pmd = pmd_offset(pud, addr);
30931 + if (!pmd_present(*pmd))
30932 + continue;
30933 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30934 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30935 + else
30936 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30937 + }
30938 +
30939 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30940 + end = addr + KERNEL_IMAGE_SIZE;
30941 + for (; addr < end; addr += PMD_SIZE) {
30942 + pgd = pgd_offset_k(addr);
30943 + pud = pud_offset(pgd, addr);
30944 + pmd = pmd_offset(pud, addr);
30945 + if (!pmd_present(*pmd))
30946 + continue;
30947 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30948 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30949 + }
30950 +#endif
30951 +
30952 + flush_tlb_all();
30953 +#endif
30954 +
30955 free_init_pages("unused kernel",
30956 (unsigned long)(&__init_begin),
30957 (unsigned long)(&__init_end));
30958 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30959 index 4287f1f..3b99c71 100644
30960 --- a/arch/x86/mm/init_32.c
30961 +++ b/arch/x86/mm/init_32.c
30962 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30963 bool __read_mostly __vmalloc_start_set = false;
30964
30965 /*
30966 - * Creates a middle page table and puts a pointer to it in the
30967 - * given global directory entry. This only returns the gd entry
30968 - * in non-PAE compilation mode, since the middle layer is folded.
30969 - */
30970 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30971 -{
30972 - pud_t *pud;
30973 - pmd_t *pmd_table;
30974 -
30975 -#ifdef CONFIG_X86_PAE
30976 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30977 - pmd_table = (pmd_t *)alloc_low_page();
30978 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30979 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30980 - pud = pud_offset(pgd, 0);
30981 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30982 -
30983 - return pmd_table;
30984 - }
30985 -#endif
30986 - pud = pud_offset(pgd, 0);
30987 - pmd_table = pmd_offset(pud, 0);
30988 -
30989 - return pmd_table;
30990 -}
30991 -
30992 -/*
30993 * Create a page table and place a pointer to it in a middle page
30994 * directory entry:
30995 */
30996 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
30997 pte_t *page_table = (pte_t *)alloc_low_page();
30998
30999 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
31000 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31001 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
31002 +#else
31003 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
31004 +#endif
31005 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
31006 }
31007
31008 return pte_offset_kernel(pmd, 0);
31009 }
31010
31011 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
31012 +{
31013 + pud_t *pud;
31014 + pmd_t *pmd_table;
31015 +
31016 + pud = pud_offset(pgd, 0);
31017 + pmd_table = pmd_offset(pud, 0);
31018 +
31019 + return pmd_table;
31020 +}
31021 +
31022 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31023 {
31024 int pgd_idx = pgd_index(vaddr);
31025 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31026 int pgd_idx, pmd_idx;
31027 unsigned long vaddr;
31028 pgd_t *pgd;
31029 + pud_t *pud;
31030 pmd_t *pmd;
31031 pte_t *pte = NULL;
31032 unsigned long count = page_table_range_init_count(start, end);
31033 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31034 pgd = pgd_base + pgd_idx;
31035
31036 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31037 - pmd = one_md_table_init(pgd);
31038 - pmd = pmd + pmd_index(vaddr);
31039 + pud = pud_offset(pgd, vaddr);
31040 + pmd = pmd_offset(pud, vaddr);
31041 +
31042 +#ifdef CONFIG_X86_PAE
31043 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31044 +#endif
31045 +
31046 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31047 pmd++, pmd_idx++) {
31048 pte = page_table_kmap_check(one_page_table_init(pmd),
31049 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31050 }
31051 }
31052
31053 -static inline int is_kernel_text(unsigned long addr)
31054 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31055 {
31056 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31057 - return 1;
31058 - return 0;
31059 + if ((start > ktla_ktva((unsigned long)_etext) ||
31060 + end <= ktla_ktva((unsigned long)_stext)) &&
31061 + (start > ktla_ktva((unsigned long)_einittext) ||
31062 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31063 +
31064 +#ifdef CONFIG_ACPI_SLEEP
31065 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31066 +#endif
31067 +
31068 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31069 + return 0;
31070 + return 1;
31071 }
31072
31073 /*
31074 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31075 unsigned long last_map_addr = end;
31076 unsigned long start_pfn, end_pfn;
31077 pgd_t *pgd_base = swapper_pg_dir;
31078 - int pgd_idx, pmd_idx, pte_ofs;
31079 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31080 unsigned long pfn;
31081 pgd_t *pgd;
31082 + pud_t *pud;
31083 pmd_t *pmd;
31084 pte_t *pte;
31085 unsigned pages_2m, pages_4k;
31086 @@ -291,8 +295,13 @@ repeat:
31087 pfn = start_pfn;
31088 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31089 pgd = pgd_base + pgd_idx;
31090 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31091 - pmd = one_md_table_init(pgd);
31092 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31093 + pud = pud_offset(pgd, 0);
31094 + pmd = pmd_offset(pud, 0);
31095 +
31096 +#ifdef CONFIG_X86_PAE
31097 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31098 +#endif
31099
31100 if (pfn >= end_pfn)
31101 continue;
31102 @@ -304,14 +313,13 @@ repeat:
31103 #endif
31104 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31105 pmd++, pmd_idx++) {
31106 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31107 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31108
31109 /*
31110 * Map with big pages if possible, otherwise
31111 * create normal page tables:
31112 */
31113 if (use_pse) {
31114 - unsigned int addr2;
31115 pgprot_t prot = PAGE_KERNEL_LARGE;
31116 /*
31117 * first pass will use the same initial
31118 @@ -322,11 +330,7 @@ repeat:
31119 _PAGE_PSE);
31120
31121 pfn &= PMD_MASK >> PAGE_SHIFT;
31122 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31123 - PAGE_OFFSET + PAGE_SIZE-1;
31124 -
31125 - if (is_kernel_text(addr) ||
31126 - is_kernel_text(addr2))
31127 + if (is_kernel_text(address, address + PMD_SIZE))
31128 prot = PAGE_KERNEL_LARGE_EXEC;
31129
31130 pages_2m++;
31131 @@ -343,7 +347,7 @@ repeat:
31132 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31133 pte += pte_ofs;
31134 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31135 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31136 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31137 pgprot_t prot = PAGE_KERNEL;
31138 /*
31139 * first pass will use the same initial
31140 @@ -351,7 +355,7 @@ repeat:
31141 */
31142 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31143
31144 - if (is_kernel_text(addr))
31145 + if (is_kernel_text(address, address + PAGE_SIZE))
31146 prot = PAGE_KERNEL_EXEC;
31147
31148 pages_4k++;
31149 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31150
31151 pud = pud_offset(pgd, va);
31152 pmd = pmd_offset(pud, va);
31153 - if (!pmd_present(*pmd))
31154 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31155 break;
31156
31157 /* should not be large page here */
31158 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31159
31160 static void __init pagetable_init(void)
31161 {
31162 - pgd_t *pgd_base = swapper_pg_dir;
31163 -
31164 - permanent_kmaps_init(pgd_base);
31165 + permanent_kmaps_init(swapper_pg_dir);
31166 }
31167
31168 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31169 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31170 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31171
31172 /* user-defined highmem size */
31173 @@ -787,10 +789,10 @@ void __init mem_init(void)
31174 ((unsigned long)&__init_end -
31175 (unsigned long)&__init_begin) >> 10,
31176
31177 - (unsigned long)&_etext, (unsigned long)&_edata,
31178 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31179 + (unsigned long)&_sdata, (unsigned long)&_edata,
31180 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31181
31182 - (unsigned long)&_text, (unsigned long)&_etext,
31183 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31184 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31185
31186 /*
31187 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31188 if (!kernel_set_to_readonly)
31189 return;
31190
31191 + start = ktla_ktva(start);
31192 pr_debug("Set kernel text: %lx - %lx for read write\n",
31193 start, start+size);
31194
31195 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31196 if (!kernel_set_to_readonly)
31197 return;
31198
31199 + start = ktla_ktva(start);
31200 pr_debug("Set kernel text: %lx - %lx for read only\n",
31201 start, start+size);
31202
31203 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31204 unsigned long start = PFN_ALIGN(_text);
31205 unsigned long size = PFN_ALIGN(_etext) - start;
31206
31207 + start = ktla_ktva(start);
31208 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31209 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31210 size >> 10);
31211 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31212 index 104d56a..62ba13f 100644
31213 --- a/arch/x86/mm/init_64.c
31214 +++ b/arch/x86/mm/init_64.c
31215 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31216 * around without checking the pgd every time.
31217 */
31218
31219 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31220 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31221 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31222
31223 int force_personality32;
31224 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31225
31226 for (address = start; address <= end; address += PGDIR_SIZE) {
31227 const pgd_t *pgd_ref = pgd_offset_k(address);
31228 +
31229 +#ifdef CONFIG_PAX_PER_CPU_PGD
31230 + unsigned long cpu;
31231 +#else
31232 struct page *page;
31233 +#endif
31234
31235 if (pgd_none(*pgd_ref))
31236 continue;
31237
31238 spin_lock(&pgd_lock);
31239 +
31240 +#ifdef CONFIG_PAX_PER_CPU_PGD
31241 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31242 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31243 +
31244 + if (pgd_none(*pgd))
31245 + set_pgd(pgd, *pgd_ref);
31246 + else
31247 + BUG_ON(pgd_page_vaddr(*pgd)
31248 + != pgd_page_vaddr(*pgd_ref));
31249 + pgd = pgd_offset_cpu(cpu, kernel, address);
31250 +#else
31251 list_for_each_entry(page, &pgd_list, lru) {
31252 pgd_t *pgd;
31253 spinlock_t *pgt_lock;
31254 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31255 /* the pgt_lock only for Xen */
31256 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31257 spin_lock(pgt_lock);
31258 +#endif
31259
31260 if (pgd_none(*pgd))
31261 set_pgd(pgd, *pgd_ref);
31262 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31263 BUG_ON(pgd_page_vaddr(*pgd)
31264 != pgd_page_vaddr(*pgd_ref));
31265
31266 +#ifndef CONFIG_PAX_PER_CPU_PGD
31267 spin_unlock(pgt_lock);
31268 +#endif
31269 +
31270 }
31271 spin_unlock(&pgd_lock);
31272 }
31273 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31274 {
31275 if (pgd_none(*pgd)) {
31276 pud_t *pud = (pud_t *)spp_getpage();
31277 - pgd_populate(&init_mm, pgd, pud);
31278 + pgd_populate_kernel(&init_mm, pgd, pud);
31279 if (pud != pud_offset(pgd, 0))
31280 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31281 pud, pud_offset(pgd, 0));
31282 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31283 {
31284 if (pud_none(*pud)) {
31285 pmd_t *pmd = (pmd_t *) spp_getpage();
31286 - pud_populate(&init_mm, pud, pmd);
31287 + pud_populate_kernel(&init_mm, pud, pmd);
31288 if (pmd != pmd_offset(pud, 0))
31289 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31290 pmd, pmd_offset(pud, 0));
31291 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31292 pmd = fill_pmd(pud, vaddr);
31293 pte = fill_pte(pmd, vaddr);
31294
31295 + pax_open_kernel();
31296 set_pte(pte, new_pte);
31297 + pax_close_kernel();
31298
31299 /*
31300 * It's enough to flush this one mapping.
31301 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31302 pgd = pgd_offset_k((unsigned long)__va(phys));
31303 if (pgd_none(*pgd)) {
31304 pud = (pud_t *) spp_getpage();
31305 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31306 - _PAGE_USER));
31307 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31308 }
31309 pud = pud_offset(pgd, (unsigned long)__va(phys));
31310 if (pud_none(*pud)) {
31311 pmd = (pmd_t *) spp_getpage();
31312 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31313 - _PAGE_USER));
31314 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31315 }
31316 pmd = pmd_offset(pud, phys);
31317 BUG_ON(!pmd_none(*pmd));
31318 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31319 prot);
31320
31321 spin_lock(&init_mm.page_table_lock);
31322 - pud_populate(&init_mm, pud, pmd);
31323 + pud_populate_kernel(&init_mm, pud, pmd);
31324 spin_unlock(&init_mm.page_table_lock);
31325 }
31326 __flush_tlb_all();
31327 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31328 page_size_mask);
31329
31330 spin_lock(&init_mm.page_table_lock);
31331 - pgd_populate(&init_mm, pgd, pud);
31332 + pgd_populate_kernel(&init_mm, pgd, pud);
31333 spin_unlock(&init_mm.page_table_lock);
31334 pgd_changed = true;
31335 }
31336 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31337 static struct vm_area_struct gate_vma = {
31338 .vm_start = VSYSCALL_START,
31339 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31340 - .vm_page_prot = PAGE_READONLY_EXEC,
31341 - .vm_flags = VM_READ | VM_EXEC
31342 + .vm_page_prot = PAGE_READONLY,
31343 + .vm_flags = VM_READ
31344 };
31345
31346 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31347 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31348
31349 const char *arch_vma_name(struct vm_area_struct *vma)
31350 {
31351 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31352 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31353 return "[vdso]";
31354 if (vma == &gate_vma)
31355 return "[vsyscall]";
31356 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31357 index 7b179b4..6bd17777 100644
31358 --- a/arch/x86/mm/iomap_32.c
31359 +++ b/arch/x86/mm/iomap_32.c
31360 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31361 type = kmap_atomic_idx_push();
31362 idx = type + KM_TYPE_NR * smp_processor_id();
31363 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31364 +
31365 + pax_open_kernel();
31366 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31367 + pax_close_kernel();
31368 +
31369 arch_flush_lazy_mmu_mode();
31370
31371 return (void *)vaddr;
31372 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31373 index 0215e2c..1c62dab 100644
31374 --- a/arch/x86/mm/ioremap.c
31375 +++ b/arch/x86/mm/ioremap.c
31376 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31377 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31378 int is_ram = page_is_ram(pfn);
31379
31380 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31381 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31382 return NULL;
31383 WARN_ON_ONCE(is_ram);
31384 }
31385 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31386 *
31387 * Caller must ensure there is only one unmapping for the same pointer.
31388 */
31389 -void iounmap(volatile void __iomem *addr)
31390 +void iounmap(const volatile void __iomem *addr)
31391 {
31392 struct vm_struct *p, *o;
31393
31394 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31395
31396 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31397 if (page_is_ram(start >> PAGE_SHIFT))
31398 +#ifdef CONFIG_HIGHMEM
31399 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31400 +#endif
31401 return __va(phys);
31402
31403 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31404 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31405 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31406 {
31407 if (page_is_ram(phys >> PAGE_SHIFT))
31408 +#ifdef CONFIG_HIGHMEM
31409 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31410 +#endif
31411 return;
31412
31413 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31414 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31415 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31416
31417 static __initdata int after_paging_init;
31418 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31419 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31420
31421 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31422 {
31423 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31424 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31425
31426 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31427 - memset(bm_pte, 0, sizeof(bm_pte));
31428 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31429 + pmd_populate_user(&init_mm, pmd, bm_pte);
31430
31431 /*
31432 * The boot-ioremap range spans multiple pmds, for which
31433 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31434 index d87dd6d..bf3fa66 100644
31435 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31436 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31437 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31438 * memory (e.g. tracked pages)? For now, we need this to avoid
31439 * invoking kmemcheck for PnP BIOS calls.
31440 */
31441 - if (regs->flags & X86_VM_MASK)
31442 + if (v8086_mode(regs))
31443 return false;
31444 - if (regs->cs != __KERNEL_CS)
31445 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31446 return false;
31447
31448 pte = kmemcheck_pte_lookup(address);
31449 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31450 index 25e7e13..1964579 100644
31451 --- a/arch/x86/mm/mmap.c
31452 +++ b/arch/x86/mm/mmap.c
31453 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31454 * Leave an at least ~128 MB hole with possible stack randomization.
31455 */
31456 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31457 -#define MAX_GAP (TASK_SIZE/6*5)
31458 +#define MAX_GAP (pax_task_size/6*5)
31459
31460 static int mmap_is_legacy(void)
31461 {
31462 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31463 return rnd << PAGE_SHIFT;
31464 }
31465
31466 -static unsigned long mmap_base(void)
31467 +static unsigned long mmap_base(struct mm_struct *mm)
31468 {
31469 unsigned long gap = rlimit(RLIMIT_STACK);
31470 + unsigned long pax_task_size = TASK_SIZE;
31471 +
31472 +#ifdef CONFIG_PAX_SEGMEXEC
31473 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31474 + pax_task_size = SEGMEXEC_TASK_SIZE;
31475 +#endif
31476
31477 if (gap < MIN_GAP)
31478 gap = MIN_GAP;
31479 else if (gap > MAX_GAP)
31480 gap = MAX_GAP;
31481
31482 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31483 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31484 }
31485
31486 /*
31487 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31488 * does, but not when emulating X86_32
31489 */
31490 -static unsigned long mmap_legacy_base(void)
31491 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31492 {
31493 - if (mmap_is_ia32())
31494 + if (mmap_is_ia32()) {
31495 +
31496 +#ifdef CONFIG_PAX_SEGMEXEC
31497 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31498 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31499 + else
31500 +#endif
31501 +
31502 return TASK_UNMAPPED_BASE;
31503 - else
31504 + } else
31505 return TASK_UNMAPPED_BASE + mmap_rnd();
31506 }
31507
31508 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31509 */
31510 void arch_pick_mmap_layout(struct mm_struct *mm)
31511 {
31512 - mm->mmap_legacy_base = mmap_legacy_base();
31513 - mm->mmap_base = mmap_base();
31514 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31515 + mm->mmap_base = mmap_base(mm);
31516 +
31517 +#ifdef CONFIG_PAX_RANDMMAP
31518 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31519 + mm->mmap_legacy_base += mm->delta_mmap;
31520 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31521 + }
31522 +#endif
31523
31524 if (mmap_is_legacy()) {
31525 mm->mmap_base = mm->mmap_legacy_base;
31526 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31527 index 0057a7a..95c7edd 100644
31528 --- a/arch/x86/mm/mmio-mod.c
31529 +++ b/arch/x86/mm/mmio-mod.c
31530 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31531 break;
31532 default:
31533 {
31534 - unsigned char *ip = (unsigned char *)instptr;
31535 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31536 my_trace->opcode = MMIO_UNKNOWN_OP;
31537 my_trace->width = 0;
31538 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31539 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31540 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31541 void __iomem *addr)
31542 {
31543 - static atomic_t next_id;
31544 + static atomic_unchecked_t next_id;
31545 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31546 /* These are page-unaligned. */
31547 struct mmiotrace_map map = {
31548 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31549 .private = trace
31550 },
31551 .phys = offset,
31552 - .id = atomic_inc_return(&next_id)
31553 + .id = atomic_inc_return_unchecked(&next_id)
31554 };
31555 map.map_id = trace->id;
31556
31557 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31558 ioremap_trace_core(offset, size, addr);
31559 }
31560
31561 -static void iounmap_trace_core(volatile void __iomem *addr)
31562 +static void iounmap_trace_core(const volatile void __iomem *addr)
31563 {
31564 struct mmiotrace_map map = {
31565 .phys = 0,
31566 @@ -328,7 +328,7 @@ not_enabled:
31567 }
31568 }
31569
31570 -void mmiotrace_iounmap(volatile void __iomem *addr)
31571 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31572 {
31573 might_sleep();
31574 if (is_enabled()) /* recheck and proper locking in *_core() */
31575 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31576 index 8bf93ba..dbcd670 100644
31577 --- a/arch/x86/mm/numa.c
31578 +++ b/arch/x86/mm/numa.c
31579 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31580 return true;
31581 }
31582
31583 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31584 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31585 {
31586 unsigned long uninitialized_var(pfn_align);
31587 int i, nid;
31588 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31589 index d0b1773..4c3327c 100644
31590 --- a/arch/x86/mm/pageattr-test.c
31591 +++ b/arch/x86/mm/pageattr-test.c
31592 @@ -36,7 +36,7 @@ enum {
31593
31594 static int pte_testbit(pte_t pte)
31595 {
31596 - return pte_flags(pte) & _PAGE_UNUSED1;
31597 + return pte_flags(pte) & _PAGE_CPA_TEST;
31598 }
31599
31600 struct split_state {
31601 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31602 index bb32480..75f2f5e 100644
31603 --- a/arch/x86/mm/pageattr.c
31604 +++ b/arch/x86/mm/pageattr.c
31605 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31606 */
31607 #ifdef CONFIG_PCI_BIOS
31608 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31609 - pgprot_val(forbidden) |= _PAGE_NX;
31610 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31611 #endif
31612
31613 /*
31614 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31615 * Does not cover __inittext since that is gone later on. On
31616 * 64bit we do not enforce !NX on the low mapping
31617 */
31618 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31619 - pgprot_val(forbidden) |= _PAGE_NX;
31620 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31621 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31622
31623 +#ifdef CONFIG_DEBUG_RODATA
31624 /*
31625 * The .rodata section needs to be read-only. Using the pfn
31626 * catches all aliases.
31627 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31628 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31629 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31630 pgprot_val(forbidden) |= _PAGE_RW;
31631 +#endif
31632
31633 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31634 /*
31635 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31636 }
31637 #endif
31638
31639 +#ifdef CONFIG_PAX_KERNEXEC
31640 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31641 + pgprot_val(forbidden) |= _PAGE_RW;
31642 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31643 + }
31644 +#endif
31645 +
31646 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31647
31648 return prot;
31649 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31650 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31651 {
31652 /* change init_mm */
31653 + pax_open_kernel();
31654 set_pte_atomic(kpte, pte);
31655 +
31656 #ifdef CONFIG_X86_32
31657 if (!SHARED_KERNEL_PMD) {
31658 +
31659 +#ifdef CONFIG_PAX_PER_CPU_PGD
31660 + unsigned long cpu;
31661 +#else
31662 struct page *page;
31663 +#endif
31664
31665 +#ifdef CONFIG_PAX_PER_CPU_PGD
31666 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31667 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31668 +#else
31669 list_for_each_entry(page, &pgd_list, lru) {
31670 - pgd_t *pgd;
31671 + pgd_t *pgd = (pgd_t *)page_address(page);
31672 +#endif
31673 +
31674 pud_t *pud;
31675 pmd_t *pmd;
31676
31677 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31678 + pgd += pgd_index(address);
31679 pud = pud_offset(pgd, address);
31680 pmd = pmd_offset(pud, address);
31681 set_pte_atomic((pte_t *)pmd, pte);
31682 }
31683 }
31684 #endif
31685 + pax_close_kernel();
31686 }
31687
31688 static int
31689 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31690 index 6574388..87e9bef 100644
31691 --- a/arch/x86/mm/pat.c
31692 +++ b/arch/x86/mm/pat.c
31693 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31694
31695 if (!entry) {
31696 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31697 - current->comm, current->pid, start, end - 1);
31698 + current->comm, task_pid_nr(current), start, end - 1);
31699 return -EINVAL;
31700 }
31701
31702 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31703
31704 while (cursor < to) {
31705 if (!devmem_is_allowed(pfn)) {
31706 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31707 - current->comm, from, to - 1);
31708 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31709 + current->comm, from, to - 1, cursor);
31710 return 0;
31711 }
31712 cursor += PAGE_SIZE;
31713 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31714 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31715 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31716 "for [mem %#010Lx-%#010Lx]\n",
31717 - current->comm, current->pid,
31718 + current->comm, task_pid_nr(current),
31719 cattr_name(flags),
31720 base, (unsigned long long)(base + size-1));
31721 return -EINVAL;
31722 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31723 flags = lookup_memtype(paddr);
31724 if (want_flags != flags) {
31725 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31726 - current->comm, current->pid,
31727 + current->comm, task_pid_nr(current),
31728 cattr_name(want_flags),
31729 (unsigned long long)paddr,
31730 (unsigned long long)(paddr + size - 1),
31731 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31732 free_memtype(paddr, paddr + size);
31733 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31734 " for [mem %#010Lx-%#010Lx], got %s\n",
31735 - current->comm, current->pid,
31736 + current->comm, task_pid_nr(current),
31737 cattr_name(want_flags),
31738 (unsigned long long)paddr,
31739 (unsigned long long)(paddr + size - 1),
31740 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31741 index 415f6c4..d319983 100644
31742 --- a/arch/x86/mm/pat_rbtree.c
31743 +++ b/arch/x86/mm/pat_rbtree.c
31744 @@ -160,7 +160,7 @@ success:
31745
31746 failure:
31747 printk(KERN_INFO "%s:%d conflicting memory types "
31748 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31749 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31750 end, cattr_name(found_type), cattr_name(match->type));
31751 return -EBUSY;
31752 }
31753 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31754 index 9f0614d..92ae64a 100644
31755 --- a/arch/x86/mm/pf_in.c
31756 +++ b/arch/x86/mm/pf_in.c
31757 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31758 int i;
31759 enum reason_type rv = OTHERS;
31760
31761 - p = (unsigned char *)ins_addr;
31762 + p = (unsigned char *)ktla_ktva(ins_addr);
31763 p += skip_prefix(p, &prf);
31764 p += get_opcode(p, &opcode);
31765
31766 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31767 struct prefix_bits prf;
31768 int i;
31769
31770 - p = (unsigned char *)ins_addr;
31771 + p = (unsigned char *)ktla_ktva(ins_addr);
31772 p += skip_prefix(p, &prf);
31773 p += get_opcode(p, &opcode);
31774
31775 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31776 struct prefix_bits prf;
31777 int i;
31778
31779 - p = (unsigned char *)ins_addr;
31780 + p = (unsigned char *)ktla_ktva(ins_addr);
31781 p += skip_prefix(p, &prf);
31782 p += get_opcode(p, &opcode);
31783
31784 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31785 struct prefix_bits prf;
31786 int i;
31787
31788 - p = (unsigned char *)ins_addr;
31789 + p = (unsigned char *)ktla_ktva(ins_addr);
31790 p += skip_prefix(p, &prf);
31791 p += get_opcode(p, &opcode);
31792 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31793 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31794 struct prefix_bits prf;
31795 int i;
31796
31797 - p = (unsigned char *)ins_addr;
31798 + p = (unsigned char *)ktla_ktva(ins_addr);
31799 p += skip_prefix(p, &prf);
31800 p += get_opcode(p, &opcode);
31801 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31802 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31803 index dfa537a..fd45c64 100644
31804 --- a/arch/x86/mm/pgtable.c
31805 +++ b/arch/x86/mm/pgtable.c
31806 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31807 list_del(&page->lru);
31808 }
31809
31810 -#define UNSHARED_PTRS_PER_PGD \
31811 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31812 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31813 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31814
31815 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31816 +{
31817 + unsigned int count = USER_PGD_PTRS;
31818
31819 + if (!pax_user_shadow_base)
31820 + return;
31821 +
31822 + while (count--)
31823 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31824 +}
31825 +#endif
31826 +
31827 +#ifdef CONFIG_PAX_PER_CPU_PGD
31828 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31829 +{
31830 + unsigned int count = USER_PGD_PTRS;
31831 +
31832 + while (count--) {
31833 + pgd_t pgd;
31834 +
31835 +#ifdef CONFIG_X86_64
31836 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31837 +#else
31838 + pgd = *src++;
31839 +#endif
31840 +
31841 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31842 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31843 +#endif
31844 +
31845 + *dst++ = pgd;
31846 + }
31847 +
31848 +}
31849 +#endif
31850 +
31851 +#ifdef CONFIG_X86_64
31852 +#define pxd_t pud_t
31853 +#define pyd_t pgd_t
31854 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31855 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31856 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31857 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31858 +#define PYD_SIZE PGDIR_SIZE
31859 +#else
31860 +#define pxd_t pmd_t
31861 +#define pyd_t pud_t
31862 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31863 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31864 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31865 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31866 +#define PYD_SIZE PUD_SIZE
31867 +#endif
31868 +
31869 +#ifdef CONFIG_PAX_PER_CPU_PGD
31870 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31871 +static inline void pgd_dtor(pgd_t *pgd) {}
31872 +#else
31873 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31874 {
31875 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31876 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31877 pgd_list_del(pgd);
31878 spin_unlock(&pgd_lock);
31879 }
31880 +#endif
31881
31882 /*
31883 * List of all pgd's needed for non-PAE so it can invalidate entries
31884 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31885 * -- nyc
31886 */
31887
31888 -#ifdef CONFIG_X86_PAE
31889 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31890 /*
31891 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31892 * updating the top-level pagetable entries to guarantee the
31893 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31894 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31895 * and initialize the kernel pmds here.
31896 */
31897 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31898 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31899
31900 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31901 {
31902 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31903 */
31904 flush_tlb_mm(mm);
31905 }
31906 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31907 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31908 #else /* !CONFIG_X86_PAE */
31909
31910 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31911 -#define PREALLOCATED_PMDS 0
31912 +#define PREALLOCATED_PXDS 0
31913
31914 #endif /* CONFIG_X86_PAE */
31915
31916 -static void free_pmds(pmd_t *pmds[])
31917 +static void free_pxds(pxd_t *pxds[])
31918 {
31919 int i;
31920
31921 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31922 - if (pmds[i])
31923 - free_page((unsigned long)pmds[i]);
31924 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31925 + if (pxds[i])
31926 + free_page((unsigned long)pxds[i]);
31927 }
31928
31929 -static int preallocate_pmds(pmd_t *pmds[])
31930 +static int preallocate_pxds(pxd_t *pxds[])
31931 {
31932 int i;
31933 bool failed = false;
31934
31935 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31936 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31937 - if (pmd == NULL)
31938 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31939 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31940 + if (pxd == NULL)
31941 failed = true;
31942 - pmds[i] = pmd;
31943 + pxds[i] = pxd;
31944 }
31945
31946 if (failed) {
31947 - free_pmds(pmds);
31948 + free_pxds(pxds);
31949 return -ENOMEM;
31950 }
31951
31952 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
31953 * preallocate which never got a corresponding vma will need to be
31954 * freed manually.
31955 */
31956 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31957 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31958 {
31959 int i;
31960
31961 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31962 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31963 pgd_t pgd = pgdp[i];
31964
31965 if (pgd_val(pgd) != 0) {
31966 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31967 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31968
31969 - pgdp[i] = native_make_pgd(0);
31970 + set_pgd(pgdp + i, native_make_pgd(0));
31971
31972 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31973 - pmd_free(mm, pmd);
31974 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31975 + pxd_free(mm, pxd);
31976 }
31977 }
31978 }
31979
31980 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31981 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31982 {
31983 - pud_t *pud;
31984 + pyd_t *pyd;
31985 int i;
31986
31987 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31988 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31989 return;
31990
31991 - pud = pud_offset(pgd, 0);
31992 -
31993 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
31994 - pmd_t *pmd = pmds[i];
31995 +#ifdef CONFIG_X86_64
31996 + pyd = pyd_offset(mm, 0L);
31997 +#else
31998 + pyd = pyd_offset(pgd, 0L);
31999 +#endif
32000
32001 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
32002 + pxd_t *pxd = pxds[i];
32003 if (i >= KERNEL_PGD_BOUNDARY)
32004 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32005 - sizeof(pmd_t) * PTRS_PER_PMD);
32006 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32007 + sizeof(pxd_t) * PTRS_PER_PMD);
32008
32009 - pud_populate(mm, pud, pmd);
32010 + pyd_populate(mm, pyd, pxd);
32011 }
32012 }
32013
32014 pgd_t *pgd_alloc(struct mm_struct *mm)
32015 {
32016 pgd_t *pgd;
32017 - pmd_t *pmds[PREALLOCATED_PMDS];
32018 + pxd_t *pxds[PREALLOCATED_PXDS];
32019
32020 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32021
32022 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32023
32024 mm->pgd = pgd;
32025
32026 - if (preallocate_pmds(pmds) != 0)
32027 + if (preallocate_pxds(pxds) != 0)
32028 goto out_free_pgd;
32029
32030 if (paravirt_pgd_alloc(mm) != 0)
32031 - goto out_free_pmds;
32032 + goto out_free_pxds;
32033
32034 /*
32035 * Make sure that pre-populating the pmds is atomic with
32036 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32037 spin_lock(&pgd_lock);
32038
32039 pgd_ctor(mm, pgd);
32040 - pgd_prepopulate_pmd(mm, pgd, pmds);
32041 + pgd_prepopulate_pxd(mm, pgd, pxds);
32042
32043 spin_unlock(&pgd_lock);
32044
32045 return pgd;
32046
32047 -out_free_pmds:
32048 - free_pmds(pmds);
32049 +out_free_pxds:
32050 + free_pxds(pxds);
32051 out_free_pgd:
32052 free_page((unsigned long)pgd);
32053 out:
32054 @@ -300,7 +363,7 @@ out:
32055
32056 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32057 {
32058 - pgd_mop_up_pmds(mm, pgd);
32059 + pgd_mop_up_pxds(mm, pgd);
32060 pgd_dtor(pgd);
32061 paravirt_pgd_free(mm, pgd);
32062 free_page((unsigned long)pgd);
32063 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32064 index a69bcb8..19068ab 100644
32065 --- a/arch/x86/mm/pgtable_32.c
32066 +++ b/arch/x86/mm/pgtable_32.c
32067 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32068 return;
32069 }
32070 pte = pte_offset_kernel(pmd, vaddr);
32071 +
32072 + pax_open_kernel();
32073 if (pte_val(pteval))
32074 set_pte_at(&init_mm, vaddr, pte, pteval);
32075 else
32076 pte_clear(&init_mm, vaddr, pte);
32077 + pax_close_kernel();
32078
32079 /*
32080 * It's enough to flush this one mapping.
32081 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32082 index e666cbb..61788c45 100644
32083 --- a/arch/x86/mm/physaddr.c
32084 +++ b/arch/x86/mm/physaddr.c
32085 @@ -10,7 +10,7 @@
32086 #ifdef CONFIG_X86_64
32087
32088 #ifdef CONFIG_DEBUG_VIRTUAL
32089 -unsigned long __phys_addr(unsigned long x)
32090 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32091 {
32092 unsigned long y = x - __START_KERNEL_map;
32093
32094 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32095 #else
32096
32097 #ifdef CONFIG_DEBUG_VIRTUAL
32098 -unsigned long __phys_addr(unsigned long x)
32099 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32100 {
32101 unsigned long phys_addr = x - PAGE_OFFSET;
32102 /* VMALLOC_* aren't constants */
32103 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32104 index 90555bf..f5f1828 100644
32105 --- a/arch/x86/mm/setup_nx.c
32106 +++ b/arch/x86/mm/setup_nx.c
32107 @@ -5,8 +5,10 @@
32108 #include <asm/pgtable.h>
32109 #include <asm/proto.h>
32110
32111 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32112 static int disable_nx;
32113
32114 +#ifndef CONFIG_PAX_PAGEEXEC
32115 /*
32116 * noexec = on|off
32117 *
32118 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32119 return 0;
32120 }
32121 early_param("noexec", noexec_setup);
32122 +#endif
32123 +
32124 +#endif
32125
32126 void x86_configure_nx(void)
32127 {
32128 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32129 if (cpu_has_nx && !disable_nx)
32130 __supported_pte_mask |= _PAGE_NX;
32131 else
32132 +#endif
32133 __supported_pte_mask &= ~_PAGE_NX;
32134 }
32135
32136 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32137 index 282375f..e03a98f 100644
32138 --- a/arch/x86/mm/tlb.c
32139 +++ b/arch/x86/mm/tlb.c
32140 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32141 BUG();
32142 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32143 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32144 +
32145 +#ifndef CONFIG_PAX_PER_CPU_PGD
32146 load_cr3(swapper_pg_dir);
32147 +#endif
32148 +
32149 }
32150 }
32151 EXPORT_SYMBOL_GPL(leave_mm);
32152 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32153 new file mode 100644
32154 index 0000000..dace51c
32155 --- /dev/null
32156 +++ b/arch/x86/mm/uderef_64.c
32157 @@ -0,0 +1,37 @@
32158 +#include <linux/mm.h>
32159 +#include <asm/pgtable.h>
32160 +#include <asm/uaccess.h>
32161 +
32162 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32163 +/* PaX: due to the special call convention these functions must
32164 + * - remain leaf functions under all configurations,
32165 + * - never be called directly, only dereferenced from the wrappers.
32166 + */
32167 +void __pax_open_userland(void)
32168 +{
32169 + unsigned int cpu;
32170 +
32171 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32172 + return;
32173 +
32174 + cpu = raw_get_cpu();
32175 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32176 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32177 + raw_put_cpu_no_resched();
32178 +}
32179 +EXPORT_SYMBOL(__pax_open_userland);
32180 +
32181 +void __pax_close_userland(void)
32182 +{
32183 + unsigned int cpu;
32184 +
32185 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32186 + return;
32187 +
32188 + cpu = raw_get_cpu();
32189 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32190 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32191 + raw_put_cpu_no_resched();
32192 +}
32193 +EXPORT_SYMBOL(__pax_close_userland);
32194 +#endif
32195 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32196 index 877b9a1..a8ecf42 100644
32197 --- a/arch/x86/net/bpf_jit.S
32198 +++ b/arch/x86/net/bpf_jit.S
32199 @@ -9,6 +9,7 @@
32200 */
32201 #include <linux/linkage.h>
32202 #include <asm/dwarf2.h>
32203 +#include <asm/alternative-asm.h>
32204
32205 /*
32206 * Calling convention :
32207 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32208 jle bpf_slow_path_word
32209 mov (SKBDATA,%rsi),%eax
32210 bswap %eax /* ntohl() */
32211 + pax_force_retaddr
32212 ret
32213
32214 sk_load_half:
32215 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32216 jle bpf_slow_path_half
32217 movzwl (SKBDATA,%rsi),%eax
32218 rol $8,%ax # ntohs()
32219 + pax_force_retaddr
32220 ret
32221
32222 sk_load_byte:
32223 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32224 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32225 jle bpf_slow_path_byte
32226 movzbl (SKBDATA,%rsi),%eax
32227 + pax_force_retaddr
32228 ret
32229
32230 /**
32231 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32232 movzbl (SKBDATA,%rsi),%ebx
32233 and $15,%bl
32234 shl $2,%bl
32235 + pax_force_retaddr
32236 ret
32237
32238 /* rsi contains offset and can be scratched */
32239 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32240 js bpf_error
32241 mov -12(%rbp),%eax
32242 bswap %eax
32243 + pax_force_retaddr
32244 ret
32245
32246 bpf_slow_path_half:
32247 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32248 mov -12(%rbp),%ax
32249 rol $8,%ax
32250 movzwl %ax,%eax
32251 + pax_force_retaddr
32252 ret
32253
32254 bpf_slow_path_byte:
32255 bpf_slow_path_common(1)
32256 js bpf_error
32257 movzbl -12(%rbp),%eax
32258 + pax_force_retaddr
32259 ret
32260
32261 bpf_slow_path_byte_msh:
32262 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32263 and $15,%al
32264 shl $2,%al
32265 xchg %eax,%ebx
32266 + pax_force_retaddr
32267 ret
32268
32269 #define sk_negative_common(SIZE) \
32270 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32271 sk_negative_common(4)
32272 mov (%rax), %eax
32273 bswap %eax
32274 + pax_force_retaddr
32275 ret
32276
32277 bpf_slow_path_half_neg:
32278 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32279 mov (%rax),%ax
32280 rol $8,%ax
32281 movzwl %ax,%eax
32282 + pax_force_retaddr
32283 ret
32284
32285 bpf_slow_path_byte_neg:
32286 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32287 .globl sk_load_byte_negative_offset
32288 sk_negative_common(1)
32289 movzbl (%rax), %eax
32290 + pax_force_retaddr
32291 ret
32292
32293 bpf_slow_path_byte_msh_neg:
32294 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32295 and $15,%al
32296 shl $2,%al
32297 xchg %eax,%ebx
32298 + pax_force_retaddr
32299 ret
32300
32301 bpf_error:
32302 @@ -197,4 +210,5 @@ bpf_error:
32303 xor %eax,%eax
32304 mov -8(%rbp),%rbx
32305 leaveq
32306 + pax_force_retaddr
32307 ret
32308 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32309 index 79c216a..08d39cc 100644
32310 --- a/arch/x86/net/bpf_jit_comp.c
32311 +++ b/arch/x86/net/bpf_jit_comp.c
32312 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32313 return ptr + len;
32314 }
32315
32316 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32317 +#define MAX_INSTR_CODE_SIZE 96
32318 +#else
32319 +#define MAX_INSTR_CODE_SIZE 64
32320 +#endif
32321 +
32322 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32323
32324 #define EMIT1(b1) EMIT(b1, 1)
32325 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32326 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32327 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32328 +
32329 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32330 +/* original constant will appear in ecx */
32331 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32332 +do { \
32333 + /* mov ecx, randkey */ \
32334 + EMIT1(0xb9); \
32335 + EMIT(_key, 4); \
32336 + /* xor ecx, randkey ^ off */ \
32337 + EMIT2(0x81, 0xf1); \
32338 + EMIT((_key) ^ (_off), 4); \
32339 +} while (0)
32340 +
32341 +#define EMIT1_off32(b1, _off) \
32342 +do { \
32343 + switch (b1) { \
32344 + case 0x05: /* add eax, imm32 */ \
32345 + case 0x2d: /* sub eax, imm32 */ \
32346 + case 0x25: /* and eax, imm32 */ \
32347 + case 0x0d: /* or eax, imm32 */ \
32348 + case 0xb8: /* mov eax, imm32 */ \
32349 + case 0x35: /* xor eax, imm32 */ \
32350 + case 0x3d: /* cmp eax, imm32 */ \
32351 + case 0xa9: /* test eax, imm32 */ \
32352 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32353 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32354 + break; \
32355 + case 0xbb: /* mov ebx, imm32 */ \
32356 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32357 + /* mov ebx, ecx */ \
32358 + EMIT2(0x89, 0xcb); \
32359 + break; \
32360 + case 0xbe: /* mov esi, imm32 */ \
32361 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32362 + /* mov esi, ecx */ \
32363 + EMIT2(0x89, 0xce); \
32364 + break; \
32365 + case 0xe8: /* call rel imm32, always to known funcs */ \
32366 + EMIT1(b1); \
32367 + EMIT(_off, 4); \
32368 + break; \
32369 + case 0xe9: /* jmp rel imm32 */ \
32370 + EMIT1(b1); \
32371 + EMIT(_off, 4); \
32372 + /* prevent fall-through, we're not called if off = 0 */ \
32373 + EMIT(0xcccccccc, 4); \
32374 + EMIT(0xcccccccc, 4); \
32375 + break; \
32376 + default: \
32377 + BUILD_BUG(); \
32378 + } \
32379 +} while (0)
32380 +
32381 +#define EMIT2_off32(b1, b2, _off) \
32382 +do { \
32383 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32384 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32385 + EMIT(randkey, 4); \
32386 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32387 + EMIT((_off) - randkey, 4); \
32388 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32389 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32390 + /* imul eax, ecx */ \
32391 + EMIT3(0x0f, 0xaf, 0xc1); \
32392 + } else { \
32393 + BUILD_BUG(); \
32394 + } \
32395 +} while (0)
32396 +#else
32397 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32398 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32399 +#endif
32400
32401 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32402 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32403 @@ -91,6 +168,24 @@ do { \
32404 #define X86_JBE 0x76
32405 #define X86_JA 0x77
32406
32407 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32408 +#define APPEND_FLOW_VERIFY() \
32409 +do { \
32410 + /* mov ecx, randkey */ \
32411 + EMIT1(0xb9); \
32412 + EMIT(randkey, 4); \
32413 + /* cmp ecx, randkey */ \
32414 + EMIT2(0x81, 0xf9); \
32415 + EMIT(randkey, 4); \
32416 + /* jz after 8 int 3s */ \
32417 + EMIT2(0x74, 0x08); \
32418 + EMIT(0xcccccccc, 4); \
32419 + EMIT(0xcccccccc, 4); \
32420 +} while (0)
32421 +#else
32422 +#define APPEND_FLOW_VERIFY() do { } while (0)
32423 +#endif
32424 +
32425 #define EMIT_COND_JMP(op, offset) \
32426 do { \
32427 if (is_near(offset)) \
32428 @@ -98,6 +193,7 @@ do { \
32429 else { \
32430 EMIT2(0x0f, op + 0x10); \
32431 EMIT(offset, 4); /* jxx .+off32 */ \
32432 + APPEND_FLOW_VERIFY(); \
32433 } \
32434 } while (0)
32435
32436 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32437 return -1;
32438 }
32439
32440 -struct bpf_binary_header {
32441 - unsigned int pages;
32442 - /* Note : for security reasons, bpf code will follow a randomly
32443 - * sized amount of int3 instructions
32444 - */
32445 - u8 image[];
32446 -};
32447 -
32448 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32449 +/* Note : for security reasons, bpf code will follow a randomly
32450 + * sized amount of int3 instructions
32451 + */
32452 +static u8 *bpf_alloc_binary(unsigned int proglen,
32453 u8 **image_ptr)
32454 {
32455 unsigned int sz, hole;
32456 - struct bpf_binary_header *header;
32457 + u8 *header;
32458
32459 /* Most of BPF filters are really small,
32460 * but if some of them fill a page, allow at least
32461 * 128 extra bytes to insert a random section of int3
32462 */
32463 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32464 - header = module_alloc(sz);
32465 + sz = round_up(proglen + 128, PAGE_SIZE);
32466 + header = module_alloc_exec(sz);
32467 if (!header)
32468 return NULL;
32469
32470 + pax_open_kernel();
32471 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32472 + pax_close_kernel();
32473
32474 - header->pages = sz / PAGE_SIZE;
32475 - hole = sz - (proglen + sizeof(*header));
32476 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32477
32478 /* insert a random number of int3 instructions before BPF code */
32479 - *image_ptr = &header->image[prandom_u32() % hole];
32480 + *image_ptr = &header[prandom_u32() % hole];
32481 return header;
32482 }
32483
32484 void bpf_jit_compile(struct sk_filter *fp)
32485 {
32486 - u8 temp[64];
32487 + u8 temp[MAX_INSTR_CODE_SIZE];
32488 u8 *prog;
32489 unsigned int proglen, oldproglen = 0;
32490 int ilen, i;
32491 int t_offset, f_offset;
32492 u8 t_op, f_op, seen = 0, pass;
32493 u8 *image = NULL;
32494 - struct bpf_binary_header *header = NULL;
32495 + u8 *header = NULL;
32496 u8 *func;
32497 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32498 unsigned int cleanup_addr; /* epilogue code offset */
32499 unsigned int *addrs;
32500 const struct sock_filter *filter = fp->insns;
32501 int flen = fp->len;
32502 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32503 + unsigned int randkey;
32504 +#endif
32505
32506 if (!bpf_jit_enable)
32507 return;
32508 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32509 if (addrs == NULL)
32510 return;
32511
32512 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32513 + randkey = get_random_int();
32514 +#endif
32515 +
32516 /* Before first pass, make a rough estimation of addrs[]
32517 - * each bpf instruction is translated to less than 64 bytes
32518 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32519 */
32520 for (proglen = 0, i = 0; i < flen; i++) {
32521 - proglen += 64;
32522 + proglen += MAX_INSTR_CODE_SIZE;
32523 addrs[i] = proglen;
32524 }
32525 cleanup_addr = proglen; /* epilogue address */
32526 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32527 case BPF_S_ALU_MUL_K: /* A *= K */
32528 if (is_imm8(K))
32529 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32530 - else {
32531 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32532 - EMIT(K, 4);
32533 - }
32534 + else
32535 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32536 break;
32537 case BPF_S_ALU_DIV_X: /* A /= X; */
32538 seen |= SEEN_XREG;
32539 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32540 break;
32541 case BPF_S_ALU_MOD_K: /* A %= K; */
32542 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32543 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32544 + DILUTE_CONST_SEQUENCE(K, randkey);
32545 +#else
32546 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32547 +#endif
32548 EMIT2(0xf7, 0xf1); /* div %ecx */
32549 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32550 break;
32551 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32552 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32553 + DILUTE_CONST_SEQUENCE(K, randkey);
32554 + // imul rax, rcx
32555 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32556 +#else
32557 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32558 EMIT(K, 4);
32559 +#endif
32560 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32561 break;
32562 case BPF_S_ALU_AND_X:
32563 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32564 if (is_imm8(K)) {
32565 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32566 } else {
32567 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32568 - EMIT(K, 4);
32569 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32570 }
32571 } else {
32572 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32573 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32574 if (unlikely(proglen + ilen > oldproglen)) {
32575 pr_err("bpb_jit_compile fatal error\n");
32576 kfree(addrs);
32577 - module_free(NULL, header);
32578 + module_free_exec(NULL, image);
32579 return;
32580 }
32581 + pax_open_kernel();
32582 memcpy(image + proglen, temp, ilen);
32583 + pax_close_kernel();
32584 }
32585 proglen += ilen;
32586 addrs[i] = proglen;
32587 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32588
32589 if (image) {
32590 bpf_flush_icache(header, image + proglen);
32591 - set_memory_ro((unsigned long)header, header->pages);
32592 fp->bpf_func = (void *)image;
32593 }
32594 out:
32595 @@ -776,9 +883,7 @@ void bpf_jit_free(struct sk_filter *fp)
32596 {
32597 if (fp->bpf_func != sk_run_filter) {
32598 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32599 - struct bpf_binary_header *header = (void *)addr;
32600 -
32601 - set_memory_rw(addr, header->pages);
32602 - module_free(NULL, header);
32603 + set_memory_rw(addr, 1);
32604 + module_free_exec(NULL, (void *)addr);
32605 }
32606 }
32607 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32608 index d6aa6e8..266395a 100644
32609 --- a/arch/x86/oprofile/backtrace.c
32610 +++ b/arch/x86/oprofile/backtrace.c
32611 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32612 struct stack_frame_ia32 *fp;
32613 unsigned long bytes;
32614
32615 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32616 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32617 if (bytes != sizeof(bufhead))
32618 return NULL;
32619
32620 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32621 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32622
32623 oprofile_add_trace(bufhead[0].return_address);
32624
32625 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32626 struct stack_frame bufhead[2];
32627 unsigned long bytes;
32628
32629 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32630 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32631 if (bytes != sizeof(bufhead))
32632 return NULL;
32633
32634 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32635 {
32636 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32637
32638 - if (!user_mode_vm(regs)) {
32639 + if (!user_mode(regs)) {
32640 unsigned long stack = kernel_stack_pointer(regs);
32641 if (depth)
32642 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32643 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32644 index 48768df..ba9143c 100644
32645 --- a/arch/x86/oprofile/nmi_int.c
32646 +++ b/arch/x86/oprofile/nmi_int.c
32647 @@ -23,6 +23,7 @@
32648 #include <asm/nmi.h>
32649 #include <asm/msr.h>
32650 #include <asm/apic.h>
32651 +#include <asm/pgtable.h>
32652
32653 #include "op_counter.h"
32654 #include "op_x86_model.h"
32655 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32656 if (ret)
32657 return ret;
32658
32659 - if (!model->num_virt_counters)
32660 - model->num_virt_counters = model->num_counters;
32661 + if (!model->num_virt_counters) {
32662 + pax_open_kernel();
32663 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32664 + pax_close_kernel();
32665 + }
32666
32667 mux_init(ops);
32668
32669 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32670 index b2b9443..be58856 100644
32671 --- a/arch/x86/oprofile/op_model_amd.c
32672 +++ b/arch/x86/oprofile/op_model_amd.c
32673 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32674 num_counters = AMD64_NUM_COUNTERS;
32675 }
32676
32677 - op_amd_spec.num_counters = num_counters;
32678 - op_amd_spec.num_controls = num_counters;
32679 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32680 + pax_open_kernel();
32681 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32682 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32683 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32684 + pax_close_kernel();
32685
32686 return 0;
32687 }
32688 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32689 index d90528e..0127e2b 100644
32690 --- a/arch/x86/oprofile/op_model_ppro.c
32691 +++ b/arch/x86/oprofile/op_model_ppro.c
32692 @@ -19,6 +19,7 @@
32693 #include <asm/msr.h>
32694 #include <asm/apic.h>
32695 #include <asm/nmi.h>
32696 +#include <asm/pgtable.h>
32697
32698 #include "op_x86_model.h"
32699 #include "op_counter.h"
32700 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32701
32702 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32703
32704 - op_arch_perfmon_spec.num_counters = num_counters;
32705 - op_arch_perfmon_spec.num_controls = num_counters;
32706 + pax_open_kernel();
32707 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32708 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32709 + pax_close_kernel();
32710 }
32711
32712 static int arch_perfmon_init(struct oprofile_operations *ignore)
32713 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32714 index 71e8a67..6a313bb 100644
32715 --- a/arch/x86/oprofile/op_x86_model.h
32716 +++ b/arch/x86/oprofile/op_x86_model.h
32717 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32718 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32719 struct op_msrs const * const msrs);
32720 #endif
32721 -};
32722 +} __do_const;
32723
32724 struct op_counter_config;
32725
32726 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32727 index 372e9b8..e775a6c 100644
32728 --- a/arch/x86/pci/irq.c
32729 +++ b/arch/x86/pci/irq.c
32730 @@ -50,7 +50,7 @@ struct irq_router {
32731 struct irq_router_handler {
32732 u16 vendor;
32733 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32734 -};
32735 +} __do_const;
32736
32737 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32738 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32739 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32740 return 0;
32741 }
32742
32743 -static __initdata struct irq_router_handler pirq_routers[] = {
32744 +static __initconst const struct irq_router_handler pirq_routers[] = {
32745 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32746 { PCI_VENDOR_ID_AL, ali_router_probe },
32747 { PCI_VENDOR_ID_ITE, ite_router_probe },
32748 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32749 static void __init pirq_find_router(struct irq_router *r)
32750 {
32751 struct irq_routing_table *rt = pirq_table;
32752 - struct irq_router_handler *h;
32753 + const struct irq_router_handler *h;
32754
32755 #ifdef CONFIG_PCI_BIOS
32756 if (!rt->signature) {
32757 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32758 return 0;
32759 }
32760
32761 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32762 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32763 {
32764 .callback = fix_broken_hp_bios_irq9,
32765 .ident = "HP Pavilion N5400 Series Laptop",
32766 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32767 index 6eb18c4..20d83de 100644
32768 --- a/arch/x86/pci/mrst.c
32769 +++ b/arch/x86/pci/mrst.c
32770 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
32771 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
32772 pci_mmcfg_late_init();
32773 pcibios_enable_irq = mrst_pci_irq_enable;
32774 - pci_root_ops = pci_mrst_ops;
32775 + pax_open_kernel();
32776 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32777 + pax_close_kernel();
32778 pci_soc_mode = 1;
32779 /* Continue with standard init */
32780 return 1;
32781 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32782 index c77b24a..c979855 100644
32783 --- a/arch/x86/pci/pcbios.c
32784 +++ b/arch/x86/pci/pcbios.c
32785 @@ -79,7 +79,7 @@ union bios32 {
32786 static struct {
32787 unsigned long address;
32788 unsigned short segment;
32789 -} bios32_indirect = { 0, __KERNEL_CS };
32790 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32791
32792 /*
32793 * Returns the entry point for the given service, NULL on error
32794 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32795 unsigned long length; /* %ecx */
32796 unsigned long entry; /* %edx */
32797 unsigned long flags;
32798 + struct desc_struct d, *gdt;
32799
32800 local_irq_save(flags);
32801 - __asm__("lcall *(%%edi); cld"
32802 +
32803 + gdt = get_cpu_gdt_table(smp_processor_id());
32804 +
32805 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32806 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32807 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32808 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32809 +
32810 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32811 : "=a" (return_code),
32812 "=b" (address),
32813 "=c" (length),
32814 "=d" (entry)
32815 : "0" (service),
32816 "1" (0),
32817 - "D" (&bios32_indirect));
32818 + "D" (&bios32_indirect),
32819 + "r"(__PCIBIOS_DS)
32820 + : "memory");
32821 +
32822 + pax_open_kernel();
32823 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32824 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32825 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32826 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32827 + pax_close_kernel();
32828 +
32829 local_irq_restore(flags);
32830
32831 switch (return_code) {
32832 - case 0:
32833 - return address + entry;
32834 - case 0x80: /* Not present */
32835 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32836 - return 0;
32837 - default: /* Shouldn't happen */
32838 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32839 - service, return_code);
32840 + case 0: {
32841 + int cpu;
32842 + unsigned char flags;
32843 +
32844 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32845 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32846 + printk(KERN_WARNING "bios32_service: not valid\n");
32847 return 0;
32848 + }
32849 + address = address + PAGE_OFFSET;
32850 + length += 16UL; /* some BIOSs underreport this... */
32851 + flags = 4;
32852 + if (length >= 64*1024*1024) {
32853 + length >>= PAGE_SHIFT;
32854 + flags |= 8;
32855 + }
32856 +
32857 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32858 + gdt = get_cpu_gdt_table(cpu);
32859 + pack_descriptor(&d, address, length, 0x9b, flags);
32860 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32861 + pack_descriptor(&d, address, length, 0x93, flags);
32862 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32863 + }
32864 + return entry;
32865 + }
32866 + case 0x80: /* Not present */
32867 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32868 + return 0;
32869 + default: /* Shouldn't happen */
32870 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32871 + service, return_code);
32872 + return 0;
32873 }
32874 }
32875
32876 static struct {
32877 unsigned long address;
32878 unsigned short segment;
32879 -} pci_indirect = { 0, __KERNEL_CS };
32880 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32881
32882 -static int pci_bios_present;
32883 +static int pci_bios_present __read_only;
32884
32885 static int check_pcibios(void)
32886 {
32887 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32888 unsigned long flags, pcibios_entry;
32889
32890 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32891 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32892 + pci_indirect.address = pcibios_entry;
32893
32894 local_irq_save(flags);
32895 - __asm__(
32896 - "lcall *(%%edi); cld\n\t"
32897 + __asm__("movw %w6, %%ds\n\t"
32898 + "lcall *%%ss:(%%edi); cld\n\t"
32899 + "push %%ss\n\t"
32900 + "pop %%ds\n\t"
32901 "jc 1f\n\t"
32902 "xor %%ah, %%ah\n"
32903 "1:"
32904 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32905 "=b" (ebx),
32906 "=c" (ecx)
32907 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32908 - "D" (&pci_indirect)
32909 + "D" (&pci_indirect),
32910 + "r" (__PCIBIOS_DS)
32911 : "memory");
32912 local_irq_restore(flags);
32913
32914 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32915
32916 switch (len) {
32917 case 1:
32918 - __asm__("lcall *(%%esi); cld\n\t"
32919 + __asm__("movw %w6, %%ds\n\t"
32920 + "lcall *%%ss:(%%esi); cld\n\t"
32921 + "push %%ss\n\t"
32922 + "pop %%ds\n\t"
32923 "jc 1f\n\t"
32924 "xor %%ah, %%ah\n"
32925 "1:"
32926 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32927 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32928 "b" (bx),
32929 "D" ((long)reg),
32930 - "S" (&pci_indirect));
32931 + "S" (&pci_indirect),
32932 + "r" (__PCIBIOS_DS));
32933 /*
32934 * Zero-extend the result beyond 8 bits, do not trust the
32935 * BIOS having done it:
32936 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32937 *value &= 0xff;
32938 break;
32939 case 2:
32940 - __asm__("lcall *(%%esi); cld\n\t"
32941 + __asm__("movw %w6, %%ds\n\t"
32942 + "lcall *%%ss:(%%esi); cld\n\t"
32943 + "push %%ss\n\t"
32944 + "pop %%ds\n\t"
32945 "jc 1f\n\t"
32946 "xor %%ah, %%ah\n"
32947 "1:"
32948 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32949 : "1" (PCIBIOS_READ_CONFIG_WORD),
32950 "b" (bx),
32951 "D" ((long)reg),
32952 - "S" (&pci_indirect));
32953 + "S" (&pci_indirect),
32954 + "r" (__PCIBIOS_DS));
32955 /*
32956 * Zero-extend the result beyond 16 bits, do not trust the
32957 * BIOS having done it:
32958 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32959 *value &= 0xffff;
32960 break;
32961 case 4:
32962 - __asm__("lcall *(%%esi); cld\n\t"
32963 + __asm__("movw %w6, %%ds\n\t"
32964 + "lcall *%%ss:(%%esi); cld\n\t"
32965 + "push %%ss\n\t"
32966 + "pop %%ds\n\t"
32967 "jc 1f\n\t"
32968 "xor %%ah, %%ah\n"
32969 "1:"
32970 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32971 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32972 "b" (bx),
32973 "D" ((long)reg),
32974 - "S" (&pci_indirect));
32975 + "S" (&pci_indirect),
32976 + "r" (__PCIBIOS_DS));
32977 break;
32978 }
32979
32980 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32981
32982 switch (len) {
32983 case 1:
32984 - __asm__("lcall *(%%esi); cld\n\t"
32985 + __asm__("movw %w6, %%ds\n\t"
32986 + "lcall *%%ss:(%%esi); cld\n\t"
32987 + "push %%ss\n\t"
32988 + "pop %%ds\n\t"
32989 "jc 1f\n\t"
32990 "xor %%ah, %%ah\n"
32991 "1:"
32992 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32993 "c" (value),
32994 "b" (bx),
32995 "D" ((long)reg),
32996 - "S" (&pci_indirect));
32997 + "S" (&pci_indirect),
32998 + "r" (__PCIBIOS_DS));
32999 break;
33000 case 2:
33001 - __asm__("lcall *(%%esi); cld\n\t"
33002 + __asm__("movw %w6, %%ds\n\t"
33003 + "lcall *%%ss:(%%esi); cld\n\t"
33004 + "push %%ss\n\t"
33005 + "pop %%ds\n\t"
33006 "jc 1f\n\t"
33007 "xor %%ah, %%ah\n"
33008 "1:"
33009 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33010 "c" (value),
33011 "b" (bx),
33012 "D" ((long)reg),
33013 - "S" (&pci_indirect));
33014 + "S" (&pci_indirect),
33015 + "r" (__PCIBIOS_DS));
33016 break;
33017 case 4:
33018 - __asm__("lcall *(%%esi); cld\n\t"
33019 + __asm__("movw %w6, %%ds\n\t"
33020 + "lcall *%%ss:(%%esi); cld\n\t"
33021 + "push %%ss\n\t"
33022 + "pop %%ds\n\t"
33023 "jc 1f\n\t"
33024 "xor %%ah, %%ah\n"
33025 "1:"
33026 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33027 "c" (value),
33028 "b" (bx),
33029 "D" ((long)reg),
33030 - "S" (&pci_indirect));
33031 + "S" (&pci_indirect),
33032 + "r" (__PCIBIOS_DS));
33033 break;
33034 }
33035
33036 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33037
33038 DBG("PCI: Fetching IRQ routing table... ");
33039 __asm__("push %%es\n\t"
33040 + "movw %w8, %%ds\n\t"
33041 "push %%ds\n\t"
33042 "pop %%es\n\t"
33043 - "lcall *(%%esi); cld\n\t"
33044 + "lcall *%%ss:(%%esi); cld\n\t"
33045 "pop %%es\n\t"
33046 + "push %%ss\n\t"
33047 + "pop %%ds\n"
33048 "jc 1f\n\t"
33049 "xor %%ah, %%ah\n"
33050 "1:"
33051 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33052 "1" (0),
33053 "D" ((long) &opt),
33054 "S" (&pci_indirect),
33055 - "m" (opt)
33056 + "m" (opt),
33057 + "r" (__PCIBIOS_DS)
33058 : "memory");
33059 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33060 if (ret & 0xff00)
33061 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33062 {
33063 int ret;
33064
33065 - __asm__("lcall *(%%esi); cld\n\t"
33066 + __asm__("movw %w5, %%ds\n\t"
33067 + "lcall *%%ss:(%%esi); cld\n\t"
33068 + "push %%ss\n\t"
33069 + "pop %%ds\n"
33070 "jc 1f\n\t"
33071 "xor %%ah, %%ah\n"
33072 "1:"
33073 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33074 : "0" (PCIBIOS_SET_PCI_HW_INT),
33075 "b" ((dev->bus->number << 8) | dev->devfn),
33076 "c" ((irq << 8) | (pin + 10)),
33077 - "S" (&pci_indirect));
33078 + "S" (&pci_indirect),
33079 + "r" (__PCIBIOS_DS));
33080 return !(ret & 0xff00);
33081 }
33082 EXPORT_SYMBOL(pcibios_set_irq_routing);
33083 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33084 index 40e4469..d915bf9 100644
33085 --- a/arch/x86/platform/efi/efi_32.c
33086 +++ b/arch/x86/platform/efi/efi_32.c
33087 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33088 {
33089 struct desc_ptr gdt_descr;
33090
33091 +#ifdef CONFIG_PAX_KERNEXEC
33092 + struct desc_struct d;
33093 +#endif
33094 +
33095 local_irq_save(efi_rt_eflags);
33096
33097 load_cr3(initial_page_table);
33098 __flush_tlb_all();
33099
33100 +#ifdef CONFIG_PAX_KERNEXEC
33101 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33102 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33103 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33104 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33105 +#endif
33106 +
33107 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33108 gdt_descr.size = GDT_SIZE - 1;
33109 load_gdt(&gdt_descr);
33110 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33111 {
33112 struct desc_ptr gdt_descr;
33113
33114 +#ifdef CONFIG_PAX_KERNEXEC
33115 + struct desc_struct d;
33116 +
33117 + memset(&d, 0, sizeof d);
33118 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33119 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33120 +#endif
33121 +
33122 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33123 gdt_descr.size = GDT_SIZE - 1;
33124 load_gdt(&gdt_descr);
33125
33126 +#ifdef CONFIG_PAX_PER_CPU_PGD
33127 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33128 +#else
33129 load_cr3(swapper_pg_dir);
33130 +#endif
33131 +
33132 __flush_tlb_all();
33133
33134 local_irq_restore(efi_rt_eflags);
33135 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33136 index 39a0e7f1..872396e 100644
33137 --- a/arch/x86/platform/efi/efi_64.c
33138 +++ b/arch/x86/platform/efi/efi_64.c
33139 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33140 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33141 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33142 }
33143 +
33144 +#ifdef CONFIG_PAX_PER_CPU_PGD
33145 + load_cr3(swapper_pg_dir);
33146 +#endif
33147 +
33148 __flush_tlb_all();
33149 }
33150
33151 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33152 for (pgd = 0; pgd < n_pgds; pgd++)
33153 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33154 kfree(save_pgd);
33155 +
33156 +#ifdef CONFIG_PAX_PER_CPU_PGD
33157 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33158 +#endif
33159 +
33160 __flush_tlb_all();
33161 local_irq_restore(efi_flags);
33162 early_code_mapping_set_exec(0);
33163 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33164 index fbe66e6..eae5e38 100644
33165 --- a/arch/x86/platform/efi/efi_stub_32.S
33166 +++ b/arch/x86/platform/efi/efi_stub_32.S
33167 @@ -6,7 +6,9 @@
33168 */
33169
33170 #include <linux/linkage.h>
33171 +#include <linux/init.h>
33172 #include <asm/page_types.h>
33173 +#include <asm/segment.h>
33174
33175 /*
33176 * efi_call_phys(void *, ...) is a function with variable parameters.
33177 @@ -20,7 +22,7 @@
33178 * service functions will comply with gcc calling convention, too.
33179 */
33180
33181 -.text
33182 +__INIT
33183 ENTRY(efi_call_phys)
33184 /*
33185 * 0. The function can only be called in Linux kernel. So CS has been
33186 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33187 * The mapping of lower virtual memory has been created in prelog and
33188 * epilog.
33189 */
33190 - movl $1f, %edx
33191 - subl $__PAGE_OFFSET, %edx
33192 - jmp *%edx
33193 +#ifdef CONFIG_PAX_KERNEXEC
33194 + movl $(__KERNEXEC_EFI_DS), %edx
33195 + mov %edx, %ds
33196 + mov %edx, %es
33197 + mov %edx, %ss
33198 + addl $2f,(1f)
33199 + ljmp *(1f)
33200 +
33201 +__INITDATA
33202 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33203 +.previous
33204 +
33205 +2:
33206 + subl $2b,(1b)
33207 +#else
33208 + jmp 1f-__PAGE_OFFSET
33209 1:
33210 +#endif
33211
33212 /*
33213 * 2. Now on the top of stack is the return
33214 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33215 * parameter 2, ..., param n. To make things easy, we save the return
33216 * address of efi_call_phys in a global variable.
33217 */
33218 - popl %edx
33219 - movl %edx, saved_return_addr
33220 - /* get the function pointer into ECX*/
33221 - popl %ecx
33222 - movl %ecx, efi_rt_function_ptr
33223 - movl $2f, %edx
33224 - subl $__PAGE_OFFSET, %edx
33225 - pushl %edx
33226 + popl (saved_return_addr)
33227 + popl (efi_rt_function_ptr)
33228
33229 /*
33230 * 3. Clear PG bit in %CR0.
33231 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33232 /*
33233 * 5. Call the physical function.
33234 */
33235 - jmp *%ecx
33236 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33237
33238 -2:
33239 /*
33240 * 6. After EFI runtime service returns, control will return to
33241 * following instruction. We'd better readjust stack pointer first.
33242 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33243 movl %cr0, %edx
33244 orl $0x80000000, %edx
33245 movl %edx, %cr0
33246 - jmp 1f
33247 -1:
33248 +
33249 /*
33250 * 8. Now restore the virtual mode from flat mode by
33251 * adding EIP with PAGE_OFFSET.
33252 */
33253 - movl $1f, %edx
33254 - jmp *%edx
33255 +#ifdef CONFIG_PAX_KERNEXEC
33256 + movl $(__KERNEL_DS), %edx
33257 + mov %edx, %ds
33258 + mov %edx, %es
33259 + mov %edx, %ss
33260 + ljmp $(__KERNEL_CS),$1f
33261 +#else
33262 + jmp 1f+__PAGE_OFFSET
33263 +#endif
33264 1:
33265
33266 /*
33267 * 9. Balance the stack. And because EAX contain the return value,
33268 * we'd better not clobber it.
33269 */
33270 - leal efi_rt_function_ptr, %edx
33271 - movl (%edx), %ecx
33272 - pushl %ecx
33273 + pushl (efi_rt_function_ptr)
33274
33275 /*
33276 - * 10. Push the saved return address onto the stack and return.
33277 + * 10. Return to the saved return address.
33278 */
33279 - leal saved_return_addr, %edx
33280 - movl (%edx), %ecx
33281 - pushl %ecx
33282 - ret
33283 + jmpl *(saved_return_addr)
33284 ENDPROC(efi_call_phys)
33285 .previous
33286
33287 -.data
33288 +__INITDATA
33289 saved_return_addr:
33290 .long 0
33291 efi_rt_function_ptr:
33292 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33293 index 4c07cca..2c8427d 100644
33294 --- a/arch/x86/platform/efi/efi_stub_64.S
33295 +++ b/arch/x86/platform/efi/efi_stub_64.S
33296 @@ -7,6 +7,7 @@
33297 */
33298
33299 #include <linux/linkage.h>
33300 +#include <asm/alternative-asm.h>
33301
33302 #define SAVE_XMM \
33303 mov %rsp, %rax; \
33304 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33305 call *%rdi
33306 addq $32, %rsp
33307 RESTORE_XMM
33308 + pax_force_retaddr 0, 1
33309 ret
33310 ENDPROC(efi_call0)
33311
33312 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33313 call *%rdi
33314 addq $32, %rsp
33315 RESTORE_XMM
33316 + pax_force_retaddr 0, 1
33317 ret
33318 ENDPROC(efi_call1)
33319
33320 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33321 call *%rdi
33322 addq $32, %rsp
33323 RESTORE_XMM
33324 + pax_force_retaddr 0, 1
33325 ret
33326 ENDPROC(efi_call2)
33327
33328 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33329 call *%rdi
33330 addq $32, %rsp
33331 RESTORE_XMM
33332 + pax_force_retaddr 0, 1
33333 ret
33334 ENDPROC(efi_call3)
33335
33336 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33337 call *%rdi
33338 addq $32, %rsp
33339 RESTORE_XMM
33340 + pax_force_retaddr 0, 1
33341 ret
33342 ENDPROC(efi_call4)
33343
33344 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33345 call *%rdi
33346 addq $48, %rsp
33347 RESTORE_XMM
33348 + pax_force_retaddr 0, 1
33349 ret
33350 ENDPROC(efi_call5)
33351
33352 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33353 call *%rdi
33354 addq $48, %rsp
33355 RESTORE_XMM
33356 + pax_force_retaddr 0, 1
33357 ret
33358 ENDPROC(efi_call6)
33359 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33360 index 47fe66f..6206449 100644
33361 --- a/arch/x86/platform/mrst/mrst.c
33362 +++ b/arch/x86/platform/mrst/mrst.c
33363 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33364 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33365 int sfi_mrtc_num;
33366
33367 -static void mrst_power_off(void)
33368 +static __noreturn void mrst_power_off(void)
33369 {
33370 + BUG();
33371 }
33372
33373 -static void mrst_reboot(void)
33374 +static __noreturn void mrst_reboot(void)
33375 {
33376 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33377 + BUG();
33378 }
33379
33380 /* parse all the mtimer info to a static mtimer array */
33381 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33382 index d6ee929..3637cb5 100644
33383 --- a/arch/x86/platform/olpc/olpc_dt.c
33384 +++ b/arch/x86/platform/olpc/olpc_dt.c
33385 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33386 return res;
33387 }
33388
33389 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33390 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33391 .nextprop = olpc_dt_nextprop,
33392 .getproplen = olpc_dt_getproplen,
33393 .getproperty = olpc_dt_getproperty,
33394 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33395 index 1cf5b30..fd45732 100644
33396 --- a/arch/x86/power/cpu.c
33397 +++ b/arch/x86/power/cpu.c
33398 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33399 static void fix_processor_context(void)
33400 {
33401 int cpu = smp_processor_id();
33402 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33403 -#ifdef CONFIG_X86_64
33404 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33405 - tss_desc tss;
33406 -#endif
33407 + struct tss_struct *t = init_tss + cpu;
33408 +
33409 set_tss_desc(cpu, t); /*
33410 * This just modifies memory; should not be
33411 * necessary. But... This is necessary, because
33412 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33413 */
33414
33415 #ifdef CONFIG_X86_64
33416 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33417 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33418 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33419 -
33420 syscall_init(); /* This sets MSR_*STAR and related */
33421 #endif
33422 load_TR_desc(); /* This does ltr */
33423 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33424 index a44f457..9140171 100644
33425 --- a/arch/x86/realmode/init.c
33426 +++ b/arch/x86/realmode/init.c
33427 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33428 __va(real_mode_header->trampoline_header);
33429
33430 #ifdef CONFIG_X86_32
33431 - trampoline_header->start = __pa_symbol(startup_32_smp);
33432 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33433 +
33434 +#ifdef CONFIG_PAX_KERNEXEC
33435 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33436 +#endif
33437 +
33438 + trampoline_header->boot_cs = __BOOT_CS;
33439 trampoline_header->gdt_limit = __BOOT_DS + 7;
33440 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33441 #else
33442 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33443 *trampoline_cr4_features = read_cr4();
33444
33445 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33446 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33447 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33448 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33449 #endif
33450 }
33451 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33452 index 8869287..d577672 100644
33453 --- a/arch/x86/realmode/rm/Makefile
33454 +++ b/arch/x86/realmode/rm/Makefile
33455 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33456 $(call cc-option, -fno-unit-at-a-time)) \
33457 $(call cc-option, -fno-stack-protector) \
33458 $(call cc-option, -mpreferred-stack-boundary=2)
33459 +ifdef CONSTIFY_PLUGIN
33460 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33461 +endif
33462 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33463 GCOV_PROFILE := n
33464 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33465 index a28221d..93c40f1 100644
33466 --- a/arch/x86/realmode/rm/header.S
33467 +++ b/arch/x86/realmode/rm/header.S
33468 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33469 #endif
33470 /* APM/BIOS reboot */
33471 .long pa_machine_real_restart_asm
33472 -#ifdef CONFIG_X86_64
33473 +#ifdef CONFIG_X86_32
33474 + .long __KERNEL_CS
33475 +#else
33476 .long __KERNEL32_CS
33477 #endif
33478 END(real_mode_header)
33479 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33480 index c1b2791..f9e31c7 100644
33481 --- a/arch/x86/realmode/rm/trampoline_32.S
33482 +++ b/arch/x86/realmode/rm/trampoline_32.S
33483 @@ -25,6 +25,12 @@
33484 #include <asm/page_types.h>
33485 #include "realmode.h"
33486
33487 +#ifdef CONFIG_PAX_KERNEXEC
33488 +#define ta(X) (X)
33489 +#else
33490 +#define ta(X) (pa_ ## X)
33491 +#endif
33492 +
33493 .text
33494 .code16
33495
33496 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33497
33498 cli # We should be safe anyway
33499
33500 - movl tr_start, %eax # where we need to go
33501 -
33502 movl $0xA5A5A5A5, trampoline_status
33503 # write marker for master knows we're running
33504
33505 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33506 movw $1, %dx # protected mode (PE) bit
33507 lmsw %dx # into protected mode
33508
33509 - ljmpl $__BOOT_CS, $pa_startup_32
33510 + ljmpl *(trampoline_header)
33511
33512 .section ".text32","ax"
33513 .code32
33514 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33515 .balign 8
33516 GLOBAL(trampoline_header)
33517 tr_start: .space 4
33518 - tr_gdt_pad: .space 2
33519 + tr_boot_cs: .space 2
33520 tr_gdt: .space 6
33521 END(trampoline_header)
33522
33523 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33524 index bb360dc..d0fd8f8 100644
33525 --- a/arch/x86/realmode/rm/trampoline_64.S
33526 +++ b/arch/x86/realmode/rm/trampoline_64.S
33527 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33528 movl %edx, %gs
33529
33530 movl pa_tr_cr4, %eax
33531 + andl $~X86_CR4_PCIDE, %eax
33532 movl %eax, %cr4 # Enable PAE mode
33533
33534 # Setup trampoline 4 level pagetables
33535 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33536 wrmsr
33537
33538 # Enable paging and in turn activate Long Mode
33539 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33540 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33541 movl %eax, %cr0
33542
33543 /*
33544 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33545 index e812034..c747134 100644
33546 --- a/arch/x86/tools/Makefile
33547 +++ b/arch/x86/tools/Makefile
33548 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33549
33550 $(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
33551
33552 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33553 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33554 hostprogs-y += relocs
33555 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33556 relocs: $(obj)/relocs
33557 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33558 index f7bab68..b6d9886 100644
33559 --- a/arch/x86/tools/relocs.c
33560 +++ b/arch/x86/tools/relocs.c
33561 @@ -1,5 +1,7 @@
33562 /* This is included from relocs_32/64.c */
33563
33564 +#include "../../../include/generated/autoconf.h"
33565 +
33566 #define ElfW(type) _ElfW(ELF_BITS, type)
33567 #define _ElfW(bits, type) __ElfW(bits, type)
33568 #define __ElfW(bits, type) Elf##bits##_##type
33569 @@ -11,6 +13,7 @@
33570 #define Elf_Sym ElfW(Sym)
33571
33572 static Elf_Ehdr ehdr;
33573 +static Elf_Phdr *phdr;
33574
33575 struct relocs {
33576 uint32_t *offset;
33577 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33578 }
33579 }
33580
33581 +static void read_phdrs(FILE *fp)
33582 +{
33583 + unsigned int i;
33584 +
33585 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33586 + if (!phdr) {
33587 + die("Unable to allocate %d program headers\n",
33588 + ehdr.e_phnum);
33589 + }
33590 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33591 + die("Seek to %d failed: %s\n",
33592 + ehdr.e_phoff, strerror(errno));
33593 + }
33594 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33595 + die("Cannot read ELF program headers: %s\n",
33596 + strerror(errno));
33597 + }
33598 + for(i = 0; i < ehdr.e_phnum; i++) {
33599 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33600 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33601 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33602 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33603 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33604 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33605 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33606 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33607 + }
33608 +
33609 +}
33610 +
33611 static void read_shdrs(FILE *fp)
33612 {
33613 - int i;
33614 + unsigned int i;
33615 Elf_Shdr shdr;
33616
33617 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33618 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33619
33620 static void read_strtabs(FILE *fp)
33621 {
33622 - int i;
33623 + unsigned int i;
33624 for (i = 0; i < ehdr.e_shnum; i++) {
33625 struct section *sec = &secs[i];
33626 if (sec->shdr.sh_type != SHT_STRTAB) {
33627 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33628
33629 static void read_symtabs(FILE *fp)
33630 {
33631 - int i,j;
33632 + unsigned int i,j;
33633 for (i = 0; i < ehdr.e_shnum; i++) {
33634 struct section *sec = &secs[i];
33635 if (sec->shdr.sh_type != SHT_SYMTAB) {
33636 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33637 }
33638
33639
33640 -static void read_relocs(FILE *fp)
33641 +static void read_relocs(FILE *fp, int use_real_mode)
33642 {
33643 - int i,j;
33644 + unsigned int i,j;
33645 + uint32_t base;
33646 +
33647 for (i = 0; i < ehdr.e_shnum; i++) {
33648 struct section *sec = &secs[i];
33649 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33650 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33651 die("Cannot read symbol table: %s\n",
33652 strerror(errno));
33653 }
33654 + base = 0;
33655 +
33656 +#ifdef CONFIG_X86_32
33657 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33658 + if (phdr[j].p_type != PT_LOAD )
33659 + continue;
33660 + 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)
33661 + continue;
33662 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33663 + break;
33664 + }
33665 +#endif
33666 +
33667 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33668 Elf_Rel *rel = &sec->reltab[j];
33669 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33670 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33671 rel->r_info = elf_xword_to_cpu(rel->r_info);
33672 #if (SHT_REL_TYPE == SHT_RELA)
33673 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33674 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33675
33676 static void print_absolute_symbols(void)
33677 {
33678 - int i;
33679 + unsigned int i;
33680 const char *format;
33681
33682 if (ELF_BITS == 64)
33683 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33684 for (i = 0; i < ehdr.e_shnum; i++) {
33685 struct section *sec = &secs[i];
33686 char *sym_strtab;
33687 - int j;
33688 + unsigned int j;
33689
33690 if (sec->shdr.sh_type != SHT_SYMTAB) {
33691 continue;
33692 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33693
33694 static void print_absolute_relocs(void)
33695 {
33696 - int i, printed = 0;
33697 + unsigned int i, printed = 0;
33698 const char *format;
33699
33700 if (ELF_BITS == 64)
33701 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33702 struct section *sec_applies, *sec_symtab;
33703 char *sym_strtab;
33704 Elf_Sym *sh_symtab;
33705 - int j;
33706 + unsigned int j;
33707 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33708 continue;
33709 }
33710 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33711 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33712 Elf_Sym *sym, const char *symname))
33713 {
33714 - int i;
33715 + unsigned int i;
33716 /* Walk through the relocations */
33717 for (i = 0; i < ehdr.e_shnum; i++) {
33718 char *sym_strtab;
33719 Elf_Sym *sh_symtab;
33720 struct section *sec_applies, *sec_symtab;
33721 - int j;
33722 + unsigned int j;
33723 struct section *sec = &secs[i];
33724
33725 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33726 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33727 {
33728 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33729 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33730 + char *sym_strtab = sec->link->link->strtab;
33731 +
33732 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33733 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33734 + return 0;
33735 +
33736 +#ifdef CONFIG_PAX_KERNEXEC
33737 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33738 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33739 + return 0;
33740 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33741 + return 0;
33742 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33743 + return 0;
33744 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33745 + return 0;
33746 +#endif
33747
33748 switch (r_type) {
33749 case R_386_NONE:
33750 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33751
33752 static void emit_relocs(int as_text, int use_real_mode)
33753 {
33754 - int i;
33755 + unsigned int i;
33756 int (*write_reloc)(uint32_t, FILE *) = write32;
33757 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33758 const char *symname);
33759 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33760 {
33761 regex_init(use_real_mode);
33762 read_ehdr(fp);
33763 + read_phdrs(fp);
33764 read_shdrs(fp);
33765 read_strtabs(fp);
33766 read_symtabs(fp);
33767 - read_relocs(fp);
33768 + read_relocs(fp, use_real_mode);
33769 if (ELF_BITS == 64)
33770 percpu_init();
33771 if (show_absolute_syms) {
33772 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33773 index 80ffa5b..a33bd15 100644
33774 --- a/arch/x86/um/tls_32.c
33775 +++ b/arch/x86/um/tls_32.c
33776 @@ -260,7 +260,7 @@ out:
33777 if (unlikely(task == current &&
33778 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33779 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33780 - "without flushed TLS.", current->pid);
33781 + "without flushed TLS.", task_pid_nr(current));
33782 }
33783
33784 return 0;
33785 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33786 index fd14be1..e3c79c0 100644
33787 --- a/arch/x86/vdso/Makefile
33788 +++ b/arch/x86/vdso/Makefile
33789 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33790 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33791 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33792
33793 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33794 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33795 GCOV_PROFILE := n
33796
33797 #
33798 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33799 index d6bfb87..876ee18 100644
33800 --- a/arch/x86/vdso/vdso32-setup.c
33801 +++ b/arch/x86/vdso/vdso32-setup.c
33802 @@ -25,6 +25,7 @@
33803 #include <asm/tlbflush.h>
33804 #include <asm/vdso.h>
33805 #include <asm/proto.h>
33806 +#include <asm/mman.h>
33807
33808 enum {
33809 VDSO_DISABLED = 0,
33810 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33811 void enable_sep_cpu(void)
33812 {
33813 int cpu = get_cpu();
33814 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33815 + struct tss_struct *tss = init_tss + cpu;
33816
33817 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33818 put_cpu();
33819 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33820 gate_vma.vm_start = FIXADDR_USER_START;
33821 gate_vma.vm_end = FIXADDR_USER_END;
33822 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33823 - gate_vma.vm_page_prot = __P101;
33824 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33825
33826 return 0;
33827 }
33828 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33829 if (compat)
33830 addr = VDSO_HIGH_BASE;
33831 else {
33832 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33833 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33834 if (IS_ERR_VALUE(addr)) {
33835 ret = addr;
33836 goto up_fail;
33837 }
33838 }
33839
33840 - current->mm->context.vdso = (void *)addr;
33841 + current->mm->context.vdso = addr;
33842
33843 if (compat_uses_vma || !compat) {
33844 /*
33845 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33846 }
33847
33848 current_thread_info()->sysenter_return =
33849 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33850 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33851
33852 up_fail:
33853 if (ret)
33854 - current->mm->context.vdso = NULL;
33855 + current->mm->context.vdso = 0;
33856
33857 up_write(&mm->mmap_sem);
33858
33859 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33860
33861 const char *arch_vma_name(struct vm_area_struct *vma)
33862 {
33863 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33864 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33865 return "[vdso]";
33866 +
33867 +#ifdef CONFIG_PAX_SEGMEXEC
33868 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33869 + return "[vdso]";
33870 +#endif
33871 +
33872 return NULL;
33873 }
33874
33875 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33876 * Check to see if the corresponding task was created in compat vdso
33877 * mode.
33878 */
33879 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33880 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33881 return &gate_vma;
33882 return NULL;
33883 }
33884 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33885 index 431e875..cbb23f3 100644
33886 --- a/arch/x86/vdso/vma.c
33887 +++ b/arch/x86/vdso/vma.c
33888 @@ -16,8 +16,6 @@
33889 #include <asm/vdso.h>
33890 #include <asm/page.h>
33891
33892 -unsigned int __read_mostly vdso_enabled = 1;
33893 -
33894 extern char vdso_start[], vdso_end[];
33895 extern unsigned short vdso_sync_cpuid;
33896
33897 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33898 * unaligned here as a result of stack start randomization.
33899 */
33900 addr = PAGE_ALIGN(addr);
33901 - addr = align_vdso_addr(addr);
33902
33903 return addr;
33904 }
33905 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33906 unsigned size)
33907 {
33908 struct mm_struct *mm = current->mm;
33909 - unsigned long addr;
33910 + unsigned long addr = 0;
33911 int ret;
33912
33913 - if (!vdso_enabled)
33914 - return 0;
33915 -
33916 down_write(&mm->mmap_sem);
33917 +
33918 +#ifdef CONFIG_PAX_RANDMMAP
33919 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33920 +#endif
33921 +
33922 addr = vdso_addr(mm->start_stack, size);
33923 + addr = align_vdso_addr(addr);
33924 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33925 if (IS_ERR_VALUE(addr)) {
33926 ret = addr;
33927 goto up_fail;
33928 }
33929
33930 - current->mm->context.vdso = (void *)addr;
33931 + mm->context.vdso = addr;
33932
33933 ret = install_special_mapping(mm, addr, size,
33934 VM_READ|VM_EXEC|
33935 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33936 pages);
33937 - if (ret) {
33938 - current->mm->context.vdso = NULL;
33939 - goto up_fail;
33940 - }
33941 + if (ret)
33942 + mm->context.vdso = 0;
33943
33944 up_fail:
33945 up_write(&mm->mmap_sem);
33946 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33947 vdsox32_size);
33948 }
33949 #endif
33950 -
33951 -static __init int vdso_setup(char *s)
33952 -{
33953 - vdso_enabled = simple_strtoul(s, NULL, 0);
33954 - return 0;
33955 -}
33956 -__setup("vdso=", vdso_setup);
33957 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33958 index 193097e..7590269 100644
33959 --- a/arch/x86/xen/enlighten.c
33960 +++ b/arch/x86/xen/enlighten.c
33961 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33962
33963 struct shared_info xen_dummy_shared_info;
33964
33965 -void *xen_initial_gdt;
33966 -
33967 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33968 __read_mostly int xen_have_vector_callback;
33969 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33970 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33971 {
33972 unsigned long va = dtr->address;
33973 unsigned int size = dtr->size + 1;
33974 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33975 - unsigned long frames[pages];
33976 + unsigned long frames[65536 / PAGE_SIZE];
33977 int f;
33978
33979 /*
33980 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33981 {
33982 unsigned long va = dtr->address;
33983 unsigned int size = dtr->size + 1;
33984 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33985 - unsigned long frames[pages];
33986 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33987 int f;
33988
33989 /*
33990 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33991 * 8-byte entries, or 16 4k pages..
33992 */
33993
33994 - BUG_ON(size > 65536);
33995 + BUG_ON(size > GDT_SIZE);
33996 BUG_ON(va & ~PAGE_MASK);
33997
33998 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
33999 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
34000 return 0;
34001 }
34002
34003 -static void set_xen_basic_apic_ops(void)
34004 +static void __init set_xen_basic_apic_ops(void)
34005 {
34006 apic->read = xen_apic_read;
34007 apic->write = xen_apic_write;
34008 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
34009 #endif
34010 };
34011
34012 -static void xen_reboot(int reason)
34013 +static __noreturn void xen_reboot(int reason)
34014 {
34015 struct sched_shutdown r = { .reason = reason };
34016
34017 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34018 - BUG();
34019 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34020 + BUG();
34021 }
34022
34023 -static void xen_restart(char *msg)
34024 +static __noreturn void xen_restart(char *msg)
34025 {
34026 xen_reboot(SHUTDOWN_reboot);
34027 }
34028
34029 -static void xen_emergency_restart(void)
34030 +static __noreturn void xen_emergency_restart(void)
34031 {
34032 xen_reboot(SHUTDOWN_reboot);
34033 }
34034
34035 -static void xen_machine_halt(void)
34036 +static __noreturn void xen_machine_halt(void)
34037 {
34038 xen_reboot(SHUTDOWN_poweroff);
34039 }
34040
34041 -static void xen_machine_power_off(void)
34042 +static __noreturn void xen_machine_power_off(void)
34043 {
34044 if (pm_power_off)
34045 pm_power_off();
34046 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
34047 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34048
34049 /* Work out if we support NX */
34050 - x86_configure_nx();
34051 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34052 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34053 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34054 + unsigned l, h;
34055 +
34056 + __supported_pte_mask |= _PAGE_NX;
34057 + rdmsr(MSR_EFER, l, h);
34058 + l |= EFER_NX;
34059 + wrmsr(MSR_EFER, l, h);
34060 + }
34061 +#endif
34062
34063 xen_setup_features();
34064
34065 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
34066
34067 machine_ops = xen_machine_ops;
34068
34069 - /*
34070 - * The only reliable way to retain the initial address of the
34071 - * percpu gdt_page is to remember it here, so we can go and
34072 - * mark it RW later, when the initial percpu area is freed.
34073 - */
34074 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34075 -
34076 xen_smp_init();
34077
34078 #ifdef CONFIG_ACPI_NUMA
34079 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34080 index fdc3ba2..3daee39 100644
34081 --- a/arch/x86/xen/mmu.c
34082 +++ b/arch/x86/xen/mmu.c
34083 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34084 /* L3_k[510] -> level2_kernel_pgt
34085 * L3_i[511] -> level2_fixmap_pgt */
34086 convert_pfn_mfn(level3_kernel_pgt);
34087 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34088 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34089 + convert_pfn_mfn(level3_vmemmap_pgt);
34090
34091 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34092 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34093 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34094 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34095 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34096 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34097 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34098 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34099 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34100 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34101 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34102 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34103 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34104 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34105
34106 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34107 pv_mmu_ops.set_pud = xen_set_pud;
34108 #if PAGETABLE_LEVELS == 4
34109 pv_mmu_ops.set_pgd = xen_set_pgd;
34110 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34111 #endif
34112
34113 /* This will work as long as patching hasn't happened yet
34114 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34115 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34116 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34117 .set_pgd = xen_set_pgd_hyper,
34118 + .set_pgd_batched = xen_set_pgd_hyper,
34119
34120 .alloc_pud = xen_alloc_pmd_init,
34121 .release_pud = xen_release_pmd_init,
34122 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34123 index b81c88e..2cbe7b8 100644
34124 --- a/arch/x86/xen/smp.c
34125 +++ b/arch/x86/xen/smp.c
34126 @@ -272,11 +272,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
34127 {
34128 BUG_ON(smp_processor_id() != 0);
34129 native_smp_prepare_boot_cpu();
34130 -
34131 - /* We've switched to the "real" per-cpu gdt, so make sure the
34132 - old memory can be recycled */
34133 - make_lowmem_page_readwrite(xen_initial_gdt);
34134 -
34135 xen_filter_cpu_maps();
34136 xen_setup_vcpu_info_placement();
34137 }
34138 @@ -346,7 +341,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34139 ctxt->user_regs.ss = __KERNEL_DS;
34140 #ifdef CONFIG_X86_32
34141 ctxt->user_regs.fs = __KERNEL_PERCPU;
34142 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34143 + savesegment(gs, ctxt->user_regs.gs);
34144 #else
34145 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34146 #endif
34147 @@ -356,8 +351,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34148
34149 {
34150 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34151 - ctxt->user_regs.ds = __USER_DS;
34152 - ctxt->user_regs.es = __USER_DS;
34153 + ctxt->user_regs.ds = __KERNEL_DS;
34154 + ctxt->user_regs.es = __KERNEL_DS;
34155
34156 xen_copy_trap_info(ctxt->trap_ctxt);
34157
34158 @@ -402,13 +397,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34159 int rc;
34160
34161 per_cpu(current_task, cpu) = idle;
34162 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34163 #ifdef CONFIG_X86_32
34164 irq_ctx_init(cpu);
34165 #else
34166 clear_tsk_thread_flag(idle, TIF_FORK);
34167 - per_cpu(kernel_stack, cpu) =
34168 - (unsigned long)task_stack_page(idle) -
34169 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34170 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34171 #endif
34172 xen_setup_runstate_info(cpu);
34173 xen_setup_timer(cpu);
34174 @@ -678,7 +672,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34175
34176 void __init xen_smp_init(void)
34177 {
34178 - smp_ops = xen_smp_ops;
34179 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34180 xen_fill_possible_map();
34181 xen_init_spinlocks();
34182 }
34183 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34184 index 33ca6e4..0ded929 100644
34185 --- a/arch/x86/xen/xen-asm_32.S
34186 +++ b/arch/x86/xen/xen-asm_32.S
34187 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34188 ESP_OFFSET=4 # bytes pushed onto stack
34189
34190 /*
34191 - * Store vcpu_info pointer for easy access. Do it this way to
34192 - * avoid having to reload %fs
34193 + * Store vcpu_info pointer for easy access.
34194 */
34195 #ifdef CONFIG_SMP
34196 - GET_THREAD_INFO(%eax)
34197 - movl %ss:TI_cpu(%eax), %eax
34198 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34199 - mov %ss:xen_vcpu(%eax), %eax
34200 + push %fs
34201 + mov $(__KERNEL_PERCPU), %eax
34202 + mov %eax, %fs
34203 + mov PER_CPU_VAR(xen_vcpu), %eax
34204 + pop %fs
34205 #else
34206 movl %ss:xen_vcpu, %eax
34207 #endif
34208 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34209 index 7faed58..ba4427c 100644
34210 --- a/arch/x86/xen/xen-head.S
34211 +++ b/arch/x86/xen/xen-head.S
34212 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34213 #ifdef CONFIG_X86_32
34214 mov %esi,xen_start_info
34215 mov $init_thread_union+THREAD_SIZE,%esp
34216 +#ifdef CONFIG_SMP
34217 + movl $cpu_gdt_table,%edi
34218 + movl $__per_cpu_load,%eax
34219 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34220 + rorl $16,%eax
34221 + movb %al,__KERNEL_PERCPU + 4(%edi)
34222 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34223 + movl $__per_cpu_end - 1,%eax
34224 + subl $__per_cpu_start,%eax
34225 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34226 +#endif
34227 #else
34228 mov %rsi,xen_start_info
34229 mov $init_thread_union+THREAD_SIZE,%rsp
34230 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34231 index 86782c5..fa272c8 100644
34232 --- a/arch/x86/xen/xen-ops.h
34233 +++ b/arch/x86/xen/xen-ops.h
34234 @@ -10,8 +10,6 @@
34235 extern const char xen_hypervisor_callback[];
34236 extern const char xen_failsafe_callback[];
34237
34238 -extern void *xen_initial_gdt;
34239 -
34240 struct trap_info;
34241 void xen_copy_trap_info(struct trap_info *traps);
34242
34243 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34244 index 525bd3d..ef888b1 100644
34245 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34246 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34247 @@ -119,9 +119,9 @@
34248 ----------------------------------------------------------------------*/
34249
34250 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34251 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34252 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34253 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34254 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34255
34256 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34257 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34258 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34259 index 2f33760..835e50a 100644
34260 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34261 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34262 @@ -11,6 +11,7 @@
34263 #ifndef _XTENSA_CORE_H
34264 #define _XTENSA_CORE_H
34265
34266 +#include <linux/const.h>
34267
34268 /****************************************************************************
34269 Parameters Useful for Any Code, USER or PRIVILEGED
34270 @@ -112,9 +113,9 @@
34271 ----------------------------------------------------------------------*/
34272
34273 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34274 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34275 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34276 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34277 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34278
34279 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34280 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34281 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34282 index af00795..2bb8105 100644
34283 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34284 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34285 @@ -11,6 +11,7 @@
34286 #ifndef _XTENSA_CORE_CONFIGURATION_H
34287 #define _XTENSA_CORE_CONFIGURATION_H
34288
34289 +#include <linux/const.h>
34290
34291 /****************************************************************************
34292 Parameters Useful for Any Code, USER or PRIVILEGED
34293 @@ -118,9 +119,9 @@
34294 ----------------------------------------------------------------------*/
34295
34296 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34297 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34298 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34299 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34300 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34301
34302 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34303 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34304 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34305 index 290792a..416f287 100644
34306 --- a/block/blk-cgroup.c
34307 +++ b/block/blk-cgroup.c
34308 @@ -808,7 +808,7 @@ static void blkcg_css_free(struct cgroup *cgroup)
34309
34310 static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34311 {
34312 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34313 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34314 struct blkcg *blkcg;
34315 struct cgroup *parent = cgroup->parent;
34316
34317 @@ -823,7 +823,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34318
34319 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34320 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34321 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34322 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34323 done:
34324 spin_lock_init(&blkcg->lock);
34325 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34326 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34327 index 4b8d9b54..a7178c0 100644
34328 --- a/block/blk-iopoll.c
34329 +++ b/block/blk-iopoll.c
34330 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34331 }
34332 EXPORT_SYMBOL(blk_iopoll_complete);
34333
34334 -static void blk_iopoll_softirq(struct softirq_action *h)
34335 +static __latent_entropy void blk_iopoll_softirq(void)
34336 {
34337 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34338 int rearm = 0, budget = blk_iopoll_budget;
34339 diff --git a/block/blk-map.c b/block/blk-map.c
34340 index 623e1cd..ca1e109 100644
34341 --- a/block/blk-map.c
34342 +++ b/block/blk-map.c
34343 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34344 if (!len || !kbuf)
34345 return -EINVAL;
34346
34347 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34348 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34349 if (do_copy)
34350 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34351 else
34352 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34353 index ec9e606..3f38839 100644
34354 --- a/block/blk-softirq.c
34355 +++ b/block/blk-softirq.c
34356 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34357 * Softirq action handler - move entries to local list and loop over them
34358 * while passing them to the queue registered handler.
34359 */
34360 -static void blk_done_softirq(struct softirq_action *h)
34361 +static __latent_entropy void blk_done_softirq(void)
34362 {
34363 struct list_head *cpu_list, local_list;
34364
34365 diff --git a/block/bsg.c b/block/bsg.c
34366 index 420a5a9..23834aa 100644
34367 --- a/block/bsg.c
34368 +++ b/block/bsg.c
34369 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34370 struct sg_io_v4 *hdr, struct bsg_device *bd,
34371 fmode_t has_write_perm)
34372 {
34373 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34374 + unsigned char *cmdptr;
34375 +
34376 if (hdr->request_len > BLK_MAX_CDB) {
34377 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34378 if (!rq->cmd)
34379 return -ENOMEM;
34380 - }
34381 + cmdptr = rq->cmd;
34382 + } else
34383 + cmdptr = tmpcmd;
34384
34385 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34386 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34387 hdr->request_len))
34388 return -EFAULT;
34389
34390 + if (cmdptr != rq->cmd)
34391 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34392 +
34393 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34394 if (blk_verify_command(rq->cmd, has_write_perm))
34395 return -EPERM;
34396 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34397 index 7e5d474..0cf0017 100644
34398 --- a/block/compat_ioctl.c
34399 +++ b/block/compat_ioctl.c
34400 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34401 err |= __get_user(f->spec1, &uf->spec1);
34402 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34403 err |= __get_user(name, &uf->name);
34404 - f->name = compat_ptr(name);
34405 + f->name = (void __force_kernel *)compat_ptr(name);
34406 if (err) {
34407 err = -EFAULT;
34408 goto out;
34409 diff --git a/block/genhd.c b/block/genhd.c
34410 index dadf42b..48dc887 100644
34411 --- a/block/genhd.c
34412 +++ b/block/genhd.c
34413 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34414
34415 /*
34416 * Register device numbers dev..(dev+range-1)
34417 - * range must be nonzero
34418 + * Noop if @range is zero.
34419 * The hash chain is sorted on range, so that subranges can override.
34420 */
34421 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34422 struct kobject *(*probe)(dev_t, int *, void *),
34423 int (*lock)(dev_t, void *), void *data)
34424 {
34425 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34426 + if (range)
34427 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34428 }
34429
34430 EXPORT_SYMBOL(blk_register_region);
34431
34432 +/* undo blk_register_region(), noop if @range is zero */
34433 void blk_unregister_region(dev_t devt, unsigned long range)
34434 {
34435 - kobj_unmap(bdev_map, devt, range);
34436 + if (range)
34437 + kobj_unmap(bdev_map, devt, range);
34438 }
34439
34440 EXPORT_SYMBOL(blk_unregister_region);
34441 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34442 index c85fc89..51e690b 100644
34443 --- a/block/partitions/efi.c
34444 +++ b/block/partitions/efi.c
34445 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34446 if (!gpt)
34447 return NULL;
34448
34449 + if (!le32_to_cpu(gpt->num_partition_entries))
34450 + return NULL;
34451 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34452 + if (!pte)
34453 + return NULL;
34454 +
34455 count = le32_to_cpu(gpt->num_partition_entries) *
34456 le32_to_cpu(gpt->sizeof_partition_entry);
34457 - if (!count)
34458 - return NULL;
34459 - pte = kmalloc(count, GFP_KERNEL);
34460 - if (!pte)
34461 - return NULL;
34462 -
34463 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34464 (u8 *) pte,
34465 count) < count) {
34466 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34467 index a5ffcc9..3cedc9c 100644
34468 --- a/block/scsi_ioctl.c
34469 +++ b/block/scsi_ioctl.c
34470 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34471 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34472 struct sg_io_hdr *hdr, fmode_t mode)
34473 {
34474 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34475 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34476 + unsigned char *cmdptr;
34477 +
34478 + if (rq->cmd != rq->__cmd)
34479 + cmdptr = rq->cmd;
34480 + else
34481 + cmdptr = tmpcmd;
34482 +
34483 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34484 return -EFAULT;
34485 +
34486 + if (cmdptr != rq->cmd)
34487 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34488 +
34489 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34490 return -EPERM;
34491
34492 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34493 int err;
34494 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34495 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34496 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34497 + unsigned char *cmdptr;
34498
34499 if (!sic)
34500 return -EINVAL;
34501 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34502 */
34503 err = -EFAULT;
34504 rq->cmd_len = cmdlen;
34505 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34506 +
34507 + if (rq->cmd != rq->__cmd)
34508 + cmdptr = rq->cmd;
34509 + else
34510 + cmdptr = tmpcmd;
34511 +
34512 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34513 goto error;
34514
34515 + if (rq->cmd != cmdptr)
34516 + memcpy(rq->cmd, cmdptr, cmdlen);
34517 +
34518 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34519 goto error;
34520
34521 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34522 index 7bdd61b..afec999 100644
34523 --- a/crypto/cryptd.c
34524 +++ b/crypto/cryptd.c
34525 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34526
34527 struct cryptd_blkcipher_request_ctx {
34528 crypto_completion_t complete;
34529 -};
34530 +} __no_const;
34531
34532 struct cryptd_hash_ctx {
34533 struct crypto_shash *child;
34534 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34535
34536 struct cryptd_aead_request_ctx {
34537 crypto_completion_t complete;
34538 -};
34539 +} __no_const;
34540
34541 static void cryptd_queue_worker(struct work_struct *work);
34542
34543 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34544 index f8c920c..ab2cb5a 100644
34545 --- a/crypto/pcrypt.c
34546 +++ b/crypto/pcrypt.c
34547 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34548 int ret;
34549
34550 pinst->kobj.kset = pcrypt_kset;
34551 - ret = kobject_add(&pinst->kobj, NULL, name);
34552 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34553 if (!ret)
34554 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34555
34556 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34557 index f220d64..d359ad6 100644
34558 --- a/drivers/acpi/apei/apei-internal.h
34559 +++ b/drivers/acpi/apei/apei-internal.h
34560 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34561 struct apei_exec_ins_type {
34562 u32 flags;
34563 apei_exec_ins_func_t run;
34564 -};
34565 +} __do_const;
34566
34567 struct apei_exec_context {
34568 u32 ip;
34569 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34570 index 33dc6a0..4b24b47 100644
34571 --- a/drivers/acpi/apei/cper.c
34572 +++ b/drivers/acpi/apei/cper.c
34573 @@ -39,12 +39,12 @@
34574 */
34575 u64 cper_next_record_id(void)
34576 {
34577 - static atomic64_t seq;
34578 + static atomic64_unchecked_t seq;
34579
34580 - if (!atomic64_read(&seq))
34581 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34582 + if (!atomic64_read_unchecked(&seq))
34583 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34584
34585 - return atomic64_inc_return(&seq);
34586 + return atomic64_inc_return_unchecked(&seq);
34587 }
34588 EXPORT_SYMBOL_GPL(cper_next_record_id);
34589
34590 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34591 index ec9b57d..9682b3a 100644
34592 --- a/drivers/acpi/apei/ghes.c
34593 +++ b/drivers/acpi/apei/ghes.c
34594 @@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
34595 const struct acpi_hest_generic *generic,
34596 const struct acpi_hest_generic_status *estatus)
34597 {
34598 - static atomic_t seqno;
34599 + static atomic_unchecked_t seqno;
34600 unsigned int curr_seqno;
34601 char pfx_seq[64];
34602
34603 @@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
34604 else
34605 pfx = KERN_ERR;
34606 }
34607 - curr_seqno = atomic_inc_return(&seqno);
34608 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34609 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34610 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34611 pfx_seq, generic->header.source_id);
34612 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34613 index be60399..778b33e8 100644
34614 --- a/drivers/acpi/bgrt.c
34615 +++ b/drivers/acpi/bgrt.c
34616 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
34617 return -ENODEV;
34618
34619 sysfs_bin_attr_init(&image_attr);
34620 - image_attr.private = bgrt_image;
34621 - image_attr.size = bgrt_image_size;
34622 + pax_open_kernel();
34623 + *(void **)&image_attr.private = bgrt_image;
34624 + *(size_t *)&image_attr.size = bgrt_image_size;
34625 + pax_close_kernel();
34626
34627 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34628 if (!bgrt_kobj)
34629 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34630 index cb96296..b81293b 100644
34631 --- a/drivers/acpi/blacklist.c
34632 +++ b/drivers/acpi/blacklist.c
34633 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34634 u32 is_critical_error;
34635 };
34636
34637 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34638 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34639
34640 /*
34641 * POLICY: If *anything* doesn't work, put it on the blacklist.
34642 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
34643 return 0;
34644 }
34645
34646 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34647 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34648 {
34649 .callback = dmi_disable_osi_vista,
34650 .ident = "Fujitsu Siemens",
34651 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34652 index f98dd00..7b69865 100644
34653 --- a/drivers/acpi/processor_idle.c
34654 +++ b/drivers/acpi/processor_idle.c
34655 @@ -992,7 +992,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34656 {
34657 int i, count = CPUIDLE_DRIVER_STATE_START;
34658 struct acpi_processor_cx *cx;
34659 - struct cpuidle_state *state;
34660 + cpuidle_state_no_const *state;
34661 struct cpuidle_driver *drv = &acpi_idle_driver;
34662
34663 if (!pr->flags.power_setup_done)
34664 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34665 index 05306a5..733d1f0 100644
34666 --- a/drivers/acpi/sysfs.c
34667 +++ b/drivers/acpi/sysfs.c
34668 @@ -423,11 +423,11 @@ static u32 num_counters;
34669 static struct attribute **all_attrs;
34670 static u32 acpi_gpe_count;
34671
34672 -static struct attribute_group interrupt_stats_attr_group = {
34673 +static attribute_group_no_const interrupt_stats_attr_group = {
34674 .name = "interrupts",
34675 };
34676
34677 -static struct kobj_attribute *counter_attrs;
34678 +static kobj_attribute_no_const *counter_attrs;
34679
34680 static void delete_gpe_attr_array(void)
34681 {
34682 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34683 index acfd0f7..e5acb08 100644
34684 --- a/drivers/ata/libahci.c
34685 +++ b/drivers/ata/libahci.c
34686 @@ -1231,7 +1231,7 @@ int ahci_kick_engine(struct ata_port *ap)
34687 }
34688 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34689
34690 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34691 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34692 struct ata_taskfile *tf, int is_cmd, u16 flags,
34693 unsigned long timeout_msec)
34694 {
34695 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34696 index c24354d..335c975 100644
34697 --- a/drivers/ata/libata-core.c
34698 +++ b/drivers/ata/libata-core.c
34699 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34700 static void ata_dev_xfermask(struct ata_device *dev);
34701 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34702
34703 -atomic_t ata_print_id = ATOMIC_INIT(0);
34704 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34705
34706 struct ata_force_param {
34707 const char *name;
34708 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34709 struct ata_port *ap;
34710 unsigned int tag;
34711
34712 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34713 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34714 ap = qc->ap;
34715
34716 qc->flags = 0;
34717 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34718 struct ata_port *ap;
34719 struct ata_link *link;
34720
34721 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34722 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34723 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34724 ap = qc->ap;
34725 link = qc->dev->link;
34726 @@ -5927,6 +5927,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34727 return;
34728
34729 spin_lock(&lock);
34730 + pax_open_kernel();
34731
34732 for (cur = ops->inherits; cur; cur = cur->inherits) {
34733 void **inherit = (void **)cur;
34734 @@ -5940,8 +5941,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34735 if (IS_ERR(*pp))
34736 *pp = NULL;
34737
34738 - ops->inherits = NULL;
34739 + *(struct ata_port_operations **)&ops->inherits = NULL;
34740
34741 + pax_close_kernel();
34742 spin_unlock(&lock);
34743 }
34744
34745 @@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34746
34747 /* give ports names and add SCSI hosts */
34748 for (i = 0; i < host->n_ports; i++) {
34749 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34750 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34751 host->ports[i]->local_port_no = i + 1;
34752 }
34753
34754 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34755 index b1e880a..8cf82e1 100644
34756 --- a/drivers/ata/libata-scsi.c
34757 +++ b/drivers/ata/libata-scsi.c
34758 @@ -4104,7 +4104,7 @@ int ata_sas_port_init(struct ata_port *ap)
34759
34760 if (rc)
34761 return rc;
34762 - ap->print_id = atomic_inc_return(&ata_print_id);
34763 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34764 return 0;
34765 }
34766 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34767 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34768 index 577d902b..cb4781e 100644
34769 --- a/drivers/ata/libata.h
34770 +++ b/drivers/ata/libata.h
34771 @@ -53,7 +53,7 @@ enum {
34772 ATA_DNXFER_QUIET = (1 << 31),
34773 };
34774
34775 -extern atomic_t ata_print_id;
34776 +extern atomic_unchecked_t ata_print_id;
34777 extern int atapi_passthru16;
34778 extern int libata_fua;
34779 extern int libata_noacpi;
34780 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34781 index 848ed32..132f39d 100644
34782 --- a/drivers/ata/pata_arasan_cf.c
34783 +++ b/drivers/ata/pata_arasan_cf.c
34784 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34785 /* Handle platform specific quirks */
34786 if (quirk) {
34787 if (quirk & CF_BROKEN_PIO) {
34788 - ap->ops->set_piomode = NULL;
34789 + pax_open_kernel();
34790 + *(void **)&ap->ops->set_piomode = NULL;
34791 + pax_close_kernel();
34792 ap->pio_mask = 0;
34793 }
34794 if (quirk & CF_BROKEN_MWDMA)
34795 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34796 index f9b983a..887b9d8 100644
34797 --- a/drivers/atm/adummy.c
34798 +++ b/drivers/atm/adummy.c
34799 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34800 vcc->pop(vcc, skb);
34801 else
34802 dev_kfree_skb_any(skb);
34803 - atomic_inc(&vcc->stats->tx);
34804 + atomic_inc_unchecked(&vcc->stats->tx);
34805
34806 return 0;
34807 }
34808 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34809 index 62a7607..cc4be104 100644
34810 --- a/drivers/atm/ambassador.c
34811 +++ b/drivers/atm/ambassador.c
34812 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34813 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34814
34815 // VC layer stats
34816 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34817 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34818
34819 // free the descriptor
34820 kfree (tx_descr);
34821 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34822 dump_skb ("<<<", vc, skb);
34823
34824 // VC layer stats
34825 - atomic_inc(&atm_vcc->stats->rx);
34826 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34827 __net_timestamp(skb);
34828 // end of our responsibility
34829 atm_vcc->push (atm_vcc, skb);
34830 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34831 } else {
34832 PRINTK (KERN_INFO, "dropped over-size frame");
34833 // should we count this?
34834 - atomic_inc(&atm_vcc->stats->rx_drop);
34835 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34836 }
34837
34838 } else {
34839 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34840 }
34841
34842 if (check_area (skb->data, skb->len)) {
34843 - atomic_inc(&atm_vcc->stats->tx_err);
34844 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34845 return -ENOMEM; // ?
34846 }
34847
34848 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34849 index 0e3f8f9..765a7a5 100644
34850 --- a/drivers/atm/atmtcp.c
34851 +++ b/drivers/atm/atmtcp.c
34852 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34853 if (vcc->pop) vcc->pop(vcc,skb);
34854 else dev_kfree_skb(skb);
34855 if (dev_data) return 0;
34856 - atomic_inc(&vcc->stats->tx_err);
34857 + atomic_inc_unchecked(&vcc->stats->tx_err);
34858 return -ENOLINK;
34859 }
34860 size = skb->len+sizeof(struct atmtcp_hdr);
34861 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34862 if (!new_skb) {
34863 if (vcc->pop) vcc->pop(vcc,skb);
34864 else dev_kfree_skb(skb);
34865 - atomic_inc(&vcc->stats->tx_err);
34866 + atomic_inc_unchecked(&vcc->stats->tx_err);
34867 return -ENOBUFS;
34868 }
34869 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34870 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34871 if (vcc->pop) vcc->pop(vcc,skb);
34872 else dev_kfree_skb(skb);
34873 out_vcc->push(out_vcc,new_skb);
34874 - atomic_inc(&vcc->stats->tx);
34875 - atomic_inc(&out_vcc->stats->rx);
34876 + atomic_inc_unchecked(&vcc->stats->tx);
34877 + atomic_inc_unchecked(&out_vcc->stats->rx);
34878 return 0;
34879 }
34880
34881 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34882 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34883 read_unlock(&vcc_sklist_lock);
34884 if (!out_vcc) {
34885 - atomic_inc(&vcc->stats->tx_err);
34886 + atomic_inc_unchecked(&vcc->stats->tx_err);
34887 goto done;
34888 }
34889 skb_pull(skb,sizeof(struct atmtcp_hdr));
34890 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34891 __net_timestamp(new_skb);
34892 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34893 out_vcc->push(out_vcc,new_skb);
34894 - atomic_inc(&vcc->stats->tx);
34895 - atomic_inc(&out_vcc->stats->rx);
34896 + atomic_inc_unchecked(&vcc->stats->tx);
34897 + atomic_inc_unchecked(&out_vcc->stats->rx);
34898 done:
34899 if (vcc->pop) vcc->pop(vcc,skb);
34900 else dev_kfree_skb(skb);
34901 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34902 index b1955ba..b179940 100644
34903 --- a/drivers/atm/eni.c
34904 +++ b/drivers/atm/eni.c
34905 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34906 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34907 vcc->dev->number);
34908 length = 0;
34909 - atomic_inc(&vcc->stats->rx_err);
34910 + atomic_inc_unchecked(&vcc->stats->rx_err);
34911 }
34912 else {
34913 length = ATM_CELL_SIZE-1; /* no HEC */
34914 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34915 size);
34916 }
34917 eff = length = 0;
34918 - atomic_inc(&vcc->stats->rx_err);
34919 + atomic_inc_unchecked(&vcc->stats->rx_err);
34920 }
34921 else {
34922 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34923 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34924 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34925 vcc->dev->number,vcc->vci,length,size << 2,descr);
34926 length = eff = 0;
34927 - atomic_inc(&vcc->stats->rx_err);
34928 + atomic_inc_unchecked(&vcc->stats->rx_err);
34929 }
34930 }
34931 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34932 @@ -767,7 +767,7 @@ rx_dequeued++;
34933 vcc->push(vcc,skb);
34934 pushed++;
34935 }
34936 - atomic_inc(&vcc->stats->rx);
34937 + atomic_inc_unchecked(&vcc->stats->rx);
34938 }
34939 wake_up(&eni_dev->rx_wait);
34940 }
34941 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34942 PCI_DMA_TODEVICE);
34943 if (vcc->pop) vcc->pop(vcc,skb);
34944 else dev_kfree_skb_irq(skb);
34945 - atomic_inc(&vcc->stats->tx);
34946 + atomic_inc_unchecked(&vcc->stats->tx);
34947 wake_up(&eni_dev->tx_wait);
34948 dma_complete++;
34949 }
34950 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34951 index b41c948..a002b17 100644
34952 --- a/drivers/atm/firestream.c
34953 +++ b/drivers/atm/firestream.c
34954 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34955 }
34956 }
34957
34958 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34959 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34960
34961 fs_dprintk (FS_DEBUG_TXMEM, "i");
34962 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34963 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34964 #endif
34965 skb_put (skb, qe->p1 & 0xffff);
34966 ATM_SKB(skb)->vcc = atm_vcc;
34967 - atomic_inc(&atm_vcc->stats->rx);
34968 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34969 __net_timestamp(skb);
34970 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34971 atm_vcc->push (atm_vcc, skb);
34972 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34973 kfree (pe);
34974 }
34975 if (atm_vcc)
34976 - atomic_inc(&atm_vcc->stats->rx_drop);
34977 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34978 break;
34979 case 0x1f: /* Reassembly abort: no buffers. */
34980 /* Silently increment error counter. */
34981 if (atm_vcc)
34982 - atomic_inc(&atm_vcc->stats->rx_drop);
34983 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34984 break;
34985 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34986 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34987 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34988 index 204814e..cede831 100644
34989 --- a/drivers/atm/fore200e.c
34990 +++ b/drivers/atm/fore200e.c
34991 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
34992 #endif
34993 /* check error condition */
34994 if (*entry->status & STATUS_ERROR)
34995 - atomic_inc(&vcc->stats->tx_err);
34996 + atomic_inc_unchecked(&vcc->stats->tx_err);
34997 else
34998 - atomic_inc(&vcc->stats->tx);
34999 + atomic_inc_unchecked(&vcc->stats->tx);
35000 }
35001 }
35002
35003 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35004 if (skb == NULL) {
35005 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35006
35007 - atomic_inc(&vcc->stats->rx_drop);
35008 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35009 return -ENOMEM;
35010 }
35011
35012 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35013
35014 dev_kfree_skb_any(skb);
35015
35016 - atomic_inc(&vcc->stats->rx_drop);
35017 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35018 return -ENOMEM;
35019 }
35020
35021 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35022
35023 vcc->push(vcc, skb);
35024 - atomic_inc(&vcc->stats->rx);
35025 + atomic_inc_unchecked(&vcc->stats->rx);
35026
35027 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35028
35029 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35030 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35031 fore200e->atm_dev->number,
35032 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35033 - atomic_inc(&vcc->stats->rx_err);
35034 + atomic_inc_unchecked(&vcc->stats->rx_err);
35035 }
35036 }
35037
35038 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35039 goto retry_here;
35040 }
35041
35042 - atomic_inc(&vcc->stats->tx_err);
35043 + atomic_inc_unchecked(&vcc->stats->tx_err);
35044
35045 fore200e->tx_sat++;
35046 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35047 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35048 index 507362a..a845e57 100644
35049 --- a/drivers/atm/he.c
35050 +++ b/drivers/atm/he.c
35051 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35052
35053 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35054 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35055 - atomic_inc(&vcc->stats->rx_drop);
35056 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35057 goto return_host_buffers;
35058 }
35059
35060 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35061 RBRQ_LEN_ERR(he_dev->rbrq_head)
35062 ? "LEN_ERR" : "",
35063 vcc->vpi, vcc->vci);
35064 - atomic_inc(&vcc->stats->rx_err);
35065 + atomic_inc_unchecked(&vcc->stats->rx_err);
35066 goto return_host_buffers;
35067 }
35068
35069 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35070 vcc->push(vcc, skb);
35071 spin_lock(&he_dev->global_lock);
35072
35073 - atomic_inc(&vcc->stats->rx);
35074 + atomic_inc_unchecked(&vcc->stats->rx);
35075
35076 return_host_buffers:
35077 ++pdus_assembled;
35078 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35079 tpd->vcc->pop(tpd->vcc, tpd->skb);
35080 else
35081 dev_kfree_skb_any(tpd->skb);
35082 - atomic_inc(&tpd->vcc->stats->tx_err);
35083 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35084 }
35085 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35086 return;
35087 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35088 vcc->pop(vcc, skb);
35089 else
35090 dev_kfree_skb_any(skb);
35091 - atomic_inc(&vcc->stats->tx_err);
35092 + atomic_inc_unchecked(&vcc->stats->tx_err);
35093 return -EINVAL;
35094 }
35095
35096 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35097 vcc->pop(vcc, skb);
35098 else
35099 dev_kfree_skb_any(skb);
35100 - atomic_inc(&vcc->stats->tx_err);
35101 + atomic_inc_unchecked(&vcc->stats->tx_err);
35102 return -EINVAL;
35103 }
35104 #endif
35105 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35106 vcc->pop(vcc, skb);
35107 else
35108 dev_kfree_skb_any(skb);
35109 - atomic_inc(&vcc->stats->tx_err);
35110 + atomic_inc_unchecked(&vcc->stats->tx_err);
35111 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35112 return -ENOMEM;
35113 }
35114 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35115 vcc->pop(vcc, skb);
35116 else
35117 dev_kfree_skb_any(skb);
35118 - atomic_inc(&vcc->stats->tx_err);
35119 + atomic_inc_unchecked(&vcc->stats->tx_err);
35120 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35121 return -ENOMEM;
35122 }
35123 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35124 __enqueue_tpd(he_dev, tpd, cid);
35125 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35126
35127 - atomic_inc(&vcc->stats->tx);
35128 + atomic_inc_unchecked(&vcc->stats->tx);
35129
35130 return 0;
35131 }
35132 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35133 index 1dc0519..1aadaf7 100644
35134 --- a/drivers/atm/horizon.c
35135 +++ b/drivers/atm/horizon.c
35136 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35137 {
35138 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35139 // VC layer stats
35140 - atomic_inc(&vcc->stats->rx);
35141 + atomic_inc_unchecked(&vcc->stats->rx);
35142 __net_timestamp(skb);
35143 // end of our responsibility
35144 vcc->push (vcc, skb);
35145 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35146 dev->tx_iovec = NULL;
35147
35148 // VC layer stats
35149 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35150 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35151
35152 // free the skb
35153 hrz_kfree_skb (skb);
35154 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35155 index 272f009..a18ba55 100644
35156 --- a/drivers/atm/idt77252.c
35157 +++ b/drivers/atm/idt77252.c
35158 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35159 else
35160 dev_kfree_skb(skb);
35161
35162 - atomic_inc(&vcc->stats->tx);
35163 + atomic_inc_unchecked(&vcc->stats->tx);
35164 }
35165
35166 atomic_dec(&scq->used);
35167 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35168 if ((sb = dev_alloc_skb(64)) == NULL) {
35169 printk("%s: Can't allocate buffers for aal0.\n",
35170 card->name);
35171 - atomic_add(i, &vcc->stats->rx_drop);
35172 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35173 break;
35174 }
35175 if (!atm_charge(vcc, sb->truesize)) {
35176 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35177 card->name);
35178 - atomic_add(i - 1, &vcc->stats->rx_drop);
35179 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35180 dev_kfree_skb(sb);
35181 break;
35182 }
35183 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35184 ATM_SKB(sb)->vcc = vcc;
35185 __net_timestamp(sb);
35186 vcc->push(vcc, sb);
35187 - atomic_inc(&vcc->stats->rx);
35188 + atomic_inc_unchecked(&vcc->stats->rx);
35189
35190 cell += ATM_CELL_PAYLOAD;
35191 }
35192 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35193 "(CDC: %08x)\n",
35194 card->name, len, rpp->len, readl(SAR_REG_CDC));
35195 recycle_rx_pool_skb(card, rpp);
35196 - atomic_inc(&vcc->stats->rx_err);
35197 + atomic_inc_unchecked(&vcc->stats->rx_err);
35198 return;
35199 }
35200 if (stat & SAR_RSQE_CRC) {
35201 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35202 recycle_rx_pool_skb(card, rpp);
35203 - atomic_inc(&vcc->stats->rx_err);
35204 + atomic_inc_unchecked(&vcc->stats->rx_err);
35205 return;
35206 }
35207 if (skb_queue_len(&rpp->queue) > 1) {
35208 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35209 RXPRINTK("%s: Can't alloc RX skb.\n",
35210 card->name);
35211 recycle_rx_pool_skb(card, rpp);
35212 - atomic_inc(&vcc->stats->rx_err);
35213 + atomic_inc_unchecked(&vcc->stats->rx_err);
35214 return;
35215 }
35216 if (!atm_charge(vcc, skb->truesize)) {
35217 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35218 __net_timestamp(skb);
35219
35220 vcc->push(vcc, skb);
35221 - atomic_inc(&vcc->stats->rx);
35222 + atomic_inc_unchecked(&vcc->stats->rx);
35223
35224 return;
35225 }
35226 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35227 __net_timestamp(skb);
35228
35229 vcc->push(vcc, skb);
35230 - atomic_inc(&vcc->stats->rx);
35231 + atomic_inc_unchecked(&vcc->stats->rx);
35232
35233 if (skb->truesize > SAR_FB_SIZE_3)
35234 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35235 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35236 if (vcc->qos.aal != ATM_AAL0) {
35237 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35238 card->name, vpi, vci);
35239 - atomic_inc(&vcc->stats->rx_drop);
35240 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35241 goto drop;
35242 }
35243
35244 if ((sb = dev_alloc_skb(64)) == NULL) {
35245 printk("%s: Can't allocate buffers for AAL0.\n",
35246 card->name);
35247 - atomic_inc(&vcc->stats->rx_err);
35248 + atomic_inc_unchecked(&vcc->stats->rx_err);
35249 goto drop;
35250 }
35251
35252 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35253 ATM_SKB(sb)->vcc = vcc;
35254 __net_timestamp(sb);
35255 vcc->push(vcc, sb);
35256 - atomic_inc(&vcc->stats->rx);
35257 + atomic_inc_unchecked(&vcc->stats->rx);
35258
35259 drop:
35260 skb_pull(queue, 64);
35261 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35262
35263 if (vc == NULL) {
35264 printk("%s: NULL connection in send().\n", card->name);
35265 - atomic_inc(&vcc->stats->tx_err);
35266 + atomic_inc_unchecked(&vcc->stats->tx_err);
35267 dev_kfree_skb(skb);
35268 return -EINVAL;
35269 }
35270 if (!test_bit(VCF_TX, &vc->flags)) {
35271 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35272 - atomic_inc(&vcc->stats->tx_err);
35273 + atomic_inc_unchecked(&vcc->stats->tx_err);
35274 dev_kfree_skb(skb);
35275 return -EINVAL;
35276 }
35277 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35278 break;
35279 default:
35280 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35281 - atomic_inc(&vcc->stats->tx_err);
35282 + atomic_inc_unchecked(&vcc->stats->tx_err);
35283 dev_kfree_skb(skb);
35284 return -EINVAL;
35285 }
35286
35287 if (skb_shinfo(skb)->nr_frags != 0) {
35288 printk("%s: No scatter-gather yet.\n", card->name);
35289 - atomic_inc(&vcc->stats->tx_err);
35290 + atomic_inc_unchecked(&vcc->stats->tx_err);
35291 dev_kfree_skb(skb);
35292 return -EINVAL;
35293 }
35294 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35295
35296 err = queue_skb(card, vc, skb, oam);
35297 if (err) {
35298 - atomic_inc(&vcc->stats->tx_err);
35299 + atomic_inc_unchecked(&vcc->stats->tx_err);
35300 dev_kfree_skb(skb);
35301 return err;
35302 }
35303 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35304 skb = dev_alloc_skb(64);
35305 if (!skb) {
35306 printk("%s: Out of memory in send_oam().\n", card->name);
35307 - atomic_inc(&vcc->stats->tx_err);
35308 + atomic_inc_unchecked(&vcc->stats->tx_err);
35309 return -ENOMEM;
35310 }
35311 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35312 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35313 index 4217f29..88f547a 100644
35314 --- a/drivers/atm/iphase.c
35315 +++ b/drivers/atm/iphase.c
35316 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35317 status = (u_short) (buf_desc_ptr->desc_mode);
35318 if (status & (RX_CER | RX_PTE | RX_OFL))
35319 {
35320 - atomic_inc(&vcc->stats->rx_err);
35321 + atomic_inc_unchecked(&vcc->stats->rx_err);
35322 IF_ERR(printk("IA: bad packet, dropping it");)
35323 if (status & RX_CER) {
35324 IF_ERR(printk(" cause: packet CRC error\n");)
35325 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35326 len = dma_addr - buf_addr;
35327 if (len > iadev->rx_buf_sz) {
35328 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35329 - atomic_inc(&vcc->stats->rx_err);
35330 + atomic_inc_unchecked(&vcc->stats->rx_err);
35331 goto out_free_desc;
35332 }
35333
35334 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35335 ia_vcc = INPH_IA_VCC(vcc);
35336 if (ia_vcc == NULL)
35337 {
35338 - atomic_inc(&vcc->stats->rx_err);
35339 + atomic_inc_unchecked(&vcc->stats->rx_err);
35340 atm_return(vcc, skb->truesize);
35341 dev_kfree_skb_any(skb);
35342 goto INCR_DLE;
35343 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35344 if ((length > iadev->rx_buf_sz) || (length >
35345 (skb->len - sizeof(struct cpcs_trailer))))
35346 {
35347 - atomic_inc(&vcc->stats->rx_err);
35348 + atomic_inc_unchecked(&vcc->stats->rx_err);
35349 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35350 length, skb->len);)
35351 atm_return(vcc, skb->truesize);
35352 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35353
35354 IF_RX(printk("rx_dle_intr: skb push");)
35355 vcc->push(vcc,skb);
35356 - atomic_inc(&vcc->stats->rx);
35357 + atomic_inc_unchecked(&vcc->stats->rx);
35358 iadev->rx_pkt_cnt++;
35359 }
35360 INCR_DLE:
35361 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35362 {
35363 struct k_sonet_stats *stats;
35364 stats = &PRIV(_ia_dev[board])->sonet_stats;
35365 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35366 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35367 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35368 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35369 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35370 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35371 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35372 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35373 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35374 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35375 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35376 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35377 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35378 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35379 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35380 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35381 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35382 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35383 }
35384 ia_cmds.status = 0;
35385 break;
35386 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35387 if ((desc == 0) || (desc > iadev->num_tx_desc))
35388 {
35389 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35390 - atomic_inc(&vcc->stats->tx);
35391 + atomic_inc_unchecked(&vcc->stats->tx);
35392 if (vcc->pop)
35393 vcc->pop(vcc, skb);
35394 else
35395 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35396 ATM_DESC(skb) = vcc->vci;
35397 skb_queue_tail(&iadev->tx_dma_q, skb);
35398
35399 - atomic_inc(&vcc->stats->tx);
35400 + atomic_inc_unchecked(&vcc->stats->tx);
35401 iadev->tx_pkt_cnt++;
35402 /* Increment transaction counter */
35403 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35404
35405 #if 0
35406 /* add flow control logic */
35407 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35408 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35409 if (iavcc->vc_desc_cnt > 10) {
35410 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35411 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35412 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35413 index fa7d701..1e404c7 100644
35414 --- a/drivers/atm/lanai.c
35415 +++ b/drivers/atm/lanai.c
35416 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35417 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35418 lanai_endtx(lanai, lvcc);
35419 lanai_free_skb(lvcc->tx.atmvcc, skb);
35420 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35421 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35422 }
35423
35424 /* Try to fill the buffer - don't call unless there is backlog */
35425 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35426 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35427 __net_timestamp(skb);
35428 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35429 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35430 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35431 out:
35432 lvcc->rx.buf.ptr = end;
35433 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35434 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35435 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35436 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35437 lanai->stats.service_rxnotaal5++;
35438 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35439 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35440 return 0;
35441 }
35442 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35443 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35444 int bytes;
35445 read_unlock(&vcc_sklist_lock);
35446 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35447 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35448 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35449 lvcc->stats.x.aal5.service_trash++;
35450 bytes = (SERVICE_GET_END(s) * 16) -
35451 (((unsigned long) lvcc->rx.buf.ptr) -
35452 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35453 }
35454 if (s & SERVICE_STREAM) {
35455 read_unlock(&vcc_sklist_lock);
35456 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35457 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35458 lvcc->stats.x.aal5.service_stream++;
35459 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35460 "PDU on VCI %d!\n", lanai->number, vci);
35461 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35462 return 0;
35463 }
35464 DPRINTK("got rx crc error on vci %d\n", vci);
35465 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35466 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35467 lvcc->stats.x.aal5.service_rxcrc++;
35468 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35469 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35470 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35471 index 6587dc2..149833d 100644
35472 --- a/drivers/atm/nicstar.c
35473 +++ b/drivers/atm/nicstar.c
35474 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35475 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35476 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35477 card->index);
35478 - atomic_inc(&vcc->stats->tx_err);
35479 + atomic_inc_unchecked(&vcc->stats->tx_err);
35480 dev_kfree_skb_any(skb);
35481 return -EINVAL;
35482 }
35483 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35484 if (!vc->tx) {
35485 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35486 card->index);
35487 - atomic_inc(&vcc->stats->tx_err);
35488 + atomic_inc_unchecked(&vcc->stats->tx_err);
35489 dev_kfree_skb_any(skb);
35490 return -EINVAL;
35491 }
35492 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35493 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35494 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35495 card->index);
35496 - atomic_inc(&vcc->stats->tx_err);
35497 + atomic_inc_unchecked(&vcc->stats->tx_err);
35498 dev_kfree_skb_any(skb);
35499 return -EINVAL;
35500 }
35501
35502 if (skb_shinfo(skb)->nr_frags != 0) {
35503 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35504 - atomic_inc(&vcc->stats->tx_err);
35505 + atomic_inc_unchecked(&vcc->stats->tx_err);
35506 dev_kfree_skb_any(skb);
35507 return -EINVAL;
35508 }
35509 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35510 }
35511
35512 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35513 - atomic_inc(&vcc->stats->tx_err);
35514 + atomic_inc_unchecked(&vcc->stats->tx_err);
35515 dev_kfree_skb_any(skb);
35516 return -EIO;
35517 }
35518 - atomic_inc(&vcc->stats->tx);
35519 + atomic_inc_unchecked(&vcc->stats->tx);
35520
35521 return 0;
35522 }
35523 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35524 printk
35525 ("nicstar%d: Can't allocate buffers for aal0.\n",
35526 card->index);
35527 - atomic_add(i, &vcc->stats->rx_drop);
35528 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35529 break;
35530 }
35531 if (!atm_charge(vcc, sb->truesize)) {
35532 RXPRINTK
35533 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35534 card->index);
35535 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35536 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35537 dev_kfree_skb_any(sb);
35538 break;
35539 }
35540 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35541 ATM_SKB(sb)->vcc = vcc;
35542 __net_timestamp(sb);
35543 vcc->push(vcc, sb);
35544 - atomic_inc(&vcc->stats->rx);
35545 + atomic_inc_unchecked(&vcc->stats->rx);
35546 cell += ATM_CELL_PAYLOAD;
35547 }
35548
35549 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35550 if (iovb == NULL) {
35551 printk("nicstar%d: Out of iovec buffers.\n",
35552 card->index);
35553 - atomic_inc(&vcc->stats->rx_drop);
35554 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35555 recycle_rx_buf(card, skb);
35556 return;
35557 }
35558 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35559 small or large buffer itself. */
35560 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35561 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35562 - atomic_inc(&vcc->stats->rx_err);
35563 + atomic_inc_unchecked(&vcc->stats->rx_err);
35564 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35565 NS_MAX_IOVECS);
35566 NS_PRV_IOVCNT(iovb) = 0;
35567 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35568 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35569 card->index);
35570 which_list(card, skb);
35571 - atomic_inc(&vcc->stats->rx_err);
35572 + atomic_inc_unchecked(&vcc->stats->rx_err);
35573 recycle_rx_buf(card, skb);
35574 vc->rx_iov = NULL;
35575 recycle_iov_buf(card, iovb);
35576 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35577 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35578 card->index);
35579 which_list(card, skb);
35580 - atomic_inc(&vcc->stats->rx_err);
35581 + atomic_inc_unchecked(&vcc->stats->rx_err);
35582 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35583 NS_PRV_IOVCNT(iovb));
35584 vc->rx_iov = NULL;
35585 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35586 printk(" - PDU size mismatch.\n");
35587 else
35588 printk(".\n");
35589 - atomic_inc(&vcc->stats->rx_err);
35590 + atomic_inc_unchecked(&vcc->stats->rx_err);
35591 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35592 NS_PRV_IOVCNT(iovb));
35593 vc->rx_iov = NULL;
35594 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35595 /* skb points to a small buffer */
35596 if (!atm_charge(vcc, skb->truesize)) {
35597 push_rxbufs(card, skb);
35598 - atomic_inc(&vcc->stats->rx_drop);
35599 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35600 } else {
35601 skb_put(skb, len);
35602 dequeue_sm_buf(card, skb);
35603 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35604 ATM_SKB(skb)->vcc = vcc;
35605 __net_timestamp(skb);
35606 vcc->push(vcc, skb);
35607 - atomic_inc(&vcc->stats->rx);
35608 + atomic_inc_unchecked(&vcc->stats->rx);
35609 }
35610 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35611 struct sk_buff *sb;
35612 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35613 if (len <= NS_SMBUFSIZE) {
35614 if (!atm_charge(vcc, sb->truesize)) {
35615 push_rxbufs(card, sb);
35616 - atomic_inc(&vcc->stats->rx_drop);
35617 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35618 } else {
35619 skb_put(sb, len);
35620 dequeue_sm_buf(card, sb);
35621 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35622 ATM_SKB(sb)->vcc = vcc;
35623 __net_timestamp(sb);
35624 vcc->push(vcc, sb);
35625 - atomic_inc(&vcc->stats->rx);
35626 + atomic_inc_unchecked(&vcc->stats->rx);
35627 }
35628
35629 push_rxbufs(card, skb);
35630 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35631
35632 if (!atm_charge(vcc, skb->truesize)) {
35633 push_rxbufs(card, skb);
35634 - atomic_inc(&vcc->stats->rx_drop);
35635 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35636 } else {
35637 dequeue_lg_buf(card, skb);
35638 #ifdef NS_USE_DESTRUCTORS
35639 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35640 ATM_SKB(skb)->vcc = vcc;
35641 __net_timestamp(skb);
35642 vcc->push(vcc, skb);
35643 - atomic_inc(&vcc->stats->rx);
35644 + atomic_inc_unchecked(&vcc->stats->rx);
35645 }
35646
35647 push_rxbufs(card, sb);
35648 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35649 printk
35650 ("nicstar%d: Out of huge buffers.\n",
35651 card->index);
35652 - atomic_inc(&vcc->stats->rx_drop);
35653 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35654 recycle_iovec_rx_bufs(card,
35655 (struct iovec *)
35656 iovb->data,
35657 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35658 card->hbpool.count++;
35659 } else
35660 dev_kfree_skb_any(hb);
35661 - atomic_inc(&vcc->stats->rx_drop);
35662 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35663 } else {
35664 /* Copy the small buffer to the huge buffer */
35665 sb = (struct sk_buff *)iov->iov_base;
35666 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35667 #endif /* NS_USE_DESTRUCTORS */
35668 __net_timestamp(hb);
35669 vcc->push(vcc, hb);
35670 - atomic_inc(&vcc->stats->rx);
35671 + atomic_inc_unchecked(&vcc->stats->rx);
35672 }
35673 }
35674
35675 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35676 index 32784d1..4a8434a 100644
35677 --- a/drivers/atm/solos-pci.c
35678 +++ b/drivers/atm/solos-pci.c
35679 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35680 }
35681 atm_charge(vcc, skb->truesize);
35682 vcc->push(vcc, skb);
35683 - atomic_inc(&vcc->stats->rx);
35684 + atomic_inc_unchecked(&vcc->stats->rx);
35685 break;
35686
35687 case PKT_STATUS:
35688 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35689 vcc = SKB_CB(oldskb)->vcc;
35690
35691 if (vcc) {
35692 - atomic_inc(&vcc->stats->tx);
35693 + atomic_inc_unchecked(&vcc->stats->tx);
35694 solos_pop(vcc, oldskb);
35695 } else {
35696 dev_kfree_skb_irq(oldskb);
35697 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35698 index 0215934..ce9f5b1 100644
35699 --- a/drivers/atm/suni.c
35700 +++ b/drivers/atm/suni.c
35701 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35702
35703
35704 #define ADD_LIMITED(s,v) \
35705 - atomic_add((v),&stats->s); \
35706 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35707 + atomic_add_unchecked((v),&stats->s); \
35708 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35709
35710
35711 static void suni_hz(unsigned long from_timer)
35712 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35713 index 5120a96..e2572bd 100644
35714 --- a/drivers/atm/uPD98402.c
35715 +++ b/drivers/atm/uPD98402.c
35716 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35717 struct sonet_stats tmp;
35718 int error = 0;
35719
35720 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35721 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35722 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35723 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35724 if (zero && !error) {
35725 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35726
35727
35728 #define ADD_LIMITED(s,v) \
35729 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35730 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35731 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35732 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35733 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35734 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35735
35736
35737 static void stat_event(struct atm_dev *dev)
35738 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35739 if (reason & uPD98402_INT_PFM) stat_event(dev);
35740 if (reason & uPD98402_INT_PCO) {
35741 (void) GET(PCOCR); /* clear interrupt cause */
35742 - atomic_add(GET(HECCT),
35743 + atomic_add_unchecked(GET(HECCT),
35744 &PRIV(dev)->sonet_stats.uncorr_hcs);
35745 }
35746 if ((reason & uPD98402_INT_RFO) &&
35747 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35748 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35749 uPD98402_INT_LOS),PIMR); /* enable them */
35750 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35751 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35752 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35753 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35754 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35755 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35756 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35757 return 0;
35758 }
35759
35760 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35761 index 969c3c2..9b72956 100644
35762 --- a/drivers/atm/zatm.c
35763 +++ b/drivers/atm/zatm.c
35764 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35765 }
35766 if (!size) {
35767 dev_kfree_skb_irq(skb);
35768 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35769 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35770 continue;
35771 }
35772 if (!atm_charge(vcc,skb->truesize)) {
35773 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35774 skb->len = size;
35775 ATM_SKB(skb)->vcc = vcc;
35776 vcc->push(vcc,skb);
35777 - atomic_inc(&vcc->stats->rx);
35778 + atomic_inc_unchecked(&vcc->stats->rx);
35779 }
35780 zout(pos & 0xffff,MTA(mbx));
35781 #if 0 /* probably a stupid idea */
35782 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35783 skb_queue_head(&zatm_vcc->backlog,skb);
35784 break;
35785 }
35786 - atomic_inc(&vcc->stats->tx);
35787 + atomic_inc_unchecked(&vcc->stats->tx);
35788 wake_up(&zatm_vcc->tx_wait);
35789 }
35790
35791 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35792 index d414331..b4dd4ba 100644
35793 --- a/drivers/base/bus.c
35794 +++ b/drivers/base/bus.c
35795 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35796 return -EINVAL;
35797
35798 mutex_lock(&subsys->p->mutex);
35799 - list_add_tail(&sif->node, &subsys->p->interfaces);
35800 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35801 if (sif->add_dev) {
35802 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35803 while ((dev = subsys_dev_iter_next(&iter)))
35804 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35805 subsys = sif->subsys;
35806
35807 mutex_lock(&subsys->p->mutex);
35808 - list_del_init(&sif->node);
35809 + pax_list_del_init((struct list_head *)&sif->node);
35810 if (sif->remove_dev) {
35811 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35812 while ((dev = subsys_dev_iter_next(&iter)))
35813 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35814 index 7413d06..79155fa 100644
35815 --- a/drivers/base/devtmpfs.c
35816 +++ b/drivers/base/devtmpfs.c
35817 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35818 if (!thread)
35819 return 0;
35820
35821 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35822 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35823 if (err)
35824 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35825 else
35826 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35827 *err = sys_unshare(CLONE_NEWNS);
35828 if (*err)
35829 goto out;
35830 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35831 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35832 if (*err)
35833 goto out;
35834 - sys_chdir("/.."); /* will traverse into overmounted root */
35835 - sys_chroot(".");
35836 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35837 + sys_chroot((char __force_user *)".");
35838 complete(&setup_done);
35839 while (1) {
35840 spin_lock(&req_lock);
35841 diff --git a/drivers/base/node.c b/drivers/base/node.c
35842 index 7616a77c..8f57f51 100644
35843 --- a/drivers/base/node.c
35844 +++ b/drivers/base/node.c
35845 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35846 struct node_attr {
35847 struct device_attribute attr;
35848 enum node_states state;
35849 -};
35850 +} __do_const;
35851
35852 static ssize_t show_node_state(struct device *dev,
35853 struct device_attribute *attr, char *buf)
35854 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35855 index bfb8955..42c9b9a 100644
35856 --- a/drivers/base/power/domain.c
35857 +++ b/drivers/base/power/domain.c
35858 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35859 {
35860 struct cpuidle_driver *cpuidle_drv;
35861 struct gpd_cpu_data *cpu_data;
35862 - struct cpuidle_state *idle_state;
35863 + cpuidle_state_no_const *idle_state;
35864 int ret = 0;
35865
35866 if (IS_ERR_OR_NULL(genpd) || state < 0)
35867 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35868 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35869 {
35870 struct gpd_cpu_data *cpu_data;
35871 - struct cpuidle_state *idle_state;
35872 + cpuidle_state_no_const *idle_state;
35873 int ret = 0;
35874
35875 if (IS_ERR_OR_NULL(genpd))
35876 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35877 index a53ebd2..8f73eeb 100644
35878 --- a/drivers/base/power/sysfs.c
35879 +++ b/drivers/base/power/sysfs.c
35880 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35881 return -EIO;
35882 }
35883 }
35884 - return sprintf(buf, p);
35885 + return sprintf(buf, "%s", p);
35886 }
35887
35888 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35889 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35890 index 2d56f41..8830f19 100644
35891 --- a/drivers/base/power/wakeup.c
35892 +++ b/drivers/base/power/wakeup.c
35893 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35894 * They need to be modified together atomically, so it's better to use one
35895 * atomic variable to hold them both.
35896 */
35897 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35898 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35899
35900 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35901 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35902
35903 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35904 {
35905 - unsigned int comb = atomic_read(&combined_event_count);
35906 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35907
35908 *cnt = (comb >> IN_PROGRESS_BITS);
35909 *inpr = comb & MAX_IN_PROGRESS;
35910 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35911 ws->start_prevent_time = ws->last_time;
35912
35913 /* Increment the counter of events in progress. */
35914 - cec = atomic_inc_return(&combined_event_count);
35915 + cec = atomic_inc_return_unchecked(&combined_event_count);
35916
35917 trace_wakeup_source_activate(ws->name, cec);
35918 }
35919 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35920 * Increment the counter of registered wakeup events and decrement the
35921 * couter of wakeup events in progress simultaneously.
35922 */
35923 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35924 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35925 trace_wakeup_source_deactivate(ws->name, cec);
35926
35927 split_counters(&cnt, &inpr);
35928 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35929 index e8d11b6..7b1b36f 100644
35930 --- a/drivers/base/syscore.c
35931 +++ b/drivers/base/syscore.c
35932 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35933 void register_syscore_ops(struct syscore_ops *ops)
35934 {
35935 mutex_lock(&syscore_ops_lock);
35936 - list_add_tail(&ops->node, &syscore_ops_list);
35937 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35938 mutex_unlock(&syscore_ops_lock);
35939 }
35940 EXPORT_SYMBOL_GPL(register_syscore_ops);
35941 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35942 void unregister_syscore_ops(struct syscore_ops *ops)
35943 {
35944 mutex_lock(&syscore_ops_lock);
35945 - list_del(&ops->node);
35946 + pax_list_del((struct list_head *)&ops->node);
35947 mutex_unlock(&syscore_ops_lock);
35948 }
35949 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35950 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35951 index 62b6c2c..002d10f 100644
35952 --- a/drivers/block/cciss.c
35953 +++ b/drivers/block/cciss.c
35954 @@ -1189,6 +1189,7 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
35955 int err;
35956 u32 cp;
35957
35958 + memset(&arg64, 0, sizeof(arg64));
35959 err = 0;
35960 err |=
35961 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
35962 @@ -3010,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
35963 while (!list_empty(&h->reqQ)) {
35964 c = list_entry(h->reqQ.next, CommandList_struct, list);
35965 /* can't do anything if fifo is full */
35966 - if ((h->access.fifo_full(h))) {
35967 + if ((h->access->fifo_full(h))) {
35968 dev_warn(&h->pdev->dev, "fifo full\n");
35969 break;
35970 }
35971 @@ -3020,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
35972 h->Qdepth--;
35973
35974 /* Tell the controller execute command */
35975 - h->access.submit_command(h, c);
35976 + h->access->submit_command(h, c);
35977
35978 /* Put job onto the completed Q */
35979 addQ(&h->cmpQ, c);
35980 @@ -3446,17 +3447,17 @@ startio:
35981
35982 static inline unsigned long get_next_completion(ctlr_info_t *h)
35983 {
35984 - return h->access.command_completed(h);
35985 + return h->access->command_completed(h);
35986 }
35987
35988 static inline int interrupt_pending(ctlr_info_t *h)
35989 {
35990 - return h->access.intr_pending(h);
35991 + return h->access->intr_pending(h);
35992 }
35993
35994 static inline long interrupt_not_for_us(ctlr_info_t *h)
35995 {
35996 - return ((h->access.intr_pending(h) == 0) ||
35997 + return ((h->access->intr_pending(h) == 0) ||
35998 (h->interrupts_enabled == 0));
35999 }
36000
36001 @@ -3489,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
36002 u32 a;
36003
36004 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36005 - return h->access.command_completed(h);
36006 + return h->access->command_completed(h);
36007
36008 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36009 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36010 @@ -4046,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36011 trans_support & CFGTBL_Trans_use_short_tags);
36012
36013 /* Change the access methods to the performant access methods */
36014 - h->access = SA5_performant_access;
36015 + h->access = &SA5_performant_access;
36016 h->transMethod = CFGTBL_Trans_Performant;
36017
36018 return;
36019 @@ -4319,7 +4320,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36020 if (prod_index < 0)
36021 return -ENODEV;
36022 h->product_name = products[prod_index].product_name;
36023 - h->access = *(products[prod_index].access);
36024 + h->access = products[prod_index].access;
36025
36026 if (cciss_board_disabled(h)) {
36027 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36028 @@ -5051,7 +5052,7 @@ reinit_after_soft_reset:
36029 }
36030
36031 /* make sure the board interrupts are off */
36032 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36033 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36034 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36035 if (rc)
36036 goto clean2;
36037 @@ -5101,7 +5102,7 @@ reinit_after_soft_reset:
36038 * fake ones to scoop up any residual completions.
36039 */
36040 spin_lock_irqsave(&h->lock, flags);
36041 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36042 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36043 spin_unlock_irqrestore(&h->lock, flags);
36044 free_irq(h->intr[h->intr_mode], h);
36045 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36046 @@ -5121,9 +5122,9 @@ reinit_after_soft_reset:
36047 dev_info(&h->pdev->dev, "Board READY.\n");
36048 dev_info(&h->pdev->dev,
36049 "Waiting for stale completions to drain.\n");
36050 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36051 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36052 msleep(10000);
36053 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36054 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36055
36056 rc = controller_reset_failed(h->cfgtable);
36057 if (rc)
36058 @@ -5146,7 +5147,7 @@ reinit_after_soft_reset:
36059 cciss_scsi_setup(h);
36060
36061 /* Turn the interrupts on so we can service requests */
36062 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36063 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36064
36065 /* Get the firmware version */
36066 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36067 @@ -5218,7 +5219,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36068 kfree(flush_buf);
36069 if (return_code != IO_OK)
36070 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36071 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36072 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36073 free_irq(h->intr[h->intr_mode], h);
36074 }
36075
36076 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36077 index 7fda30e..eb5dfe0 100644
36078 --- a/drivers/block/cciss.h
36079 +++ b/drivers/block/cciss.h
36080 @@ -101,7 +101,7 @@ struct ctlr_info
36081 /* information about each logical volume */
36082 drive_info_struct *drv[CISS_MAX_LUN];
36083
36084 - struct access_method access;
36085 + struct access_method *access;
36086
36087 /* queue and queue Info */
36088 struct list_head reqQ;
36089 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36090 index 639d26b..fd6ad1f 100644
36091 --- a/drivers/block/cpqarray.c
36092 +++ b/drivers/block/cpqarray.c
36093 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36094 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36095 goto Enomem4;
36096 }
36097 - hba[i]->access.set_intr_mask(hba[i], 0);
36098 + hba[i]->access->set_intr_mask(hba[i], 0);
36099 if (request_irq(hba[i]->intr, do_ida_intr,
36100 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36101 {
36102 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36103 add_timer(&hba[i]->timer);
36104
36105 /* Enable IRQ now that spinlock and rate limit timer are set up */
36106 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36107 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36108
36109 for(j=0; j<NWD; j++) {
36110 struct gendisk *disk = ida_gendisk[i][j];
36111 @@ -694,7 +694,7 @@ DBGINFO(
36112 for(i=0; i<NR_PRODUCTS; i++) {
36113 if (board_id == products[i].board_id) {
36114 c->product_name = products[i].product_name;
36115 - c->access = *(products[i].access);
36116 + c->access = products[i].access;
36117 break;
36118 }
36119 }
36120 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36121 hba[ctlr]->intr = intr;
36122 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36123 hba[ctlr]->product_name = products[j].product_name;
36124 - hba[ctlr]->access = *(products[j].access);
36125 + hba[ctlr]->access = products[j].access;
36126 hba[ctlr]->ctlr = ctlr;
36127 hba[ctlr]->board_id = board_id;
36128 hba[ctlr]->pci_dev = NULL; /* not PCI */
36129 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36130
36131 while((c = h->reqQ) != NULL) {
36132 /* Can't do anything if we're busy */
36133 - if (h->access.fifo_full(h) == 0)
36134 + if (h->access->fifo_full(h) == 0)
36135 return;
36136
36137 /* Get the first entry from the request Q */
36138 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36139 h->Qdepth--;
36140
36141 /* Tell the controller to do our bidding */
36142 - h->access.submit_command(h, c);
36143 + h->access->submit_command(h, c);
36144
36145 /* Get onto the completion Q */
36146 addQ(&h->cmpQ, c);
36147 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36148 unsigned long flags;
36149 __u32 a,a1;
36150
36151 - istat = h->access.intr_pending(h);
36152 + istat = h->access->intr_pending(h);
36153 /* Is this interrupt for us? */
36154 if (istat == 0)
36155 return IRQ_NONE;
36156 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36157 */
36158 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36159 if (istat & FIFO_NOT_EMPTY) {
36160 - while((a = h->access.command_completed(h))) {
36161 + while((a = h->access->command_completed(h))) {
36162 a1 = a; a &= ~3;
36163 if ((c = h->cmpQ) == NULL)
36164 {
36165 @@ -1193,6 +1193,7 @@ out_passthru:
36166 ida_pci_info_struct pciinfo;
36167
36168 if (!arg) return -EINVAL;
36169 + memset(&pciinfo, 0, sizeof(pciinfo));
36170 pciinfo.bus = host->pci_dev->bus->number;
36171 pciinfo.dev_fn = host->pci_dev->devfn;
36172 pciinfo.board_id = host->board_id;
36173 @@ -1447,11 +1448,11 @@ static int sendcmd(
36174 /*
36175 * Disable interrupt
36176 */
36177 - info_p->access.set_intr_mask(info_p, 0);
36178 + info_p->access->set_intr_mask(info_p, 0);
36179 /* Make sure there is room in the command FIFO */
36180 /* Actually it should be completely empty at this time. */
36181 for (i = 200000; i > 0; i--) {
36182 - temp = info_p->access.fifo_full(info_p);
36183 + temp = info_p->access->fifo_full(info_p);
36184 if (temp != 0) {
36185 break;
36186 }
36187 @@ -1464,7 +1465,7 @@ DBG(
36188 /*
36189 * Send the cmd
36190 */
36191 - info_p->access.submit_command(info_p, c);
36192 + info_p->access->submit_command(info_p, c);
36193 complete = pollcomplete(ctlr);
36194
36195 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36196 @@ -1547,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36197 * we check the new geometry. Then turn interrupts back on when
36198 * we're done.
36199 */
36200 - host->access.set_intr_mask(host, 0);
36201 + host->access->set_intr_mask(host, 0);
36202 getgeometry(ctlr);
36203 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36204 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36205
36206 for(i=0; i<NWD; i++) {
36207 struct gendisk *disk = ida_gendisk[ctlr][i];
36208 @@ -1589,7 +1590,7 @@ static int pollcomplete(int ctlr)
36209 /* Wait (up to 2 seconds) for a command to complete */
36210
36211 for (i = 200000; i > 0; i--) {
36212 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36213 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36214 if (done == 0) {
36215 udelay(10); /* a short fixed delay */
36216 } else
36217 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36218 index be73e9d..7fbf140 100644
36219 --- a/drivers/block/cpqarray.h
36220 +++ b/drivers/block/cpqarray.h
36221 @@ -99,7 +99,7 @@ struct ctlr_info {
36222 drv_info_t drv[NWD];
36223 struct proc_dir_entry *proc;
36224
36225 - struct access_method access;
36226 + struct access_method *access;
36227
36228 cmdlist_t *reqQ;
36229 cmdlist_t *cmpQ;
36230 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36231 index 2d7f608..11245fe 100644
36232 --- a/drivers/block/drbd/drbd_int.h
36233 +++ b/drivers/block/drbd/drbd_int.h
36234 @@ -582,7 +582,7 @@ struct drbd_epoch {
36235 struct drbd_tconn *tconn;
36236 struct list_head list;
36237 unsigned int barrier_nr;
36238 - atomic_t epoch_size; /* increased on every request added. */
36239 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36240 atomic_t active; /* increased on every req. added, and dec on every finished. */
36241 unsigned long flags;
36242 };
36243 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36244 unsigned int al_tr_number;
36245 int al_tr_cycle;
36246 wait_queue_head_t seq_wait;
36247 - atomic_t packet_seq;
36248 + atomic_unchecked_t packet_seq;
36249 unsigned int peer_seq;
36250 spinlock_t peer_seq_lock;
36251 unsigned int minor;
36252 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36253 char __user *uoptval;
36254 int err;
36255
36256 - uoptval = (char __user __force *)optval;
36257 + uoptval = (char __force_user *)optval;
36258
36259 set_fs(KERNEL_DS);
36260 if (level == SOL_SOCKET)
36261 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36262 index 55635ed..40e837c 100644
36263 --- a/drivers/block/drbd/drbd_main.c
36264 +++ b/drivers/block/drbd/drbd_main.c
36265 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36266 p->sector = sector;
36267 p->block_id = block_id;
36268 p->blksize = blksize;
36269 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36270 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36271 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36272 }
36273
36274 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36275 return -EIO;
36276 p->sector = cpu_to_be64(req->i.sector);
36277 p->block_id = (unsigned long)req;
36278 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36279 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36280 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36281 if (mdev->state.conn >= C_SYNC_SOURCE &&
36282 mdev->state.conn <= C_PAUSED_SYNC_T)
36283 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36284 {
36285 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36286
36287 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36288 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36289 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36290 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36291 kfree(tconn->current_epoch);
36292
36293 idr_destroy(&tconn->volumes);
36294 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36295 index 8cc1e64..ba7ffa9 100644
36296 --- a/drivers/block/drbd/drbd_nl.c
36297 +++ b/drivers/block/drbd/drbd_nl.c
36298 @@ -3440,7 +3440,7 @@ out:
36299
36300 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36301 {
36302 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36303 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36304 struct sk_buff *msg;
36305 struct drbd_genlmsghdr *d_out;
36306 unsigned seq;
36307 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36308 return;
36309 }
36310
36311 - seq = atomic_inc_return(&drbd_genl_seq);
36312 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36313 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36314 if (!msg)
36315 goto failed;
36316 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36317 index cc29cd3..d4b058b 100644
36318 --- a/drivers/block/drbd/drbd_receiver.c
36319 +++ b/drivers/block/drbd/drbd_receiver.c
36320 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36321 {
36322 int err;
36323
36324 - atomic_set(&mdev->packet_seq, 0);
36325 + atomic_set_unchecked(&mdev->packet_seq, 0);
36326 mdev->peer_seq = 0;
36327
36328 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36329 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36330 do {
36331 next_epoch = NULL;
36332
36333 - epoch_size = atomic_read(&epoch->epoch_size);
36334 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36335
36336 switch (ev & ~EV_CLEANUP) {
36337 case EV_PUT:
36338 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36339 rv = FE_DESTROYED;
36340 } else {
36341 epoch->flags = 0;
36342 - atomic_set(&epoch->epoch_size, 0);
36343 + atomic_set_unchecked(&epoch->epoch_size, 0);
36344 /* atomic_set(&epoch->active, 0); is already zero */
36345 if (rv == FE_STILL_LIVE)
36346 rv = FE_RECYCLED;
36347 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36348 conn_wait_active_ee_empty(tconn);
36349 drbd_flush(tconn);
36350
36351 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36352 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36353 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36354 if (epoch)
36355 break;
36356 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36357 }
36358
36359 epoch->flags = 0;
36360 - atomic_set(&epoch->epoch_size, 0);
36361 + atomic_set_unchecked(&epoch->epoch_size, 0);
36362 atomic_set(&epoch->active, 0);
36363
36364 spin_lock(&tconn->epoch_lock);
36365 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36366 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36367 list_add(&epoch->list, &tconn->current_epoch->list);
36368 tconn->current_epoch = epoch;
36369 tconn->epochs++;
36370 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36371
36372 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36373 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36374 - atomic_inc(&tconn->current_epoch->epoch_size);
36375 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36376 err2 = drbd_drain_block(mdev, pi->size);
36377 if (!err)
36378 err = err2;
36379 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36380
36381 spin_lock(&tconn->epoch_lock);
36382 peer_req->epoch = tconn->current_epoch;
36383 - atomic_inc(&peer_req->epoch->epoch_size);
36384 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36385 atomic_inc(&peer_req->epoch->active);
36386 spin_unlock(&tconn->epoch_lock);
36387
36388 @@ -4347,7 +4347,7 @@ struct data_cmd {
36389 int expect_payload;
36390 size_t pkt_size;
36391 int (*fn)(struct drbd_tconn *, struct packet_info *);
36392 -};
36393 +} __do_const;
36394
36395 static struct data_cmd drbd_cmd_handler[] = {
36396 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36397 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36398 if (!list_empty(&tconn->current_epoch->list))
36399 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36400 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36401 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36402 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36403 tconn->send.seen_any_write_yet = false;
36404
36405 conn_info(tconn, "Connection closed\n");
36406 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36407 struct asender_cmd {
36408 size_t pkt_size;
36409 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36410 -};
36411 +} __do_const;
36412
36413 static struct asender_cmd asender_tbl[] = {
36414 [P_PING] = { 0, got_Ping },
36415 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36416 index 40e7155..df5c79a 100644
36417 --- a/drivers/block/loop.c
36418 +++ b/drivers/block/loop.c
36419 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36420
36421 file_start_write(file);
36422 set_fs(get_ds());
36423 - bw = file->f_op->write(file, buf, len, &pos);
36424 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36425 set_fs(old_fs);
36426 file_end_write(file);
36427 if (likely(bw == len))
36428 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36429 index f5d0ea1..c62380a 100644
36430 --- a/drivers/block/pktcdvd.c
36431 +++ b/drivers/block/pktcdvd.c
36432 @@ -84,7 +84,7 @@
36433 #define MAX_SPEED 0xffff
36434
36435 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
36436 - ~(sector_t)((pd)->settings.size - 1))
36437 + ~(sector_t)((pd)->settings.size - 1UL))
36438
36439 static DEFINE_MUTEX(pktcdvd_mutex);
36440 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
36441 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36442 index 7332889..9ece19e 100644
36443 --- a/drivers/bus/arm-cci.c
36444 +++ b/drivers/bus/arm-cci.c
36445 @@ -419,7 +419,7 @@ static int __init cci_probe(void)
36446
36447 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36448
36449 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36450 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36451 if (!ports)
36452 return -ENOMEM;
36453
36454 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36455 index 8a3aff7..d7538c2 100644
36456 --- a/drivers/cdrom/cdrom.c
36457 +++ b/drivers/cdrom/cdrom.c
36458 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36459 ENSURE(reset, CDC_RESET);
36460 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36461 cdi->mc_flags = 0;
36462 - cdo->n_minors = 0;
36463 cdi->options = CDO_USE_FFLAGS;
36464
36465 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36466 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36467 else
36468 cdi->cdda_method = CDDA_OLD;
36469
36470 - if (!cdo->generic_packet)
36471 - cdo->generic_packet = cdrom_dummy_generic_packet;
36472 + if (!cdo->generic_packet) {
36473 + pax_open_kernel();
36474 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36475 + pax_close_kernel();
36476 + }
36477
36478 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36479 mutex_lock(&cdrom_mutex);
36480 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36481 if (cdi->exit)
36482 cdi->exit(cdi);
36483
36484 - cdi->ops->n_minors--;
36485 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36486 }
36487
36488 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36489 */
36490 nr = nframes;
36491 do {
36492 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36493 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36494 if (cgc.buffer)
36495 break;
36496
36497 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36498 struct cdrom_device_info *cdi;
36499 int ret;
36500
36501 - ret = scnprintf(info + *pos, max_size - *pos, header);
36502 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36503 if (!ret)
36504 return 1;
36505
36506 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36507 index 5980cb9..6d7bd7e 100644
36508 --- a/drivers/cdrom/gdrom.c
36509 +++ b/drivers/cdrom/gdrom.c
36510 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36511 .audio_ioctl = gdrom_audio_ioctl,
36512 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36513 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36514 - .n_minors = 1,
36515 };
36516
36517 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36518 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36519 index 1421997..33f5d6d 100644
36520 --- a/drivers/char/Kconfig
36521 +++ b/drivers/char/Kconfig
36522 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36523
36524 config DEVKMEM
36525 bool "/dev/kmem virtual device support"
36526 - default y
36527 + default n
36528 + depends on !GRKERNSEC_KMEM
36529 help
36530 Say Y here if you want to support the /dev/kmem device. The
36531 /dev/kmem device is rarely used, but can be used for certain
36532 @@ -570,6 +571,7 @@ config DEVPORT
36533 bool
36534 depends on !M68K
36535 depends on ISA || PCI
36536 + depends on !GRKERNSEC_KMEM
36537 default y
36538
36539 source "drivers/s390/char/Kconfig"
36540 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36541 index a48e05b..6bac831 100644
36542 --- a/drivers/char/agp/compat_ioctl.c
36543 +++ b/drivers/char/agp/compat_ioctl.c
36544 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36545 return -ENOMEM;
36546 }
36547
36548 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36549 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36550 sizeof(*usegment) * ureserve.seg_count)) {
36551 kfree(usegment);
36552 kfree(ksegment);
36553 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36554 index 1b19239..b87b143 100644
36555 --- a/drivers/char/agp/frontend.c
36556 +++ b/drivers/char/agp/frontend.c
36557 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36558 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36559 return -EFAULT;
36560
36561 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36562 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36563 return -EFAULT;
36564
36565 client = agp_find_client_by_pid(reserve.pid);
36566 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36567 if (segment == NULL)
36568 return -ENOMEM;
36569
36570 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36571 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36572 sizeof(struct agp_segment) * reserve.seg_count)) {
36573 kfree(segment);
36574 return -EFAULT;
36575 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36576 index 4f94375..413694e 100644
36577 --- a/drivers/char/genrtc.c
36578 +++ b/drivers/char/genrtc.c
36579 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36580 switch (cmd) {
36581
36582 case RTC_PLL_GET:
36583 + memset(&pll, 0, sizeof(pll));
36584 if (get_rtc_pll(&pll))
36585 return -EINVAL;
36586 else
36587 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36588 index 448ce5e..3a76625 100644
36589 --- a/drivers/char/hpet.c
36590 +++ b/drivers/char/hpet.c
36591 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36592 }
36593
36594 static int
36595 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36596 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36597 struct hpet_info *info)
36598 {
36599 struct hpet_timer __iomem *timer;
36600 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36601 index 86fe45c..c0ea948 100644
36602 --- a/drivers/char/hw_random/intel-rng.c
36603 +++ b/drivers/char/hw_random/intel-rng.c
36604 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36605
36606 if (no_fwh_detect)
36607 return -ENODEV;
36608 - printk(warning);
36609 + printk("%s", warning);
36610 return -EBUSY;
36611 }
36612
36613 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36614 index 4445fa1..7c6de37 100644
36615 --- a/drivers/char/ipmi/ipmi_msghandler.c
36616 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36617 @@ -420,7 +420,7 @@ struct ipmi_smi {
36618 struct proc_dir_entry *proc_dir;
36619 char proc_dir_name[10];
36620
36621 - atomic_t stats[IPMI_NUM_STATS];
36622 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36623
36624 /*
36625 * run_to_completion duplicate of smb_info, smi_info
36626 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36627
36628
36629 #define ipmi_inc_stat(intf, stat) \
36630 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36631 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36632 #define ipmi_get_stat(intf, stat) \
36633 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36634 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36635
36636 static int is_lan_addr(struct ipmi_addr *addr)
36637 {
36638 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36639 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36640 init_waitqueue_head(&intf->waitq);
36641 for (i = 0; i < IPMI_NUM_STATS; i++)
36642 - atomic_set(&intf->stats[i], 0);
36643 + atomic_set_unchecked(&intf->stats[i], 0);
36644
36645 intf->proc_dir = NULL;
36646
36647 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36648 index af4b23f..79806fc 100644
36649 --- a/drivers/char/ipmi/ipmi_si_intf.c
36650 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36651 @@ -275,7 +275,7 @@ struct smi_info {
36652 unsigned char slave_addr;
36653
36654 /* Counters and things for the proc filesystem. */
36655 - atomic_t stats[SI_NUM_STATS];
36656 + atomic_unchecked_t stats[SI_NUM_STATS];
36657
36658 struct task_struct *thread;
36659
36660 @@ -284,9 +284,9 @@ struct smi_info {
36661 };
36662
36663 #define smi_inc_stat(smi, stat) \
36664 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36665 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36666 #define smi_get_stat(smi, stat) \
36667 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36668 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36669
36670 #define SI_MAX_PARMS 4
36671
36672 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
36673 atomic_set(&new_smi->req_events, 0);
36674 new_smi->run_to_completion = 0;
36675 for (i = 0; i < SI_NUM_STATS; i++)
36676 - atomic_set(&new_smi->stats[i], 0);
36677 + atomic_set_unchecked(&new_smi->stats[i], 0);
36678
36679 new_smi->interrupt_disabled = 1;
36680 atomic_set(&new_smi->stop_operation, 0);
36681 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36682 index f895a8c..2bc9147 100644
36683 --- a/drivers/char/mem.c
36684 +++ b/drivers/char/mem.c
36685 @@ -18,6 +18,7 @@
36686 #include <linux/raw.h>
36687 #include <linux/tty.h>
36688 #include <linux/capability.h>
36689 +#include <linux/security.h>
36690 #include <linux/ptrace.h>
36691 #include <linux/device.h>
36692 #include <linux/highmem.h>
36693 @@ -37,6 +38,10 @@
36694
36695 #define DEVPORT_MINOR 4
36696
36697 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36698 +extern const struct file_operations grsec_fops;
36699 +#endif
36700 +
36701 static inline unsigned long size_inside_page(unsigned long start,
36702 unsigned long size)
36703 {
36704 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36705
36706 while (cursor < to) {
36707 if (!devmem_is_allowed(pfn)) {
36708 +#ifdef CONFIG_GRKERNSEC_KMEM
36709 + gr_handle_mem_readwrite(from, to);
36710 +#else
36711 printk(KERN_INFO
36712 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36713 current->comm, from, to);
36714 +#endif
36715 return 0;
36716 }
36717 cursor += PAGE_SIZE;
36718 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36719 }
36720 return 1;
36721 }
36722 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36723 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36724 +{
36725 + return 0;
36726 +}
36727 #else
36728 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36729 {
36730 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36731
36732 while (count > 0) {
36733 unsigned long remaining;
36734 + char *temp;
36735
36736 sz = size_inside_page(p, count);
36737
36738 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36739 if (!ptr)
36740 return -EFAULT;
36741
36742 - remaining = copy_to_user(buf, ptr, sz);
36743 +#ifdef CONFIG_PAX_USERCOPY
36744 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36745 + if (!temp) {
36746 + unxlate_dev_mem_ptr(p, ptr);
36747 + return -ENOMEM;
36748 + }
36749 + memcpy(temp, ptr, sz);
36750 +#else
36751 + temp = ptr;
36752 +#endif
36753 +
36754 + remaining = copy_to_user(buf, temp, sz);
36755 +
36756 +#ifdef CONFIG_PAX_USERCOPY
36757 + kfree(temp);
36758 +#endif
36759 +
36760 unxlate_dev_mem_ptr(p, ptr);
36761 if (remaining)
36762 return -EFAULT;
36763 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36764 size_t count, loff_t *ppos)
36765 {
36766 unsigned long p = *ppos;
36767 - ssize_t low_count, read, sz;
36768 + ssize_t low_count, read, sz, err = 0;
36769 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36770 - int err = 0;
36771
36772 read = 0;
36773 if (p < (unsigned long) high_memory) {
36774 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36775 }
36776 #endif
36777 while (low_count > 0) {
36778 + char *temp;
36779 +
36780 sz = size_inside_page(p, low_count);
36781
36782 /*
36783 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36784 */
36785 kbuf = xlate_dev_kmem_ptr((char *)p);
36786
36787 - if (copy_to_user(buf, kbuf, sz))
36788 +#ifdef CONFIG_PAX_USERCOPY
36789 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36790 + if (!temp)
36791 + return -ENOMEM;
36792 + memcpy(temp, kbuf, sz);
36793 +#else
36794 + temp = kbuf;
36795 +#endif
36796 +
36797 + err = copy_to_user(buf, temp, sz);
36798 +
36799 +#ifdef CONFIG_PAX_USERCOPY
36800 + kfree(temp);
36801 +#endif
36802 +
36803 + if (err)
36804 return -EFAULT;
36805 buf += sz;
36806 p += sz;
36807 @@ -822,6 +869,9 @@ static const struct memdev {
36808 #ifdef CONFIG_PRINTK
36809 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36810 #endif
36811 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36812 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36813 +#endif
36814 };
36815
36816 static int memory_open(struct inode *inode, struct file *filp)
36817 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36818 continue;
36819
36820 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36821 - NULL, devlist[minor].name);
36822 + NULL, "%s", devlist[minor].name);
36823 }
36824
36825 return tty_init();
36826 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36827 index 9df78e2..01ba9ae 100644
36828 --- a/drivers/char/nvram.c
36829 +++ b/drivers/char/nvram.c
36830 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36831
36832 spin_unlock_irq(&rtc_lock);
36833
36834 - if (copy_to_user(buf, contents, tmp - contents))
36835 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36836 return -EFAULT;
36837
36838 *ppos = i;
36839 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36840 index 5c5cc00..ac9edb7 100644
36841 --- a/drivers/char/pcmcia/synclink_cs.c
36842 +++ b/drivers/char/pcmcia/synclink_cs.c
36843 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36844
36845 if (debug_level >= DEBUG_LEVEL_INFO)
36846 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36847 - __FILE__, __LINE__, info->device_name, port->count);
36848 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36849
36850 - WARN_ON(!port->count);
36851 + WARN_ON(!atomic_read(&port->count));
36852
36853 if (tty_port_close_start(port, tty, filp) == 0)
36854 goto cleanup;
36855 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36856 cleanup:
36857 if (debug_level >= DEBUG_LEVEL_INFO)
36858 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36859 - tty->driver->name, port->count);
36860 + tty->driver->name, atomic_read(&port->count));
36861 }
36862
36863 /* Wait until the transmitter is empty.
36864 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36865
36866 if (debug_level >= DEBUG_LEVEL_INFO)
36867 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36868 - __FILE__, __LINE__, tty->driver->name, port->count);
36869 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36870
36871 /* If port is closing, signal caller to try again */
36872 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36873 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36874 goto cleanup;
36875 }
36876 spin_lock(&port->lock);
36877 - port->count++;
36878 + atomic_inc(&port->count);
36879 spin_unlock(&port->lock);
36880 spin_unlock_irqrestore(&info->netlock, flags);
36881
36882 - if (port->count == 1) {
36883 + if (atomic_read(&port->count) == 1) {
36884 /* 1st open on this device, init hardware */
36885 retval = startup(info, tty);
36886 if (retval < 0)
36887 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36888 unsigned short new_crctype;
36889
36890 /* return error if TTY interface open */
36891 - if (info->port.count)
36892 + if (atomic_read(&info->port.count))
36893 return -EBUSY;
36894
36895 switch (encoding)
36896 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36897
36898 /* arbitrate between network and tty opens */
36899 spin_lock_irqsave(&info->netlock, flags);
36900 - if (info->port.count != 0 || info->netcount != 0) {
36901 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36902 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36903 spin_unlock_irqrestore(&info->netlock, flags);
36904 return -EBUSY;
36905 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36906 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36907
36908 /* return error if TTY interface open */
36909 - if (info->port.count)
36910 + if (atomic_read(&info->port.count))
36911 return -EBUSY;
36912
36913 if (cmd != SIOCWANDEV)
36914 diff --git a/drivers/char/random.c b/drivers/char/random.c
36915 index 0d91fe5..f8e37b0 100644
36916 --- a/drivers/char/random.c
36917 +++ b/drivers/char/random.c
36918 @@ -272,8 +272,13 @@
36919 /*
36920 * Configuration information
36921 */
36922 +#ifdef CONFIG_GRKERNSEC_RANDNET
36923 +#define INPUT_POOL_WORDS 512
36924 +#define OUTPUT_POOL_WORDS 128
36925 +#else
36926 #define INPUT_POOL_WORDS 128
36927 #define OUTPUT_POOL_WORDS 32
36928 +#endif
36929 #define SEC_XFER_SIZE 512
36930 #define EXTRACT_SIZE 10
36931
36932 @@ -313,10 +318,17 @@ static struct poolinfo {
36933 int poolwords;
36934 int tap1, tap2, tap3, tap4, tap5;
36935 } poolinfo_table[] = {
36936 +#ifdef CONFIG_GRKERNSEC_RANDNET
36937 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36938 + { 512, 411, 308, 208, 104, 1 },
36939 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36940 + { 128, 103, 76, 51, 25, 1 },
36941 +#else
36942 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36943 { 128, 103, 76, 51, 25, 1 },
36944 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36945 { 32, 26, 20, 14, 7, 1 },
36946 +#endif
36947 #if 0
36948 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36949 { 2048, 1638, 1231, 819, 411, 1 },
36950 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36951 input_rotate += i ? 7 : 14;
36952 }
36953
36954 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36955 - ACCESS_ONCE(r->add_ptr) = i;
36956 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36957 + ACCESS_ONCE_RW(r->add_ptr) = i;
36958 smp_wmb();
36959
36960 if (out)
36961 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36962
36963 extract_buf(r, tmp);
36964 i = min_t(int, nbytes, EXTRACT_SIZE);
36965 - if (copy_to_user(buf, tmp, i)) {
36966 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36967 ret = -EFAULT;
36968 break;
36969 }
36970 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36971 #include <linux/sysctl.h>
36972
36973 static int min_read_thresh = 8, min_write_thresh;
36974 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36975 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36976 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36977 static char sysctl_bootid[16];
36978
36979 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
36980 static int proc_do_uuid(struct ctl_table *table, int write,
36981 void __user *buffer, size_t *lenp, loff_t *ppos)
36982 {
36983 - struct ctl_table fake_table;
36984 + ctl_table_no_const fake_table;
36985 unsigned char buf[64], tmp_uuid[16], *uuid;
36986
36987 uuid = table->data;
36988 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
36989 index bf2349db..5456d53 100644
36990 --- a/drivers/char/sonypi.c
36991 +++ b/drivers/char/sonypi.c
36992 @@ -54,6 +54,7 @@
36993
36994 #include <asm/uaccess.h>
36995 #include <asm/io.h>
36996 +#include <asm/local.h>
36997
36998 #include <linux/sonypi.h>
36999
37000 @@ -490,7 +491,7 @@ static struct sonypi_device {
37001 spinlock_t fifo_lock;
37002 wait_queue_head_t fifo_proc_list;
37003 struct fasync_struct *fifo_async;
37004 - int open_count;
37005 + local_t open_count;
37006 int model;
37007 struct input_dev *input_jog_dev;
37008 struct input_dev *input_key_dev;
37009 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37010 static int sonypi_misc_release(struct inode *inode, struct file *file)
37011 {
37012 mutex_lock(&sonypi_device.lock);
37013 - sonypi_device.open_count--;
37014 + local_dec(&sonypi_device.open_count);
37015 mutex_unlock(&sonypi_device.lock);
37016 return 0;
37017 }
37018 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37019 {
37020 mutex_lock(&sonypi_device.lock);
37021 /* Flush input queue on first open */
37022 - if (!sonypi_device.open_count)
37023 + if (!local_read(&sonypi_device.open_count))
37024 kfifo_reset(&sonypi_device.fifo);
37025 - sonypi_device.open_count++;
37026 + local_inc(&sonypi_device.open_count);
37027 mutex_unlock(&sonypi_device.lock);
37028
37029 return 0;
37030 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37031 index 64420b3..5c40b56 100644
37032 --- a/drivers/char/tpm/tpm_acpi.c
37033 +++ b/drivers/char/tpm/tpm_acpi.c
37034 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37035 virt = acpi_os_map_memory(start, len);
37036 if (!virt) {
37037 kfree(log->bios_event_log);
37038 + log->bios_event_log = NULL;
37039 printk("%s: ERROR - Unable to map memory\n", __func__);
37040 return -EIO;
37041 }
37042
37043 - memcpy_fromio(log->bios_event_log, virt, len);
37044 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37045
37046 acpi_os_unmap_memory(virt, len);
37047 return 0;
37048 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37049 index 84ddc55..1d32f1e 100644
37050 --- a/drivers/char/tpm/tpm_eventlog.c
37051 +++ b/drivers/char/tpm/tpm_eventlog.c
37052 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37053 event = addr;
37054
37055 if ((event->event_type == 0 && event->event_size == 0) ||
37056 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37057 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37058 return NULL;
37059
37060 return addr;
37061 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37062 return NULL;
37063
37064 if ((event->event_type == 0 && event->event_size == 0) ||
37065 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37066 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37067 return NULL;
37068
37069 (*pos)++;
37070 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37071 int i;
37072
37073 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37074 - seq_putc(m, data[i]);
37075 + if (!seq_putc(m, data[i]))
37076 + return -EFAULT;
37077
37078 return 0;
37079 }
37080 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37081 index fc45567..fa2a590 100644
37082 --- a/drivers/char/virtio_console.c
37083 +++ b/drivers/char/virtio_console.c
37084 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37085 if (to_user) {
37086 ssize_t ret;
37087
37088 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37089 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37090 if (ret)
37091 return -EFAULT;
37092 } else {
37093 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37094 if (!port_has_data(port) && !port->host_connected)
37095 return 0;
37096
37097 - return fill_readbuf(port, ubuf, count, true);
37098 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37099 }
37100
37101 static int wait_port_writable(struct port *port, bool nonblock)
37102 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37103 index a33f46f..a720eed 100644
37104 --- a/drivers/clk/clk-composite.c
37105 +++ b/drivers/clk/clk-composite.c
37106 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37107 struct clk *clk;
37108 struct clk_init_data init;
37109 struct clk_composite *composite;
37110 - struct clk_ops *clk_composite_ops;
37111 + clk_ops_no_const *clk_composite_ops;
37112
37113 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37114 if (!composite) {
37115 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37116 index 5bb848c..f1d4fc9 100644
37117 --- a/drivers/clk/socfpga/clk.c
37118 +++ b/drivers/clk/socfpga/clk.c
37119 @@ -22,6 +22,7 @@
37120 #include <linux/clk-provider.h>
37121 #include <linux/io.h>
37122 #include <linux/of.h>
37123 +#include <asm/pgtable.h>
37124
37125 /* Clock Manager offsets */
37126 #define CLKMGR_CTRL 0x0
37127 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37128 streq(clk_name, "periph_pll") ||
37129 streq(clk_name, "sdram_pll")) {
37130 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37131 - clk_pll_ops.enable = clk_gate_ops.enable;
37132 - clk_pll_ops.disable = clk_gate_ops.disable;
37133 + pax_open_kernel();
37134 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37135 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37136 + pax_close_kernel();
37137 }
37138
37139 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37140 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37141 return parent_rate / div;
37142 }
37143
37144 -static struct clk_ops gateclk_ops = {
37145 +static clk_ops_no_const gateclk_ops __read_only = {
37146 .recalc_rate = socfpga_clk_recalc_rate,
37147 .get_parent = socfpga_clk_get_parent,
37148 .set_parent = socfpga_clk_set_parent,
37149 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37150 index 3926402..37b580d 100644
37151 --- a/drivers/cpufreq/acpi-cpufreq.c
37152 +++ b/drivers/cpufreq/acpi-cpufreq.c
37153 @@ -173,7 +173,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37154 return sprintf(buf, "%u\n", boost_enabled);
37155 }
37156
37157 -static struct global_attr global_boost = __ATTR(boost, 0644,
37158 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37159 show_global_boost,
37160 store_global_boost);
37161
37162 @@ -722,8 +722,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37163 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37164 per_cpu(acfreq_data, cpu) = data;
37165
37166 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37167 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37168 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37169 + pax_open_kernel();
37170 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37171 + pax_close_kernel();
37172 + }
37173
37174 result = acpi_processor_register_performance(data->acpi_data, cpu);
37175 if (result)
37176 @@ -851,7 +854,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37177 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37178 break;
37179 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37180 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37181 + pax_open_kernel();
37182 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37183 + pax_close_kernel();
37184 policy->cur = get_cur_freq_on_cpu(cpu);
37185 break;
37186 default:
37187 @@ -862,8 +867,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37188 acpi_processor_notify_smm(THIS_MODULE);
37189
37190 /* Check for APERF/MPERF support in hardware */
37191 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
37192 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37193 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
37194 + pax_open_kernel();
37195 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37196 + pax_close_kernel();
37197 + }
37198
37199 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
37200 for (i = 0; i < perf->state_count; i++)
37201 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37202 index f0a5e2b..0a7ee46 100644
37203 --- a/drivers/cpufreq/cpufreq.c
37204 +++ b/drivers/cpufreq/cpufreq.c
37205 @@ -1959,7 +1959,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37206 return NOTIFY_OK;
37207 }
37208
37209 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37210 +static struct notifier_block cpufreq_cpu_notifier = {
37211 .notifier_call = cpufreq_cpu_callback,
37212 };
37213
37214 @@ -1991,8 +1991,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37215
37216 pr_debug("trying to register driver %s\n", driver_data->name);
37217
37218 - if (driver_data->setpolicy)
37219 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37220 + if (driver_data->setpolicy) {
37221 + pax_open_kernel();
37222 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37223 + pax_close_kernel();
37224 + }
37225
37226 write_lock_irqsave(&cpufreq_driver_lock, flags);
37227 if (cpufreq_driver) {
37228 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37229 index e59afaa..a53a3ff 100644
37230 --- a/drivers/cpufreq/cpufreq_governor.c
37231 +++ b/drivers/cpufreq/cpufreq_governor.c
37232 @@ -191,7 +191,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37233 struct dbs_data *dbs_data;
37234 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37235 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37236 - struct od_ops *od_ops = NULL;
37237 + const struct od_ops *od_ops = NULL;
37238 struct od_dbs_tuners *od_tuners = NULL;
37239 struct cs_dbs_tuners *cs_tuners = NULL;
37240 struct cpu_dbs_common_info *cpu_cdbs;
37241 @@ -257,7 +257,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37242
37243 if ((cdata->governor == GOV_CONSERVATIVE) &&
37244 (!policy->governor->initialized)) {
37245 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37246 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37247
37248 cpufreq_register_notifier(cs_ops->notifier_block,
37249 CPUFREQ_TRANSITION_NOTIFIER);
37250 @@ -277,7 +277,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37251
37252 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37253 (policy->governor->initialized == 1)) {
37254 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37255 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37256
37257 cpufreq_unregister_notifier(cs_ops->notifier_block,
37258 CPUFREQ_TRANSITION_NOTIFIER);
37259 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37260 index d5f12b4..eb30af1 100644
37261 --- a/drivers/cpufreq/cpufreq_governor.h
37262 +++ b/drivers/cpufreq/cpufreq_governor.h
37263 @@ -204,7 +204,7 @@ struct common_dbs_data {
37264 void (*exit)(struct dbs_data *dbs_data);
37265
37266 /* Governor specific ops, see below */
37267 - void *gov_ops;
37268 + const void *gov_ops;
37269 };
37270
37271 /* Governer Per policy data */
37272 @@ -224,7 +224,7 @@ struct od_ops {
37273 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37274 unsigned int freq_next, unsigned int relation);
37275 void (*freq_increase)(struct cpufreq_policy *p, unsigned int freq);
37276 -};
37277 +} __no_const;
37278
37279 struct cs_ops {
37280 struct notifier_block *notifier_block;
37281 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37282 index c087347..989aa2e 100644
37283 --- a/drivers/cpufreq/cpufreq_ondemand.c
37284 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37285 @@ -560,7 +560,7 @@ static void od_exit(struct dbs_data *dbs_data)
37286
37287 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37288
37289 -static struct od_ops od_ops = {
37290 +static struct od_ops od_ops __read_only = {
37291 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37292 .powersave_bias_target = generic_powersave_bias_target,
37293 .freq_increase = dbs_freq_increase,
37294 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37295 (struct cpufreq_policy *, unsigned int, unsigned int),
37296 unsigned int powersave_bias)
37297 {
37298 - od_ops.powersave_bias_target = f;
37299 + pax_open_kernel();
37300 + *(void **)&od_ops.powersave_bias_target = f;
37301 + pax_close_kernel();
37302 od_set_powersave_bias(powersave_bias);
37303 }
37304 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37305
37306 void od_unregister_powersave_bias_handler(void)
37307 {
37308 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37309 + pax_open_kernel();
37310 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37311 + pax_close_kernel();
37312 od_set_powersave_bias(0);
37313 }
37314 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37315 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37316 index d37568c..fbb19a1 100644
37317 --- a/drivers/cpufreq/cpufreq_stats.c
37318 +++ b/drivers/cpufreq/cpufreq_stats.c
37319 @@ -365,7 +365,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37320 }
37321
37322 /* priority=1 so this will get called before cpufreq_remove_dev */
37323 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37324 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37325 .notifier_call = cpufreq_stat_cpu_callback,
37326 .priority = 1,
37327 };
37328 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37329 index 9ee7817..17b658e 100644
37330 --- a/drivers/cpufreq/p4-clockmod.c
37331 +++ b/drivers/cpufreq/p4-clockmod.c
37332 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37333 case 0x0F: /* Core Duo */
37334 case 0x16: /* Celeron Core */
37335 case 0x1C: /* Atom */
37336 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37337 + pax_open_kernel();
37338 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37339 + pax_close_kernel();
37340 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37341 case 0x0D: /* Pentium M (Dothan) */
37342 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37343 + pax_open_kernel();
37344 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37345 + pax_close_kernel();
37346 /* fall through */
37347 case 0x09: /* Pentium M (Banias) */
37348 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37349 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37350
37351 /* on P-4s, the TSC runs with constant frequency independent whether
37352 * throttling is active or not. */
37353 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37354 + pax_open_kernel();
37355 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37356 + pax_close_kernel();
37357
37358 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37359 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37360 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37361 index 880ee29..2445bc6 100644
37362 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37363 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37364 @@ -18,14 +18,12 @@
37365 #include <asm/head.h>
37366 #include <asm/timer.h>
37367
37368 -static struct cpufreq_driver *cpufreq_us3_driver;
37369 -
37370 struct us3_freq_percpu_info {
37371 struct cpufreq_frequency_table table[4];
37372 };
37373
37374 /* Indexed by cpu number. */
37375 -static struct us3_freq_percpu_info *us3_freq_table;
37376 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37377
37378 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37379 * in the Safari config register.
37380 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37381
37382 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37383 {
37384 - if (cpufreq_us3_driver)
37385 - us3_set_cpu_divider_index(policy, 0);
37386 + us3_set_cpu_divider_index(policy->cpu, 0);
37387
37388 return 0;
37389 }
37390
37391 +static int __init us3_freq_init(void);
37392 +static void __exit us3_freq_exit(void);
37393 +
37394 +static struct cpufreq_driver cpufreq_us3_driver = {
37395 + .init = us3_freq_cpu_init,
37396 + .verify = us3_freq_verify,
37397 + .target = us3_freq_target,
37398 + .get = us3_freq_get,
37399 + .exit = us3_freq_cpu_exit,
37400 + .owner = THIS_MODULE,
37401 + .name = "UltraSPARC-III",
37402 +
37403 +};
37404 +
37405 static int __init us3_freq_init(void)
37406 {
37407 unsigned long manuf, impl, ver;
37408 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
37409 (impl == CHEETAH_IMPL ||
37410 impl == CHEETAH_PLUS_IMPL ||
37411 impl == JAGUAR_IMPL ||
37412 - impl == PANTHER_IMPL)) {
37413 - struct cpufreq_driver *driver;
37414 -
37415 - ret = -ENOMEM;
37416 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
37417 - if (!driver)
37418 - goto err_out;
37419 -
37420 - us3_freq_table = kzalloc(
37421 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
37422 - GFP_KERNEL);
37423 - if (!us3_freq_table)
37424 - goto err_out;
37425 -
37426 - driver->init = us3_freq_cpu_init;
37427 - driver->verify = us3_freq_verify;
37428 - driver->target = us3_freq_target;
37429 - driver->get = us3_freq_get;
37430 - driver->exit = us3_freq_cpu_exit;
37431 - driver->owner = THIS_MODULE,
37432 - strcpy(driver->name, "UltraSPARC-III");
37433 -
37434 - cpufreq_us3_driver = driver;
37435 - ret = cpufreq_register_driver(driver);
37436 - if (ret)
37437 - goto err_out;
37438 -
37439 - return 0;
37440 -
37441 -err_out:
37442 - if (driver) {
37443 - kfree(driver);
37444 - cpufreq_us3_driver = NULL;
37445 - }
37446 - kfree(us3_freq_table);
37447 - us3_freq_table = NULL;
37448 - return ret;
37449 - }
37450 + impl == PANTHER_IMPL))
37451 + return cpufreq_register_driver(&cpufreq_us3_driver);
37452
37453 return -ENODEV;
37454 }
37455
37456 static void __exit us3_freq_exit(void)
37457 {
37458 - if (cpufreq_us3_driver) {
37459 - cpufreq_unregister_driver(cpufreq_us3_driver);
37460 - kfree(cpufreq_us3_driver);
37461 - cpufreq_us3_driver = NULL;
37462 - kfree(us3_freq_table);
37463 - us3_freq_table = NULL;
37464 - }
37465 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37466 }
37467
37468 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37469 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37470 index 0915e71..53376ed 100644
37471 --- a/drivers/cpufreq/speedstep-centrino.c
37472 +++ b/drivers/cpufreq/speedstep-centrino.c
37473 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37474 !cpu_has(cpu, X86_FEATURE_EST))
37475 return -ENODEV;
37476
37477 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37478 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37479 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37480 + pax_open_kernel();
37481 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37482 + pax_close_kernel();
37483 + }
37484
37485 if (policy->cpu != 0)
37486 return -ENODEV;
37487 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37488 index fdc432f..98e64e2 100644
37489 --- a/drivers/cpuidle/cpuidle.c
37490 +++ b/drivers/cpuidle/cpuidle.c
37491 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
37492
37493 static void poll_idle_init(struct cpuidle_driver *drv)
37494 {
37495 - struct cpuidle_state *state = &drv->states[0];
37496 + cpuidle_state_no_const *state = &drv->states[0];
37497
37498 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37499 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37500 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37501 index ea2f8e7..70ac501 100644
37502 --- a/drivers/cpuidle/governor.c
37503 +++ b/drivers/cpuidle/governor.c
37504 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37505 mutex_lock(&cpuidle_lock);
37506 if (__cpuidle_find_governor(gov->name) == NULL) {
37507 ret = 0;
37508 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37509 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37510 if (!cpuidle_curr_governor ||
37511 cpuidle_curr_governor->rating < gov->rating)
37512 cpuidle_switch_governor(gov);
37513 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37514 new_gov = cpuidle_replace_governor(gov->rating);
37515 cpuidle_switch_governor(new_gov);
37516 }
37517 - list_del(&gov->governor_list);
37518 + pax_list_del((struct list_head *)&gov->governor_list);
37519 mutex_unlock(&cpuidle_lock);
37520 }
37521
37522 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37523 index 428754a..8bdf9cc 100644
37524 --- a/drivers/cpuidle/sysfs.c
37525 +++ b/drivers/cpuidle/sysfs.c
37526 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37527 NULL
37528 };
37529
37530 -static struct attribute_group cpuidle_attr_group = {
37531 +static attribute_group_no_const cpuidle_attr_group = {
37532 .attrs = cpuidle_default_attrs,
37533 .name = "cpuidle",
37534 };
37535 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37536 index 12fea3e..1e28f47 100644
37537 --- a/drivers/crypto/hifn_795x.c
37538 +++ b/drivers/crypto/hifn_795x.c
37539 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37540 MODULE_PARM_DESC(hifn_pll_ref,
37541 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37542
37543 -static atomic_t hifn_dev_number;
37544 +static atomic_unchecked_t hifn_dev_number;
37545
37546 #define ACRYPTO_OP_DECRYPT 0
37547 #define ACRYPTO_OP_ENCRYPT 1
37548 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37549 goto err_out_disable_pci_device;
37550
37551 snprintf(name, sizeof(name), "hifn%d",
37552 - atomic_inc_return(&hifn_dev_number)-1);
37553 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37554
37555 err = pci_request_regions(pdev, name);
37556 if (err)
37557 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37558 index e94e619..f7e249c 100644
37559 --- a/drivers/devfreq/devfreq.c
37560 +++ b/drivers/devfreq/devfreq.c
37561 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37562 goto err_out;
37563 }
37564
37565 - list_add(&governor->node, &devfreq_governor_list);
37566 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37567
37568 list_for_each_entry(devfreq, &devfreq_list, node) {
37569 int ret = 0;
37570 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37571 }
37572 }
37573
37574 - list_del(&governor->node);
37575 + pax_list_del((struct list_head *)&governor->node);
37576 err_out:
37577 mutex_unlock(&devfreq_list_lock);
37578
37579 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
37580 index 5039fbc..841169f 100644
37581 --- a/drivers/dma/sh/shdma.c
37582 +++ b/drivers/dma/sh/shdma.c
37583 @@ -488,7 +488,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37584 return ret;
37585 }
37586
37587 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37588 +static struct notifier_block sh_dmae_nmi_notifier = {
37589 .notifier_call = sh_dmae_nmi_handler,
37590
37591 /* Run before NMI debug handler and KGDB */
37592 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37593 index 211021d..201d47f 100644
37594 --- a/drivers/edac/edac_device.c
37595 +++ b/drivers/edac/edac_device.c
37596 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37597 */
37598 int edac_device_alloc_index(void)
37599 {
37600 - static atomic_t device_indexes = ATOMIC_INIT(0);
37601 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37602
37603 - return atomic_inc_return(&device_indexes) - 1;
37604 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37605 }
37606 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37607
37608 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37609 index e7c32c4..6397af1 100644
37610 --- a/drivers/edac/edac_mc_sysfs.c
37611 +++ b/drivers/edac/edac_mc_sysfs.c
37612 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
37613 struct dev_ch_attribute {
37614 struct device_attribute attr;
37615 int channel;
37616 -};
37617 +} __do_const;
37618
37619 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37620 struct dev_ch_attribute dev_attr_legacy_##_name = \
37621 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37622 }
37623
37624 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37625 + pax_open_kernel();
37626 if (mci->get_sdram_scrub_rate) {
37627 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37628 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37629 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37630 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37631 }
37632 if (mci->set_sdram_scrub_rate) {
37633 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37634 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37635 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37636 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37637 }
37638 + pax_close_kernel();
37639 err = device_create_file(&mci->dev,
37640 &dev_attr_sdram_scrub_rate);
37641 if (err) {
37642 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37643 index dd370f9..0281629 100644
37644 --- a/drivers/edac/edac_pci.c
37645 +++ b/drivers/edac/edac_pci.c
37646 @@ -29,7 +29,7 @@
37647
37648 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37649 static LIST_HEAD(edac_pci_list);
37650 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37651 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37652
37653 /*
37654 * edac_pci_alloc_ctl_info
37655 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37656 */
37657 int edac_pci_alloc_index(void)
37658 {
37659 - return atomic_inc_return(&pci_indexes) - 1;
37660 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37661 }
37662 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37663
37664 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37665 index e8658e4..22746d6 100644
37666 --- a/drivers/edac/edac_pci_sysfs.c
37667 +++ b/drivers/edac/edac_pci_sysfs.c
37668 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37669 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37670 static int edac_pci_poll_msec = 1000; /* one second workq period */
37671
37672 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37673 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37674 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37675 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37676
37677 static struct kobject *edac_pci_top_main_kobj;
37678 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37679 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37680 void *value;
37681 ssize_t(*show) (void *, char *);
37682 ssize_t(*store) (void *, const char *, size_t);
37683 -};
37684 +} __do_const;
37685
37686 /* Set of show/store abstract level functions for PCI Parity object */
37687 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37688 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37689 edac_printk(KERN_CRIT, EDAC_PCI,
37690 "Signaled System Error on %s\n",
37691 pci_name(dev));
37692 - atomic_inc(&pci_nonparity_count);
37693 + atomic_inc_unchecked(&pci_nonparity_count);
37694 }
37695
37696 if (status & (PCI_STATUS_PARITY)) {
37697 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37698 "Master Data Parity Error on %s\n",
37699 pci_name(dev));
37700
37701 - atomic_inc(&pci_parity_count);
37702 + atomic_inc_unchecked(&pci_parity_count);
37703 }
37704
37705 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37706 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37707 "Detected Parity Error on %s\n",
37708 pci_name(dev));
37709
37710 - atomic_inc(&pci_parity_count);
37711 + atomic_inc_unchecked(&pci_parity_count);
37712 }
37713 }
37714
37715 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37716 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37717 "Signaled System Error on %s\n",
37718 pci_name(dev));
37719 - atomic_inc(&pci_nonparity_count);
37720 + atomic_inc_unchecked(&pci_nonparity_count);
37721 }
37722
37723 if (status & (PCI_STATUS_PARITY)) {
37724 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37725 "Master Data Parity Error on "
37726 "%s\n", pci_name(dev));
37727
37728 - atomic_inc(&pci_parity_count);
37729 + atomic_inc_unchecked(&pci_parity_count);
37730 }
37731
37732 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37733 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37734 "Detected Parity Error on %s\n",
37735 pci_name(dev));
37736
37737 - atomic_inc(&pci_parity_count);
37738 + atomic_inc_unchecked(&pci_parity_count);
37739 }
37740 }
37741 }
37742 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37743 if (!check_pci_errors)
37744 return;
37745
37746 - before_count = atomic_read(&pci_parity_count);
37747 + before_count = atomic_read_unchecked(&pci_parity_count);
37748
37749 /* scan all PCI devices looking for a Parity Error on devices and
37750 * bridges.
37751 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37752 /* Only if operator has selected panic on PCI Error */
37753 if (edac_pci_get_panic_on_pe()) {
37754 /* If the count is different 'after' from 'before' */
37755 - if (before_count != atomic_read(&pci_parity_count))
37756 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37757 panic("EDAC: PCI Parity Error");
37758 }
37759 }
37760 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37761 index 51b7e3a..aa8a3e8 100644
37762 --- a/drivers/edac/mce_amd.h
37763 +++ b/drivers/edac/mce_amd.h
37764 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37765 bool (*mc0_mce)(u16, u8);
37766 bool (*mc1_mce)(u16, u8);
37767 bool (*mc2_mce)(u16, u8);
37768 -};
37769 +} __no_const;
37770
37771 void amd_report_gart_errors(bool);
37772 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37773 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37774 index 57ea7f4..af06b76 100644
37775 --- a/drivers/firewire/core-card.c
37776 +++ b/drivers/firewire/core-card.c
37777 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37778 const struct fw_card_driver *driver,
37779 struct device *device)
37780 {
37781 - static atomic_t index = ATOMIC_INIT(-1);
37782 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37783
37784 - card->index = atomic_inc_return(&index);
37785 + card->index = atomic_inc_return_unchecked(&index);
37786 card->driver = driver;
37787 card->device = device;
37788 card->current_tlabel = 0;
37789 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37790
37791 void fw_core_remove_card(struct fw_card *card)
37792 {
37793 - struct fw_card_driver dummy_driver = dummy_driver_template;
37794 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37795
37796 card->driver->update_phy_reg(card, 4,
37797 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37798 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37799 index de4aa40..49ab1f2 100644
37800 --- a/drivers/firewire/core-device.c
37801 +++ b/drivers/firewire/core-device.c
37802 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37803 struct config_rom_attribute {
37804 struct device_attribute attr;
37805 u32 key;
37806 -};
37807 +} __do_const;
37808
37809 static ssize_t show_immediate(struct device *dev,
37810 struct device_attribute *dattr, char *buf)
37811 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37812 index 28a94c7..58da63a 100644
37813 --- a/drivers/firewire/core-transaction.c
37814 +++ b/drivers/firewire/core-transaction.c
37815 @@ -38,6 +38,7 @@
37816 #include <linux/timer.h>
37817 #include <linux/types.h>
37818 #include <linux/workqueue.h>
37819 +#include <linux/sched.h>
37820
37821 #include <asm/byteorder.h>
37822
37823 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37824 index 515a42c..5ecf3ba 100644
37825 --- a/drivers/firewire/core.h
37826 +++ b/drivers/firewire/core.h
37827 @@ -111,6 +111,7 @@ struct fw_card_driver {
37828
37829 int (*stop_iso)(struct fw_iso_context *ctx);
37830 };
37831 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37832
37833 void fw_card_initialize(struct fw_card *card,
37834 const struct fw_card_driver *driver, struct device *device);
37835 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
37836 index 94a58a0..f5eba42 100644
37837 --- a/drivers/firmware/dmi-id.c
37838 +++ b/drivers/firmware/dmi-id.c
37839 @@ -16,7 +16,7 @@
37840 struct dmi_device_attribute{
37841 struct device_attribute dev_attr;
37842 int field;
37843 -};
37844 +} __do_const;
37845 #define to_dmi_dev_attr(_dev_attr) \
37846 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
37847
37848 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
37849 index 232fa8f..386c255 100644
37850 --- a/drivers/firmware/dmi_scan.c
37851 +++ b/drivers/firmware/dmi_scan.c
37852 @@ -504,11 +504,6 @@ void __init dmi_scan_machine(void)
37853 }
37854 }
37855 else {
37856 - /*
37857 - * no iounmap() for that ioremap(); it would be a no-op, but
37858 - * it's so early in setup that sucker gets confused into doing
37859 - * what it shouldn't if we actually call it.
37860 - */
37861 p = dmi_ioremap(0xF0000, 0x10000);
37862 if (p == NULL)
37863 goto error;
37864 @@ -806,7 +801,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
37865 if (buf == NULL)
37866 return -1;
37867
37868 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
37869 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
37870
37871 iounmap(buf);
37872 return 0;
37873 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
37874 index 5145fa3..0d3babd 100644
37875 --- a/drivers/firmware/efi/efi.c
37876 +++ b/drivers/firmware/efi/efi.c
37877 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
37878 };
37879
37880 static struct efivars generic_efivars;
37881 -static struct efivar_operations generic_ops;
37882 +static efivar_operations_no_const generic_ops __read_only;
37883
37884 static int generic_ops_register(void)
37885 {
37886 - generic_ops.get_variable = efi.get_variable;
37887 - generic_ops.set_variable = efi.set_variable;
37888 - generic_ops.get_next_variable = efi.get_next_variable;
37889 - generic_ops.query_variable_store = efi_query_variable_store;
37890 + pax_open_kernel();
37891 + *(void **)&generic_ops.get_variable = efi.get_variable;
37892 + *(void **)&generic_ops.set_variable = efi.set_variable;
37893 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
37894 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
37895 + pax_close_kernel();
37896
37897 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
37898 }
37899 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
37900 index 8a7432a..28fb839 100644
37901 --- a/drivers/firmware/efi/efivars.c
37902 +++ b/drivers/firmware/efi/efivars.c
37903 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
37904 static int
37905 create_efivars_bin_attributes(void)
37906 {
37907 - struct bin_attribute *attr;
37908 + bin_attribute_no_const *attr;
37909 int error;
37910
37911 /* new_var */
37912 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37913 index 2a90ba6..07f3733 100644
37914 --- a/drivers/firmware/google/memconsole.c
37915 +++ b/drivers/firmware/google/memconsole.c
37916 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
37917 if (!found_memconsole())
37918 return -ENODEV;
37919
37920 - memconsole_bin_attr.size = memconsole_length;
37921 + pax_open_kernel();
37922 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
37923 + pax_close_kernel();
37924
37925 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
37926
37927 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
37928 index 2729e3d..f9deca1 100644
37929 --- a/drivers/gpio/gpio-ich.c
37930 +++ b/drivers/gpio/gpio-ich.c
37931 @@ -71,7 +71,7 @@ struct ichx_desc {
37932 /* Some chipsets have quirks, let these use their own request/get */
37933 int (*request)(struct gpio_chip *chip, unsigned offset);
37934 int (*get)(struct gpio_chip *chip, unsigned offset);
37935 -};
37936 +} __do_const;
37937
37938 static struct {
37939 spinlock_t lock;
37940 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
37941 index 9902732..64b62dd 100644
37942 --- a/drivers/gpio/gpio-vr41xx.c
37943 +++ b/drivers/gpio/gpio-vr41xx.c
37944 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
37945 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
37946 maskl, pendl, maskh, pendh);
37947
37948 - atomic_inc(&irq_err_count);
37949 + atomic_inc_unchecked(&irq_err_count);
37950
37951 return -EINVAL;
37952 }
37953 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
37954 index 6a64749..0767a9f 100644
37955 --- a/drivers/gpu/drm/drm_crtc_helper.c
37956 +++ b/drivers/gpu/drm/drm_crtc_helper.c
37957 @@ -322,7 +322,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
37958 struct drm_crtc *tmp;
37959 int crtc_mask = 1;
37960
37961 - WARN(!crtc, "checking null crtc?\n");
37962 + BUG_ON(!crtc);
37963
37964 dev = crtc->dev;
37965
37966 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
37967 index 99fcd7c..13cf6c5 100644
37968 --- a/drivers/gpu/drm/drm_drv.c
37969 +++ b/drivers/gpu/drm/drm_drv.c
37970 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
37971 /**
37972 * Copy and IOCTL return string to user space
37973 */
37974 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
37975 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
37976 {
37977 int len;
37978
37979 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
37980 struct drm_file *file_priv = filp->private_data;
37981 struct drm_device *dev;
37982 const struct drm_ioctl_desc *ioctl = NULL;
37983 - drm_ioctl_t *func;
37984 + drm_ioctl_no_const_t func;
37985 unsigned int nr = DRM_IOCTL_NR(cmd);
37986 int retcode = -EINVAL;
37987 char stack_kdata[128];
37988 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
37989 return -ENODEV;
37990
37991 atomic_inc(&dev->ioctl_count);
37992 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
37993 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
37994 ++file_priv->ioctl_count;
37995
37996 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
37997 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
37998 index 3a24385..4e426e0 100644
37999 --- a/drivers/gpu/drm/drm_fops.c
38000 +++ b/drivers/gpu/drm/drm_fops.c
38001 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
38002 }
38003
38004 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
38005 - atomic_set(&dev->counts[i], 0);
38006 + atomic_set_unchecked(&dev->counts[i], 0);
38007
38008 dev->sigdata.lock = NULL;
38009
38010 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
38011 if (drm_device_is_unplugged(dev))
38012 return -ENODEV;
38013
38014 - if (!dev->open_count++)
38015 + if (local_inc_return(&dev->open_count) == 1)
38016 need_setup = 1;
38017 mutex_lock(&dev->struct_mutex);
38018 old_imapping = inode->i_mapping;
38019 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
38020 retcode = drm_open_helper(inode, filp, dev);
38021 if (retcode)
38022 goto err_undo;
38023 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38024 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38025 if (need_setup) {
38026 retcode = drm_setup(dev);
38027 if (retcode)
38028 @@ -166,7 +166,7 @@ err_undo:
38029 iput(container_of(dev->dev_mapping, struct inode, i_data));
38030 dev->dev_mapping = old_mapping;
38031 mutex_unlock(&dev->struct_mutex);
38032 - dev->open_count--;
38033 + local_dec(&dev->open_count);
38034 return retcode;
38035 }
38036 EXPORT_SYMBOL(drm_open);
38037 @@ -456,7 +456,7 @@ int drm_release(struct inode *inode, struct file *filp)
38038
38039 mutex_lock(&drm_global_mutex);
38040
38041 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38042 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38043
38044 if (dev->driver->preclose)
38045 dev->driver->preclose(dev, file_priv);
38046 @@ -465,10 +465,10 @@ int drm_release(struct inode *inode, struct file *filp)
38047 * Begin inline drm_release
38048 */
38049
38050 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38051 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38052 task_pid_nr(current),
38053 (long)old_encode_dev(file_priv->minor->device),
38054 - dev->open_count);
38055 + local_read(&dev->open_count));
38056
38057 /* Release any auth tokens that might point to this file_priv,
38058 (do that under the drm_global_mutex) */
38059 @@ -565,8 +565,8 @@ int drm_release(struct inode *inode, struct file *filp)
38060 * End inline drm_release
38061 */
38062
38063 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38064 - if (!--dev->open_count) {
38065 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38066 + if (local_dec_and_test(&dev->open_count)) {
38067 if (atomic_read(&dev->ioctl_count)) {
38068 DRM_ERROR("Device busy: %d\n",
38069 atomic_read(&dev->ioctl_count));
38070 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38071 index f731116..629842c 100644
38072 --- a/drivers/gpu/drm/drm_global.c
38073 +++ b/drivers/gpu/drm/drm_global.c
38074 @@ -36,7 +36,7 @@
38075 struct drm_global_item {
38076 struct mutex mutex;
38077 void *object;
38078 - int refcount;
38079 + atomic_t refcount;
38080 };
38081
38082 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38083 @@ -49,7 +49,7 @@ void drm_global_init(void)
38084 struct drm_global_item *item = &glob[i];
38085 mutex_init(&item->mutex);
38086 item->object = NULL;
38087 - item->refcount = 0;
38088 + atomic_set(&item->refcount, 0);
38089 }
38090 }
38091
38092 @@ -59,7 +59,7 @@ void drm_global_release(void)
38093 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38094 struct drm_global_item *item = &glob[i];
38095 BUG_ON(item->object != NULL);
38096 - BUG_ON(item->refcount != 0);
38097 + BUG_ON(atomic_read(&item->refcount) != 0);
38098 }
38099 }
38100
38101 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38102 void *object;
38103
38104 mutex_lock(&item->mutex);
38105 - if (item->refcount == 0) {
38106 + if (atomic_read(&item->refcount) == 0) {
38107 item->object = kzalloc(ref->size, GFP_KERNEL);
38108 if (unlikely(item->object == NULL)) {
38109 ret = -ENOMEM;
38110 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38111 goto out_err;
38112
38113 }
38114 - ++item->refcount;
38115 + atomic_inc(&item->refcount);
38116 ref->object = item->object;
38117 object = item->object;
38118 mutex_unlock(&item->mutex);
38119 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38120 struct drm_global_item *item = &glob[ref->global_type];
38121
38122 mutex_lock(&item->mutex);
38123 - BUG_ON(item->refcount == 0);
38124 + BUG_ON(atomic_read(&item->refcount) == 0);
38125 BUG_ON(ref->object != item->object);
38126 - if (--item->refcount == 0) {
38127 + if (atomic_dec_and_test(&item->refcount)) {
38128 ref->release(ref);
38129 item->object = NULL;
38130 }
38131 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38132 index d4b20ce..77a8d41 100644
38133 --- a/drivers/gpu/drm/drm_info.c
38134 +++ b/drivers/gpu/drm/drm_info.c
38135 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38136 struct drm_local_map *map;
38137 struct drm_map_list *r_list;
38138
38139 - /* Hardcoded from _DRM_FRAME_BUFFER,
38140 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38141 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38142 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38143 + static const char * const types[] = {
38144 + [_DRM_FRAME_BUFFER] = "FB",
38145 + [_DRM_REGISTERS] = "REG",
38146 + [_DRM_SHM] = "SHM",
38147 + [_DRM_AGP] = "AGP",
38148 + [_DRM_SCATTER_GATHER] = "SG",
38149 + [_DRM_CONSISTENT] = "PCI",
38150 + [_DRM_GEM] = "GEM" };
38151 const char *type;
38152 int i;
38153
38154 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38155 map = r_list->map;
38156 if (!map)
38157 continue;
38158 - if (map->type < 0 || map->type > 5)
38159 + if (map->type >= ARRAY_SIZE(types))
38160 type = "??";
38161 else
38162 type = types[map->type];
38163 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38164 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38165 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38166 vma->vm_flags & VM_IO ? 'i' : '-',
38167 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38168 + 0);
38169 +#else
38170 vma->vm_pgoff);
38171 +#endif
38172
38173 #if defined(__i386__)
38174 pgprot = pgprot_val(vma->vm_page_prot);
38175 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38176 index 2f4c434..dd12cd2 100644
38177 --- a/drivers/gpu/drm/drm_ioc32.c
38178 +++ b/drivers/gpu/drm/drm_ioc32.c
38179 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38180 request = compat_alloc_user_space(nbytes);
38181 if (!access_ok(VERIFY_WRITE, request, nbytes))
38182 return -EFAULT;
38183 - list = (struct drm_buf_desc *) (request + 1);
38184 + list = (struct drm_buf_desc __user *) (request + 1);
38185
38186 if (__put_user(count, &request->count)
38187 || __put_user(list, &request->list))
38188 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38189 request = compat_alloc_user_space(nbytes);
38190 if (!access_ok(VERIFY_WRITE, request, nbytes))
38191 return -EFAULT;
38192 - list = (struct drm_buf_pub *) (request + 1);
38193 + list = (struct drm_buf_pub __user *) (request + 1);
38194
38195 if (__put_user(count, &request->count)
38196 || __put_user(list, &request->list))
38197 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38198 return 0;
38199 }
38200
38201 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38202 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38203 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38204 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38205 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38206 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38207 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38208 {
38209 unsigned int nr = DRM_IOCTL_NR(cmd);
38210 - drm_ioctl_compat_t *fn;
38211 int ret;
38212
38213 /* Assume that ioctls without an explicit compat routine will just
38214 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38215 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38216 return drm_ioctl(filp, cmd, arg);
38217
38218 - fn = drm_compat_ioctls[nr];
38219 -
38220 - if (fn != NULL)
38221 - ret = (*fn) (filp, cmd, arg);
38222 + if (drm_compat_ioctls[nr] != NULL)
38223 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38224 else
38225 ret = drm_ioctl(filp, cmd, arg);
38226
38227 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
38228 index ffd7a7b..a64643e 100644
38229 --- a/drivers/gpu/drm/drm_ioctl.c
38230 +++ b/drivers/gpu/drm/drm_ioctl.c
38231 @@ -265,7 +265,7 @@ int drm_getstats(struct drm_device *dev, void *data,
38232 stats->data[i].value =
38233 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
38234 else
38235 - stats->data[i].value = atomic_read(&dev->counts[i]);
38236 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
38237 stats->data[i].type = dev->types[i];
38238 }
38239
38240 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38241 index d752c96..fe08455 100644
38242 --- a/drivers/gpu/drm/drm_lock.c
38243 +++ b/drivers/gpu/drm/drm_lock.c
38244 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38245 if (drm_lock_take(&master->lock, lock->context)) {
38246 master->lock.file_priv = file_priv;
38247 master->lock.lock_time = jiffies;
38248 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38249 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38250 break; /* Got lock */
38251 }
38252
38253 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38254 return -EINVAL;
38255 }
38256
38257 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38258 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38259
38260 if (drm_lock_free(&master->lock, lock->context)) {
38261 /* FIXME: Should really bail out here. */
38262 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38263 index 327ca19..684d3c0 100644
38264 --- a/drivers/gpu/drm/drm_stub.c
38265 +++ b/drivers/gpu/drm/drm_stub.c
38266 @@ -495,7 +495,7 @@ void drm_unplug_dev(struct drm_device *dev)
38267
38268 drm_device_set_unplugged(dev);
38269
38270 - if (dev->open_count == 0) {
38271 + if (local_read(&dev->open_count) == 0) {
38272 drm_put_dev(dev);
38273 }
38274 mutex_unlock(&drm_global_mutex);
38275 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38276 index 2290b3b..22056a1 100644
38277 --- a/drivers/gpu/drm/drm_sysfs.c
38278 +++ b/drivers/gpu/drm/drm_sysfs.c
38279 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38280 int drm_sysfs_device_add(struct drm_minor *minor)
38281 {
38282 int err;
38283 - char *minor_str;
38284 + const char *minor_str;
38285
38286 minor->kdev.parent = minor->dev->dev;
38287
38288 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38289 index ada49ed..29275a0 100644
38290 --- a/drivers/gpu/drm/i810/i810_dma.c
38291 +++ b/drivers/gpu/drm/i810/i810_dma.c
38292 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38293 dma->buflist[vertex->idx],
38294 vertex->discard, vertex->used);
38295
38296 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38297 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38298 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38299 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38300 sarea_priv->last_enqueue = dev_priv->counter - 1;
38301 sarea_priv->last_dispatch = (int)hw_status[5];
38302
38303 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38304 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38305 mc->last_render);
38306
38307 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38308 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38309 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38310 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38311 sarea_priv->last_enqueue = dev_priv->counter - 1;
38312 sarea_priv->last_dispatch = (int)hw_status[5];
38313
38314 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38315 index 6e0acad..93c8289 100644
38316 --- a/drivers/gpu/drm/i810/i810_drv.h
38317 +++ b/drivers/gpu/drm/i810/i810_drv.h
38318 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38319 int page_flipping;
38320
38321 wait_queue_head_t irq_queue;
38322 - atomic_t irq_received;
38323 - atomic_t irq_emitted;
38324 + atomic_unchecked_t irq_received;
38325 + atomic_unchecked_t irq_emitted;
38326
38327 int front_offset;
38328 } drm_i810_private_t;
38329 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38330 index 47d6c74..279123f 100644
38331 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38332 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38333 @@ -541,7 +541,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38334 I915_READ(GTIMR));
38335 }
38336 seq_printf(m, "Interrupts received: %d\n",
38337 - atomic_read(&dev_priv->irq_received));
38338 + atomic_read_unchecked(&dev_priv->irq_received));
38339 for_each_ring(ring, dev_priv, i) {
38340 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38341 seq_printf(m,
38342 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38343 index f466980..8f2883f 100644
38344 --- a/drivers/gpu/drm/i915/i915_dma.c
38345 +++ b/drivers/gpu/drm/i915/i915_dma.c
38346 @@ -1260,7 +1260,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38347 bool can_switch;
38348
38349 spin_lock(&dev->count_lock);
38350 - can_switch = (dev->open_count == 0);
38351 + can_switch = (local_read(&dev->open_count) == 0);
38352 spin_unlock(&dev->count_lock);
38353 return can_switch;
38354 }
38355 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38356 index 2f09e80..077876d 100644
38357 --- a/drivers/gpu/drm/i915/i915_drv.h
38358 +++ b/drivers/gpu/drm/i915/i915_drv.h
38359 @@ -1028,7 +1028,7 @@ typedef struct drm_i915_private {
38360 drm_dma_handle_t *status_page_dmah;
38361 struct resource mch_res;
38362
38363 - atomic_t irq_received;
38364 + atomic_unchecked_t irq_received;
38365
38366 /* protects the irq masks */
38367 spinlock_t irq_lock;
38368 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38369 index 87a3227..cd13d8f 100644
38370 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38371 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38372 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38373
38374 static int
38375 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38376 - int count)
38377 + unsigned int count)
38378 {
38379 - int i;
38380 + unsigned int i;
38381 int relocs_total = 0;
38382 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38383
38384 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38385 index 3c59584..500f2e9 100644
38386 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38387 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38388 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38389 (unsigned long)request);
38390 }
38391
38392 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38393 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38394 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38395 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38396 [DRM_I915_GETPARAM] = compat_i915_getparam,
38397 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38398 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38399 {
38400 unsigned int nr = DRM_IOCTL_NR(cmd);
38401 - drm_ioctl_compat_t *fn = NULL;
38402 int ret;
38403
38404 if (nr < DRM_COMMAND_BASE)
38405 return drm_compat_ioctl(filp, cmd, arg);
38406
38407 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38408 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38409 -
38410 - if (fn != NULL)
38411 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38412 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38413 ret = (*fn) (filp, cmd, arg);
38414 - else
38415 + } else
38416 ret = drm_ioctl(filp, cmd, arg);
38417
38418 return ret;
38419 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38420 index 46d46ba..6e49848 100644
38421 --- a/drivers/gpu/drm/i915/i915_irq.c
38422 +++ b/drivers/gpu/drm/i915/i915_irq.c
38423 @@ -975,7 +975,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38424 int pipe;
38425 u32 pipe_stats[I915_MAX_PIPES];
38426
38427 - atomic_inc(&dev_priv->irq_received);
38428 + atomic_inc_unchecked(&dev_priv->irq_received);
38429
38430 while (true) {
38431 iir = I915_READ(VLV_IIR);
38432 @@ -1192,7 +1192,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
38433 irqreturn_t ret = IRQ_NONE;
38434 int i;
38435
38436 - atomic_inc(&dev_priv->irq_received);
38437 + atomic_inc_unchecked(&dev_priv->irq_received);
38438
38439 /* We get interrupts on unclaimed registers, so check for this before we
38440 * do any I915_{READ,WRITE}. */
38441 @@ -1312,7 +1312,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38442 int ret = IRQ_NONE;
38443 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
38444
38445 - atomic_inc(&dev_priv->irq_received);
38446 + atomic_inc_unchecked(&dev_priv->irq_received);
38447
38448 /* disable master interrupt before clearing iir */
38449 de_ier = I915_READ(DEIER);
38450 @@ -2617,7 +2617,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38451 {
38452 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38453
38454 - atomic_set(&dev_priv->irq_received, 0);
38455 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38456
38457 I915_WRITE(HWSTAM, 0xeffe);
38458
38459 @@ -2639,7 +2639,7 @@ static void ivybridge_irq_preinstall(struct drm_device *dev)
38460 {
38461 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38462
38463 - atomic_set(&dev_priv->irq_received, 0);
38464 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38465
38466 I915_WRITE(HWSTAM, 0xeffe);
38467
38468 @@ -2667,7 +2667,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38469 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38470 int pipe;
38471
38472 - atomic_set(&dev_priv->irq_received, 0);
38473 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38474
38475 /* VLV magic */
38476 I915_WRITE(VLV_IMR, 0);
38477 @@ -2979,7 +2979,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38478 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38479 int pipe;
38480
38481 - atomic_set(&dev_priv->irq_received, 0);
38482 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38483
38484 for_each_pipe(pipe)
38485 I915_WRITE(PIPESTAT(pipe), 0);
38486 @@ -3058,7 +3058,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38487 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38488 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38489
38490 - atomic_inc(&dev_priv->irq_received);
38491 + atomic_inc_unchecked(&dev_priv->irq_received);
38492
38493 iir = I915_READ16(IIR);
38494 if (iir == 0)
38495 @@ -3133,7 +3133,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38496 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38497 int pipe;
38498
38499 - atomic_set(&dev_priv->irq_received, 0);
38500 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38501
38502 if (I915_HAS_HOTPLUG(dev)) {
38503 I915_WRITE(PORT_HOTPLUG_EN, 0);
38504 @@ -3232,7 +3232,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38505 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38506 int pipe, ret = IRQ_NONE;
38507
38508 - atomic_inc(&dev_priv->irq_received);
38509 + atomic_inc_unchecked(&dev_priv->irq_received);
38510
38511 iir = I915_READ(IIR);
38512 do {
38513 @@ -3356,7 +3356,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38514 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38515 int pipe;
38516
38517 - atomic_set(&dev_priv->irq_received, 0);
38518 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38519
38520 I915_WRITE(PORT_HOTPLUG_EN, 0);
38521 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38522 @@ -3465,7 +3465,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38523 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38524 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38525
38526 - atomic_inc(&dev_priv->irq_received);
38527 + atomic_inc_unchecked(&dev_priv->irq_received);
38528
38529 iir = I915_READ(IIR);
38530
38531 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38532 index bedf15a..d02d1e6 100644
38533 --- a/drivers/gpu/drm/i915/intel_display.c
38534 +++ b/drivers/gpu/drm/i915/intel_display.c
38535 @@ -9424,13 +9424,13 @@ struct intel_quirk {
38536 int subsystem_vendor;
38537 int subsystem_device;
38538 void (*hook)(struct drm_device *dev);
38539 -};
38540 +} __do_const;
38541
38542 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38543 struct intel_dmi_quirk {
38544 void (*hook)(struct drm_device *dev);
38545 const struct dmi_system_id (*dmi_id_list)[];
38546 -};
38547 +} __do_const;
38548
38549 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38550 {
38551 @@ -9438,18 +9438,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38552 return 1;
38553 }
38554
38555 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38556 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38557 {
38558 - .dmi_id_list = &(const struct dmi_system_id[]) {
38559 - {
38560 - .callback = intel_dmi_reverse_brightness,
38561 - .ident = "NCR Corporation",
38562 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38563 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38564 - },
38565 - },
38566 - { } /* terminating entry */
38567 + .callback = intel_dmi_reverse_brightness,
38568 + .ident = "NCR Corporation",
38569 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38570 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38571 },
38572 + },
38573 + { } /* terminating entry */
38574 +};
38575 +
38576 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38577 + {
38578 + .dmi_id_list = &intel_dmi_quirks_table,
38579 .hook = quirk_invert_brightness,
38580 },
38581 };
38582 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38583 index 54558a0..2d97005 100644
38584 --- a/drivers/gpu/drm/mga/mga_drv.h
38585 +++ b/drivers/gpu/drm/mga/mga_drv.h
38586 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38587 u32 clear_cmd;
38588 u32 maccess;
38589
38590 - atomic_t vbl_received; /**< Number of vblanks received. */
38591 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38592 wait_queue_head_t fence_queue;
38593 - atomic_t last_fence_retired;
38594 + atomic_unchecked_t last_fence_retired;
38595 u32 next_fence_to_post;
38596
38597 unsigned int fb_cpp;
38598 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38599 index 709e90d..89a1c0d 100644
38600 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38601 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38602 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38603 return 0;
38604 }
38605
38606 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38607 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38608 [DRM_MGA_INIT] = compat_mga_init,
38609 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38610 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38611 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38612 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38613 {
38614 unsigned int nr = DRM_IOCTL_NR(cmd);
38615 - drm_ioctl_compat_t *fn = NULL;
38616 int ret;
38617
38618 if (nr < DRM_COMMAND_BASE)
38619 return drm_compat_ioctl(filp, cmd, arg);
38620
38621 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38622 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38623 -
38624 - if (fn != NULL)
38625 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38626 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38627 ret = (*fn) (filp, cmd, arg);
38628 - else
38629 + } else
38630 ret = drm_ioctl(filp, cmd, arg);
38631
38632 return ret;
38633 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38634 index 598c281..60d590e 100644
38635 --- a/drivers/gpu/drm/mga/mga_irq.c
38636 +++ b/drivers/gpu/drm/mga/mga_irq.c
38637 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38638 if (crtc != 0)
38639 return 0;
38640
38641 - return atomic_read(&dev_priv->vbl_received);
38642 + return atomic_read_unchecked(&dev_priv->vbl_received);
38643 }
38644
38645
38646 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38647 /* VBLANK interrupt */
38648 if (status & MGA_VLINEPEN) {
38649 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38650 - atomic_inc(&dev_priv->vbl_received);
38651 + atomic_inc_unchecked(&dev_priv->vbl_received);
38652 drm_handle_vblank(dev, 0);
38653 handled = 1;
38654 }
38655 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38656 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38657 MGA_WRITE(MGA_PRIMEND, prim_end);
38658
38659 - atomic_inc(&dev_priv->last_fence_retired);
38660 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38661 DRM_WAKEUP(&dev_priv->fence_queue);
38662 handled = 1;
38663 }
38664 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38665 * using fences.
38666 */
38667 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38668 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38669 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38670 - *sequence) <= (1 << 23)));
38671
38672 *sequence = cur_fence;
38673 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38674 index 3e72876..d1c15ad 100644
38675 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38676 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38677 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38678 struct bit_table {
38679 const char id;
38680 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38681 -};
38682 +} __no_const;
38683
38684 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38685
38686 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38687 index 41ff7e0..fa854ef 100644
38688 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38689 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38690 @@ -92,7 +92,6 @@ struct nouveau_drm {
38691 struct drm_global_reference mem_global_ref;
38692 struct ttm_bo_global_ref bo_global_ref;
38693 struct ttm_bo_device bdev;
38694 - atomic_t validate_sequence;
38695 int (*move)(struct nouveau_channel *,
38696 struct ttm_buffer_object *,
38697 struct ttm_mem_reg *, struct ttm_mem_reg *);
38698 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38699 index 08214bc..9208577 100644
38700 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38701 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38702 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38703 unsigned long arg)
38704 {
38705 unsigned int nr = DRM_IOCTL_NR(cmd);
38706 - drm_ioctl_compat_t *fn = NULL;
38707 + drm_ioctl_compat_t fn = NULL;
38708 int ret;
38709
38710 if (nr < DRM_COMMAND_BASE)
38711 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38712 index 25d3495..d81aaf6 100644
38713 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38714 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38715 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38716 bool can_switch;
38717
38718 spin_lock(&dev->count_lock);
38719 - can_switch = (dev->open_count == 0);
38720 + can_switch = (local_read(&dev->open_count) == 0);
38721 spin_unlock(&dev->count_lock);
38722 return can_switch;
38723 }
38724 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38725 index 1dfd84c..104896c 100644
38726 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38727 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38728 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38729 }
38730 }
38731
38732 -static struct vm_operations_struct qxl_ttm_vm_ops;
38733 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38734 static const struct vm_operations_struct *ttm_vm_ops;
38735
38736 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38737 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38738 return r;
38739 if (unlikely(ttm_vm_ops == NULL)) {
38740 ttm_vm_ops = vma->vm_ops;
38741 + pax_open_kernel();
38742 qxl_ttm_vm_ops = *ttm_vm_ops;
38743 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38744 + pax_close_kernel();
38745 }
38746 vma->vm_ops = &qxl_ttm_vm_ops;
38747 return 0;
38748 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38749 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38750 {
38751 #if defined(CONFIG_DEBUG_FS)
38752 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38753 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38754 - unsigned i;
38755 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38756 + {
38757 + .name = "qxl_mem_mm",
38758 + .show = &qxl_mm_dump_table,
38759 + },
38760 + {
38761 + .name = "qxl_surf_mm",
38762 + .show = &qxl_mm_dump_table,
38763 + }
38764 + };
38765
38766 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38767 - if (i == 0)
38768 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38769 - else
38770 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38771 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38772 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38773 - qxl_mem_types_list[i].driver_features = 0;
38774 - if (i == 0)
38775 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38776 - else
38777 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38778 + pax_open_kernel();
38779 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38780 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38781 + pax_close_kernel();
38782
38783 - }
38784 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38785 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38786 #else
38787 return 0;
38788 #endif
38789 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38790 index d4660cf..70dbe65 100644
38791 --- a/drivers/gpu/drm/r128/r128_cce.c
38792 +++ b/drivers/gpu/drm/r128/r128_cce.c
38793 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38794
38795 /* GH: Simple idle check.
38796 */
38797 - atomic_set(&dev_priv->idle_count, 0);
38798 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38799
38800 /* We don't support anything other than bus-mastering ring mode,
38801 * but the ring can be in either AGP or PCI space for the ring
38802 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38803 index 930c71b..499aded 100644
38804 --- a/drivers/gpu/drm/r128/r128_drv.h
38805 +++ b/drivers/gpu/drm/r128/r128_drv.h
38806 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38807 int is_pci;
38808 unsigned long cce_buffers_offset;
38809
38810 - atomic_t idle_count;
38811 + atomic_unchecked_t idle_count;
38812
38813 int page_flipping;
38814 int current_page;
38815 u32 crtc_offset;
38816 u32 crtc_offset_cntl;
38817
38818 - atomic_t vbl_received;
38819 + atomic_unchecked_t vbl_received;
38820
38821 u32 color_fmt;
38822 unsigned int front_offset;
38823 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38824 index a954c54..9cc595c 100644
38825 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38826 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38827 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38828 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38829 }
38830
38831 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38832 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38833 [DRM_R128_INIT] = compat_r128_init,
38834 [DRM_R128_DEPTH] = compat_r128_depth,
38835 [DRM_R128_STIPPLE] = compat_r128_stipple,
38836 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
38837 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38838 {
38839 unsigned int nr = DRM_IOCTL_NR(cmd);
38840 - drm_ioctl_compat_t *fn = NULL;
38841 int ret;
38842
38843 if (nr < DRM_COMMAND_BASE)
38844 return drm_compat_ioctl(filp, cmd, arg);
38845
38846 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
38847 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38848 -
38849 - if (fn != NULL)
38850 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
38851 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38852 ret = (*fn) (filp, cmd, arg);
38853 - else
38854 + } else
38855 ret = drm_ioctl(filp, cmd, arg);
38856
38857 return ret;
38858 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
38859 index 2ea4f09..d391371 100644
38860 --- a/drivers/gpu/drm/r128/r128_irq.c
38861 +++ b/drivers/gpu/drm/r128/r128_irq.c
38862 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
38863 if (crtc != 0)
38864 return 0;
38865
38866 - return atomic_read(&dev_priv->vbl_received);
38867 + return atomic_read_unchecked(&dev_priv->vbl_received);
38868 }
38869
38870 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38871 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38872 /* VBLANK interrupt */
38873 if (status & R128_CRTC_VBLANK_INT) {
38874 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
38875 - atomic_inc(&dev_priv->vbl_received);
38876 + atomic_inc_unchecked(&dev_priv->vbl_received);
38877 drm_handle_vblank(dev, 0);
38878 return IRQ_HANDLED;
38879 }
38880 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
38881 index 19bb7e6..de7e2a2 100644
38882 --- a/drivers/gpu/drm/r128/r128_state.c
38883 +++ b/drivers/gpu/drm/r128/r128_state.c
38884 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
38885
38886 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
38887 {
38888 - if (atomic_read(&dev_priv->idle_count) == 0)
38889 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
38890 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
38891 else
38892 - atomic_set(&dev_priv->idle_count, 0);
38893 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38894 }
38895
38896 #endif
38897 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
38898 index af85299..ed9ac8d 100644
38899 --- a/drivers/gpu/drm/radeon/mkregtable.c
38900 +++ b/drivers/gpu/drm/radeon/mkregtable.c
38901 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
38902 regex_t mask_rex;
38903 regmatch_t match[4];
38904 char buf[1024];
38905 - size_t end;
38906 + long end;
38907 int len;
38908 int done = 0;
38909 int r;
38910 unsigned o;
38911 struct offset *offset;
38912 char last_reg_s[10];
38913 - int last_reg;
38914 + unsigned long last_reg;
38915
38916 if (regcomp
38917 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
38918 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
38919 index 63398ae..669e045 100644
38920 --- a/drivers/gpu/drm/radeon/radeon_device.c
38921 +++ b/drivers/gpu/drm/radeon/radeon_device.c
38922 @@ -1105,7 +1105,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
38923 bool can_switch;
38924
38925 spin_lock(&dev->count_lock);
38926 - can_switch = (dev->open_count == 0);
38927 + can_switch = (local_read(&dev->open_count) == 0);
38928 spin_unlock(&dev->count_lock);
38929 return can_switch;
38930 }
38931 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
38932 index b369d42..8dd04eb 100644
38933 --- a/drivers/gpu/drm/radeon/radeon_drv.h
38934 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
38935 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
38936
38937 /* SW interrupt */
38938 wait_queue_head_t swi_queue;
38939 - atomic_t swi_emitted;
38940 + atomic_unchecked_t swi_emitted;
38941 int vblank_crtc;
38942 uint32_t irq_enable_reg;
38943 uint32_t r500_disp_irq_reg;
38944 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
38945 index c180df8..5fd8186 100644
38946 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
38947 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
38948 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38949 request = compat_alloc_user_space(sizeof(*request));
38950 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
38951 || __put_user(req32.param, &request->param)
38952 - || __put_user((void __user *)(unsigned long)req32.value,
38953 + || __put_user((unsigned long)req32.value,
38954 &request->value))
38955 return -EFAULT;
38956
38957 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38958 #define compat_radeon_cp_setparam NULL
38959 #endif /* X86_64 || IA64 */
38960
38961 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38962 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
38963 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
38964 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
38965 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
38966 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38967 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38968 {
38969 unsigned int nr = DRM_IOCTL_NR(cmd);
38970 - drm_ioctl_compat_t *fn = NULL;
38971 int ret;
38972
38973 if (nr < DRM_COMMAND_BASE)
38974 return drm_compat_ioctl(filp, cmd, arg);
38975
38976 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
38977 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38978 -
38979 - if (fn != NULL)
38980 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
38981 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38982 ret = (*fn) (filp, cmd, arg);
38983 - else
38984 + } else
38985 ret = drm_ioctl(filp, cmd, arg);
38986
38987 return ret;
38988 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
38989 index 8d68e97..9dcfed8 100644
38990 --- a/drivers/gpu/drm/radeon/radeon_irq.c
38991 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
38992 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
38993 unsigned int ret;
38994 RING_LOCALS;
38995
38996 - atomic_inc(&dev_priv->swi_emitted);
38997 - ret = atomic_read(&dev_priv->swi_emitted);
38998 + atomic_inc_unchecked(&dev_priv->swi_emitted);
38999 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39000
39001 BEGIN_RING(4);
39002 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39003 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39004 drm_radeon_private_t *dev_priv =
39005 (drm_radeon_private_t *) dev->dev_private;
39006
39007 - atomic_set(&dev_priv->swi_emitted, 0);
39008 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39009 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39010
39011 dev->max_vblank_count = 0x001fffff;
39012 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39013 index 4d20910..6726b6d 100644
39014 --- a/drivers/gpu/drm/radeon/radeon_state.c
39015 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39016 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39017 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39018 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39019
39020 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39021 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39022 sarea_priv->nbox * sizeof(depth_boxes[0])))
39023 return -EFAULT;
39024
39025 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39026 {
39027 drm_radeon_private_t *dev_priv = dev->dev_private;
39028 drm_radeon_getparam_t *param = data;
39029 - int value;
39030 + int value = 0;
39031
39032 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39033
39034 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39035 index 6c0ce89..57a2529 100644
39036 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39037 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39038 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39039 man->size = size >> PAGE_SHIFT;
39040 }
39041
39042 -static struct vm_operations_struct radeon_ttm_vm_ops;
39043 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39044 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39045
39046 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39047 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39048 }
39049 if (unlikely(ttm_vm_ops == NULL)) {
39050 ttm_vm_ops = vma->vm_ops;
39051 + pax_open_kernel();
39052 radeon_ttm_vm_ops = *ttm_vm_ops;
39053 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39054 + pax_close_kernel();
39055 }
39056 vma->vm_ops = &radeon_ttm_vm_ops;
39057 return 0;
39058 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39059 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39060 {
39061 #if defined(CONFIG_DEBUG_FS)
39062 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39063 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39064 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39065 + {
39066 + .name = "radeon_vram_mm",
39067 + .show = &radeon_mm_dump_table,
39068 + },
39069 + {
39070 + .name = "radeon_gtt_mm",
39071 + .show = &radeon_mm_dump_table,
39072 + },
39073 + {
39074 + .name = "ttm_page_pool",
39075 + .show = &ttm_page_alloc_debugfs,
39076 + },
39077 + {
39078 + .name = "ttm_dma_page_pool",
39079 + .show = &ttm_dma_page_alloc_debugfs,
39080 + },
39081 + };
39082 unsigned i;
39083
39084 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39085 - if (i == 0)
39086 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39087 - else
39088 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39089 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39090 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39091 - radeon_mem_types_list[i].driver_features = 0;
39092 - if (i == 0)
39093 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39094 - else
39095 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39096 -
39097 - }
39098 - /* Add ttm page pool to debugfs */
39099 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39100 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39101 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39102 - radeon_mem_types_list[i].driver_features = 0;
39103 - radeon_mem_types_list[i++].data = NULL;
39104 + pax_open_kernel();
39105 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39106 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39107 + pax_close_kernel();
39108 #ifdef CONFIG_SWIOTLB
39109 - if (swiotlb_nr_tbl()) {
39110 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39111 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39112 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39113 - radeon_mem_types_list[i].driver_features = 0;
39114 - radeon_mem_types_list[i++].data = NULL;
39115 - }
39116 + if (swiotlb_nr_tbl())
39117 + i++;
39118 #endif
39119 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39120
39121 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39122 index d8ddfb3..609de1d 100644
39123 --- a/drivers/gpu/drm/radeon/rs690.c
39124 +++ b/drivers/gpu/drm/radeon/rs690.c
39125 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39126 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39127 rdev->pm.sideport_bandwidth.full)
39128 max_bandwidth = rdev->pm.sideport_bandwidth;
39129 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39130 + read_delay_latency.full = dfixed_const(800 * 1000);
39131 read_delay_latency.full = dfixed_div(read_delay_latency,
39132 rdev->pm.igp_sideport_mclk);
39133 + a.full = dfixed_const(370);
39134 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39135 } else {
39136 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39137 rdev->pm.k8_bandwidth.full)
39138 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39139 index dbc2def..0a9f710 100644
39140 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39141 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39142 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39143 zone->glob = glob;
39144 glob->zone_kernel = zone;
39145 ret = kobject_init_and_add(
39146 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39147 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39148 if (unlikely(ret != 0)) {
39149 kobject_put(&zone->kobj);
39150 return ret;
39151 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39152 zone->glob = glob;
39153 glob->zone_dma32 = zone;
39154 ret = kobject_init_and_add(
39155 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39156 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39157 if (unlikely(ret != 0)) {
39158 kobject_put(&zone->kobj);
39159 return ret;
39160 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39161 index bd2a3b4..122d9ad 100644
39162 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39163 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39164 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
39165 static int ttm_pool_mm_shrink(struct shrinker *shrink,
39166 struct shrink_control *sc)
39167 {
39168 - static atomic_t start_pool = ATOMIC_INIT(0);
39169 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39170 unsigned i;
39171 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39172 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39173 struct ttm_page_pool *pool;
39174 int shrink_pages = sc->nr_to_scan;
39175
39176 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39177 index 97e9d61..bf23c461 100644
39178 --- a/drivers/gpu/drm/udl/udl_fb.c
39179 +++ b/drivers/gpu/drm/udl/udl_fb.c
39180 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39181 fb_deferred_io_cleanup(info);
39182 kfree(info->fbdefio);
39183 info->fbdefio = NULL;
39184 - info->fbops->fb_mmap = udl_fb_mmap;
39185 }
39186
39187 pr_warn("released /dev/fb%d user=%d count=%d\n",
39188 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39189 index 893a650..6190d3b 100644
39190 --- a/drivers/gpu/drm/via/via_drv.h
39191 +++ b/drivers/gpu/drm/via/via_drv.h
39192 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39193 typedef uint32_t maskarray_t[5];
39194
39195 typedef struct drm_via_irq {
39196 - atomic_t irq_received;
39197 + atomic_unchecked_t irq_received;
39198 uint32_t pending_mask;
39199 uint32_t enable_mask;
39200 wait_queue_head_t irq_queue;
39201 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39202 struct timeval last_vblank;
39203 int last_vblank_valid;
39204 unsigned usec_per_vblank;
39205 - atomic_t vbl_received;
39206 + atomic_unchecked_t vbl_received;
39207 drm_via_state_t hc_state;
39208 char pci_buf[VIA_PCI_BUF_SIZE];
39209 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39210 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39211 index ac98964..5dbf512 100644
39212 --- a/drivers/gpu/drm/via/via_irq.c
39213 +++ b/drivers/gpu/drm/via/via_irq.c
39214 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39215 if (crtc != 0)
39216 return 0;
39217
39218 - return atomic_read(&dev_priv->vbl_received);
39219 + return atomic_read_unchecked(&dev_priv->vbl_received);
39220 }
39221
39222 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39223 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39224
39225 status = VIA_READ(VIA_REG_INTERRUPT);
39226 if (status & VIA_IRQ_VBLANK_PENDING) {
39227 - atomic_inc(&dev_priv->vbl_received);
39228 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39229 + atomic_inc_unchecked(&dev_priv->vbl_received);
39230 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39231 do_gettimeofday(&cur_vblank);
39232 if (dev_priv->last_vblank_valid) {
39233 dev_priv->usec_per_vblank =
39234 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39235 dev_priv->last_vblank = cur_vblank;
39236 dev_priv->last_vblank_valid = 1;
39237 }
39238 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39239 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39240 DRM_DEBUG("US per vblank is: %u\n",
39241 dev_priv->usec_per_vblank);
39242 }
39243 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39244
39245 for (i = 0; i < dev_priv->num_irqs; ++i) {
39246 if (status & cur_irq->pending_mask) {
39247 - atomic_inc(&cur_irq->irq_received);
39248 + atomic_inc_unchecked(&cur_irq->irq_received);
39249 DRM_WAKEUP(&cur_irq->irq_queue);
39250 handled = 1;
39251 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39252 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39253 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39254 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39255 masks[irq][4]));
39256 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39257 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39258 } else {
39259 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39260 (((cur_irq_sequence =
39261 - atomic_read(&cur_irq->irq_received)) -
39262 + atomic_read_unchecked(&cur_irq->irq_received)) -
39263 *sequence) <= (1 << 23)));
39264 }
39265 *sequence = cur_irq_sequence;
39266 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39267 }
39268
39269 for (i = 0; i < dev_priv->num_irqs; ++i) {
39270 - atomic_set(&cur_irq->irq_received, 0);
39271 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39272 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39273 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39274 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39275 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39276 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39277 case VIA_IRQ_RELATIVE:
39278 irqwait->request.sequence +=
39279 - atomic_read(&cur_irq->irq_received);
39280 + atomic_read_unchecked(&cur_irq->irq_received);
39281 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39282 case VIA_IRQ_ABSOLUTE:
39283 break;
39284 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39285 index 13aeda7..4a952d1 100644
39286 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39287 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39288 @@ -290,7 +290,7 @@ struct vmw_private {
39289 * Fencing and IRQs.
39290 */
39291
39292 - atomic_t marker_seq;
39293 + atomic_unchecked_t marker_seq;
39294 wait_queue_head_t fence_queue;
39295 wait_queue_head_t fifo_queue;
39296 int fence_queue_waiters; /* Protected by hw_mutex */
39297 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39298 index 3eb1486..0a47ee9 100644
39299 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39300 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39301 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39302 (unsigned int) min,
39303 (unsigned int) fifo->capabilities);
39304
39305 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39306 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39307 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39308 vmw_marker_queue_init(&fifo->marker_queue);
39309 return vmw_fifo_send_fence(dev_priv, &dummy);
39310 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39311 if (reserveable)
39312 iowrite32(bytes, fifo_mem +
39313 SVGA_FIFO_RESERVED);
39314 - return fifo_mem + (next_cmd >> 2);
39315 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39316 } else {
39317 need_bounce = true;
39318 }
39319 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39320
39321 fm = vmw_fifo_reserve(dev_priv, bytes);
39322 if (unlikely(fm == NULL)) {
39323 - *seqno = atomic_read(&dev_priv->marker_seq);
39324 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39325 ret = -ENOMEM;
39326 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39327 false, 3*HZ);
39328 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39329 }
39330
39331 do {
39332 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39333 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39334 } while (*seqno == 0);
39335
39336 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39337 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39338 index c509d40..3b640c3 100644
39339 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39340 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39341 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39342 int ret;
39343
39344 num_clips = arg->num_clips;
39345 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39346 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39347
39348 if (unlikely(num_clips == 0))
39349 return 0;
39350 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39351 int ret;
39352
39353 num_clips = arg->num_clips;
39354 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39355 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39356
39357 if (unlikely(num_clips == 0))
39358 return 0;
39359 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39360 index 4640adb..e1384ed 100644
39361 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39362 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39363 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39364 * emitted. Then the fence is stale and signaled.
39365 */
39366
39367 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39368 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39369 > VMW_FENCE_WRAP);
39370
39371 return ret;
39372 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39373
39374 if (fifo_idle)
39375 down_read(&fifo_state->rwsem);
39376 - signal_seq = atomic_read(&dev_priv->marker_seq);
39377 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39378 ret = 0;
39379
39380 for (;;) {
39381 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39382 index 8a8725c2..afed796 100644
39383 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39384 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39385 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39386 while (!vmw_lag_lt(queue, us)) {
39387 spin_lock(&queue->lock);
39388 if (list_empty(&queue->head))
39389 - seqno = atomic_read(&dev_priv->marker_seq);
39390 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39391 else {
39392 marker = list_first_entry(&queue->head,
39393 struct vmw_marker, head);
39394 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39395 index 5360e5a..c2c0d26 100644
39396 --- a/drivers/gpu/host1x/drm/dc.c
39397 +++ b/drivers/gpu/host1x/drm/dc.c
39398 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39399 }
39400
39401 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39402 - dc->debugfs_files[i].data = dc;
39403 + *(void **)&dc->debugfs_files[i].data = dc;
39404
39405 err = drm_debugfs_create_files(dc->debugfs_files,
39406 ARRAY_SIZE(debugfs_files),
39407 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39408 index ee75486..65621fd 100644
39409 --- a/drivers/hid/hid-core.c
39410 +++ b/drivers/hid/hid-core.c
39411 @@ -2351,7 +2351,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39412
39413 int hid_add_device(struct hid_device *hdev)
39414 {
39415 - static atomic_t id = ATOMIC_INIT(0);
39416 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39417 int ret;
39418
39419 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39420 @@ -2385,7 +2385,7 @@ int hid_add_device(struct hid_device *hdev)
39421 /* XXX hack, any other cleaner solution after the driver core
39422 * is converted to allow more than 20 bytes as the device name? */
39423 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39424 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39425 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39426
39427 hid_debug_register(hdev, dev_name(&hdev->dev));
39428 ret = device_add(&hdev->dev);
39429 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39430 index c13fb5b..55a3802 100644
39431 --- a/drivers/hid/hid-wiimote-debug.c
39432 +++ b/drivers/hid/hid-wiimote-debug.c
39433 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39434 else if (size == 0)
39435 return -EIO;
39436
39437 - if (copy_to_user(u, buf, size))
39438 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39439 return -EFAULT;
39440
39441 *off += size;
39442 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39443 index fc307e0..2b255e8 100644
39444 --- a/drivers/hid/uhid.c
39445 +++ b/drivers/hid/uhid.c
39446 @@ -47,7 +47,7 @@ struct uhid_device {
39447 struct mutex report_lock;
39448 wait_queue_head_t report_wait;
39449 atomic_t report_done;
39450 - atomic_t report_id;
39451 + atomic_unchecked_t report_id;
39452 struct uhid_event report_buf;
39453 };
39454
39455 @@ -187,7 +187,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39456
39457 spin_lock_irqsave(&uhid->qlock, flags);
39458 ev->type = UHID_FEATURE;
39459 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39460 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39461 ev->u.feature.rnum = rnum;
39462 ev->u.feature.rtype = report_type;
39463
39464 @@ -471,7 +471,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39465 spin_lock_irqsave(&uhid->qlock, flags);
39466
39467 /* id for old report; drop it silently */
39468 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39469 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39470 goto unlock;
39471 if (atomic_read(&uhid->report_done))
39472 goto unlock;
39473 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39474 index 6de6c98..18319e9 100644
39475 --- a/drivers/hv/channel.c
39476 +++ b/drivers/hv/channel.c
39477 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39478 int ret = 0;
39479 int t;
39480
39481 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39482 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39483 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39484 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39485
39486 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39487 if (ret)
39488 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39489 index 88f4096..e50452e 100644
39490 --- a/drivers/hv/hv.c
39491 +++ b/drivers/hv/hv.c
39492 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39493 u64 output_address = (output) ? virt_to_phys(output) : 0;
39494 u32 output_address_hi = output_address >> 32;
39495 u32 output_address_lo = output_address & 0xFFFFFFFF;
39496 - void *hypercall_page = hv_context.hypercall_page;
39497 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39498
39499 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39500 "=a"(hv_status_lo) : "d" (control_hi),
39501 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39502 index deb5c25..ed2d4fd 100644
39503 --- a/drivers/hv/hv_balloon.c
39504 +++ b/drivers/hv/hv_balloon.c
39505 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39506
39507 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39508 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39509 -static atomic_t trans_id = ATOMIC_INIT(0);
39510 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39511
39512 static int dm_ring_size = (5 * PAGE_SIZE);
39513
39514 @@ -825,7 +825,7 @@ static void hot_add_req(struct work_struct *dummy)
39515 memset(&resp, 0, sizeof(struct dm_hot_add_response));
39516 resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
39517 resp.hdr.size = sizeof(struct dm_hot_add_response);
39518 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39519 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39520
39521 #ifdef CONFIG_MEMORY_HOTPLUG
39522 pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
39523 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39524 memset(&status, 0, sizeof(struct dm_status));
39525 status.hdr.type = DM_STATUS_REPORT;
39526 status.hdr.size = sizeof(struct dm_status);
39527 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39528 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39529
39530 /*
39531 * The host expects the guest to report free memory.
39532 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39533 * send the status. This can happen if we were interrupted
39534 * after we picked our transaction ID.
39535 */
39536 - if (status.hdr.trans_id != atomic_read(&trans_id))
39537 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39538 return;
39539
39540 vmbus_sendpacket(dm->dev->channel, &status,
39541 @@ -1081,7 +1081,7 @@ static void balloon_up(struct work_struct *dummy)
39542 bl_resp = (struct dm_balloon_response *)send_buffer;
39543 memset(send_buffer, 0, PAGE_SIZE);
39544 bl_resp->hdr.type = DM_BALLOON_RESPONSE;
39545 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39546 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39547 bl_resp->hdr.size = sizeof(struct dm_balloon_response);
39548 bl_resp->more_pages = 1;
39549
39550 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39551
39552 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39553 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39554 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39555 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39556 resp.hdr.size = sizeof(struct dm_unballoon_response);
39557
39558 vmbus_sendpacket(dm_device.dev->channel, &resp,
39559 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39560 memset(&version_req, 0, sizeof(struct dm_version_request));
39561 version_req.hdr.type = DM_VERSION_REQUEST;
39562 version_req.hdr.size = sizeof(struct dm_version_request);
39563 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39564 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39565 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39566 version_req.is_last_attempt = 1;
39567
39568 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39569 memset(&version_req, 0, sizeof(struct dm_version_request));
39570 version_req.hdr.type = DM_VERSION_REQUEST;
39571 version_req.hdr.size = sizeof(struct dm_version_request);
39572 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39573 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39574 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39575 version_req.is_last_attempt = 0;
39576
39577 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39578 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39579 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39580 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39581 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39582 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39583
39584 cap_msg.caps.cap_bits.balloon = 1;
39585 cap_msg.caps.cap_bits.hot_add = 1;
39586 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39587 index d84918f..7f38f9f 100644
39588 --- a/drivers/hv/hyperv_vmbus.h
39589 +++ b/drivers/hv/hyperv_vmbus.h
39590 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39591 struct vmbus_connection {
39592 enum vmbus_connect_state conn_state;
39593
39594 - atomic_t next_gpadl_handle;
39595 + atomic_unchecked_t next_gpadl_handle;
39596
39597 /*
39598 * Represents channel interrupts. Each bit position represents a
39599 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39600 index e8e071f..5b4b245 100644
39601 --- a/drivers/hv/vmbus_drv.c
39602 +++ b/drivers/hv/vmbus_drv.c
39603 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39604 {
39605 int ret = 0;
39606
39607 - static atomic_t device_num = ATOMIC_INIT(0);
39608 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39609
39610 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39611 - atomic_inc_return(&device_num));
39612 + atomic_inc_return_unchecked(&device_num));
39613
39614 child_device_obj->device.bus = &hv_bus;
39615 child_device_obj->device.parent = &hv_acpi_dev->dev;
39616 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39617 index 6351aba..dc4aaf4 100644
39618 --- a/drivers/hwmon/acpi_power_meter.c
39619 +++ b/drivers/hwmon/acpi_power_meter.c
39620 @@ -117,7 +117,7 @@ struct sensor_template {
39621 struct device_attribute *devattr,
39622 const char *buf, size_t count);
39623 int index;
39624 -};
39625 +} __do_const;
39626
39627 /* Averaging interval */
39628 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39629 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39630 struct sensor_template *attrs)
39631 {
39632 struct device *dev = &resource->acpi_dev->dev;
39633 - struct sensor_device_attribute *sensors =
39634 + sensor_device_attribute_no_const *sensors =
39635 &resource->sensors[resource->num_sensors];
39636 int res = 0;
39637
39638 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39639 index 62c2e32..8f2859a 100644
39640 --- a/drivers/hwmon/applesmc.c
39641 +++ b/drivers/hwmon/applesmc.c
39642 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39643 {
39644 struct applesmc_node_group *grp;
39645 struct applesmc_dev_attr *node;
39646 - struct attribute *attr;
39647 + attribute_no_const *attr;
39648 int ret, i;
39649
39650 for (grp = groups; grp->format; grp++) {
39651 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
39652 index b25c643..a13460d 100644
39653 --- a/drivers/hwmon/asus_atk0110.c
39654 +++ b/drivers/hwmon/asus_atk0110.c
39655 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
39656 struct atk_sensor_data {
39657 struct list_head list;
39658 struct atk_data *data;
39659 - struct device_attribute label_attr;
39660 - struct device_attribute input_attr;
39661 - struct device_attribute limit1_attr;
39662 - struct device_attribute limit2_attr;
39663 + device_attribute_no_const label_attr;
39664 + device_attribute_no_const input_attr;
39665 + device_attribute_no_const limit1_attr;
39666 + device_attribute_no_const limit2_attr;
39667 char label_attr_name[ATTR_NAME_SIZE];
39668 char input_attr_name[ATTR_NAME_SIZE];
39669 char limit1_attr_name[ATTR_NAME_SIZE];
39670 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
39671 static struct device_attribute atk_name_attr =
39672 __ATTR(name, 0444, atk_name_show, NULL);
39673
39674 -static void atk_init_attribute(struct device_attribute *attr, char *name,
39675 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
39676 sysfs_show_func show)
39677 {
39678 sysfs_attr_init(&attr->attr);
39679 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
39680 index 2e5e2dc..5208b31 100644
39681 --- a/drivers/hwmon/coretemp.c
39682 +++ b/drivers/hwmon/coretemp.c
39683 @@ -785,7 +785,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
39684 return NOTIFY_OK;
39685 }
39686
39687 -static struct notifier_block coretemp_cpu_notifier __refdata = {
39688 +static struct notifier_block coretemp_cpu_notifier = {
39689 .notifier_call = coretemp_cpu_callback,
39690 };
39691
39692 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
39693 index 1429f6e..ee03d59 100644
39694 --- a/drivers/hwmon/ibmaem.c
39695 +++ b/drivers/hwmon/ibmaem.c
39696 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
39697 struct aem_rw_sensor_template *rw)
39698 {
39699 struct device *dev = &data->pdev->dev;
39700 - struct sensor_device_attribute *sensors = data->sensors;
39701 + sensor_device_attribute_no_const *sensors = data->sensors;
39702 int err;
39703
39704 /* Set up read-only sensors */
39705 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
39706 index 708081b..fe2d4ab 100644
39707 --- a/drivers/hwmon/iio_hwmon.c
39708 +++ b/drivers/hwmon/iio_hwmon.c
39709 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
39710 {
39711 struct device *dev = &pdev->dev;
39712 struct iio_hwmon_state *st;
39713 - struct sensor_device_attribute *a;
39714 + sensor_device_attribute_no_const *a;
39715 int ret, i;
39716 int in_i = 1, temp_i = 1, curr_i = 1;
39717 enum iio_chan_type type;
39718 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
39719 index 9add6092..ee7ba3f 100644
39720 --- a/drivers/hwmon/pmbus/pmbus_core.c
39721 +++ b/drivers/hwmon/pmbus/pmbus_core.c
39722 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
39723 return 0;
39724 }
39725
39726 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39727 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
39728 const char *name,
39729 umode_t mode,
39730 ssize_t (*show)(struct device *dev,
39731 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39732 dev_attr->store = store;
39733 }
39734
39735 -static void pmbus_attr_init(struct sensor_device_attribute *a,
39736 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
39737 const char *name,
39738 umode_t mode,
39739 ssize_t (*show)(struct device *dev,
39740 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
39741 u16 reg, u8 mask)
39742 {
39743 struct pmbus_boolean *boolean;
39744 - struct sensor_device_attribute *a;
39745 + sensor_device_attribute_no_const *a;
39746
39747 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
39748 if (!boolean)
39749 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
39750 bool update, bool readonly)
39751 {
39752 struct pmbus_sensor *sensor;
39753 - struct device_attribute *a;
39754 + device_attribute_no_const *a;
39755
39756 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
39757 if (!sensor)
39758 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
39759 const char *lstring, int index)
39760 {
39761 struct pmbus_label *label;
39762 - struct device_attribute *a;
39763 + device_attribute_no_const *a;
39764
39765 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
39766 if (!label)
39767 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
39768 index 2507f90..1645765 100644
39769 --- a/drivers/hwmon/sht15.c
39770 +++ b/drivers/hwmon/sht15.c
39771 @@ -169,7 +169,7 @@ struct sht15_data {
39772 int supply_uv;
39773 bool supply_uv_valid;
39774 struct work_struct update_supply_work;
39775 - atomic_t interrupt_handled;
39776 + atomic_unchecked_t interrupt_handled;
39777 };
39778
39779 /**
39780 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
39781 ret = gpio_direction_input(data->pdata->gpio_data);
39782 if (ret)
39783 return ret;
39784 - atomic_set(&data->interrupt_handled, 0);
39785 + atomic_set_unchecked(&data->interrupt_handled, 0);
39786
39787 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39788 if (gpio_get_value(data->pdata->gpio_data) == 0) {
39789 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
39790 /* Only relevant if the interrupt hasn't occurred. */
39791 - if (!atomic_read(&data->interrupt_handled))
39792 + if (!atomic_read_unchecked(&data->interrupt_handled))
39793 schedule_work(&data->read_work);
39794 }
39795 ret = wait_event_timeout(data->wait_queue,
39796 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
39797
39798 /* First disable the interrupt */
39799 disable_irq_nosync(irq);
39800 - atomic_inc(&data->interrupt_handled);
39801 + atomic_inc_unchecked(&data->interrupt_handled);
39802 /* Then schedule a reading work struct */
39803 if (data->state != SHT15_READING_NOTHING)
39804 schedule_work(&data->read_work);
39805 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
39806 * If not, then start the interrupt again - care here as could
39807 * have gone low in meantime so verify it hasn't!
39808 */
39809 - atomic_set(&data->interrupt_handled, 0);
39810 + atomic_set_unchecked(&data->interrupt_handled, 0);
39811 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39812 /* If still not occurred or another handler was scheduled */
39813 if (gpio_get_value(data->pdata->gpio_data)
39814 - || atomic_read(&data->interrupt_handled))
39815 + || atomic_read_unchecked(&data->interrupt_handled))
39816 return;
39817 }
39818
39819 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
39820 index 38944e9..ae9e5ed 100644
39821 --- a/drivers/hwmon/via-cputemp.c
39822 +++ b/drivers/hwmon/via-cputemp.c
39823 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
39824 return NOTIFY_OK;
39825 }
39826
39827 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
39828 +static struct notifier_block via_cputemp_cpu_notifier = {
39829 .notifier_call = via_cputemp_cpu_callback,
39830 };
39831
39832 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
39833 index 07f01ac..d79ad3d 100644
39834 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
39835 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
39836 @@ -43,7 +43,7 @@
39837 extern struct i2c_adapter amd756_smbus;
39838
39839 static struct i2c_adapter *s4882_adapter;
39840 -static struct i2c_algorithm *s4882_algo;
39841 +static i2c_algorithm_no_const *s4882_algo;
39842
39843 /* Wrapper access functions for multiplexed SMBus */
39844 static DEFINE_MUTEX(amd756_lock);
39845 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
39846 index 2ca268d..c6acbdf 100644
39847 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
39848 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
39849 @@ -41,7 +41,7 @@
39850 extern struct i2c_adapter *nforce2_smbus;
39851
39852 static struct i2c_adapter *s4985_adapter;
39853 -static struct i2c_algorithm *s4985_algo;
39854 +static i2c_algorithm_no_const *s4985_algo;
39855
39856 /* Wrapper access functions for multiplexed SMBus */
39857 static DEFINE_MUTEX(nforce2_lock);
39858 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
39859 index c3ccdea..5b3dc1a 100644
39860 --- a/drivers/i2c/i2c-dev.c
39861 +++ b/drivers/i2c/i2c-dev.c
39862 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
39863 break;
39864 }
39865
39866 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
39867 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
39868 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
39869 if (IS_ERR(rdwr_pa[i].buf)) {
39870 res = PTR_ERR(rdwr_pa[i].buf);
39871 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
39872 index 0b510ba..4fbb5085 100644
39873 --- a/drivers/ide/ide-cd.c
39874 +++ b/drivers/ide/ide-cd.c
39875 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
39876 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
39877 if ((unsigned long)buf & alignment
39878 || blk_rq_bytes(rq) & q->dma_pad_mask
39879 - || object_is_on_stack(buf))
39880 + || object_starts_on_stack(buf))
39881 drive->dma = 0;
39882 }
39883 }
39884 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
39885 index e145931..08bfc59 100644
39886 --- a/drivers/iio/industrialio-core.c
39887 +++ b/drivers/iio/industrialio-core.c
39888 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
39889 }
39890
39891 static
39892 -int __iio_device_attr_init(struct device_attribute *dev_attr,
39893 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
39894 const char *postfix,
39895 struct iio_chan_spec const *chan,
39896 ssize_t (*readfunc)(struct device *dev,
39897 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
39898 index 784b97c..c9ceadf 100644
39899 --- a/drivers/infiniband/core/cm.c
39900 +++ b/drivers/infiniband/core/cm.c
39901 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
39902
39903 struct cm_counter_group {
39904 struct kobject obj;
39905 - atomic_long_t counter[CM_ATTR_COUNT];
39906 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
39907 };
39908
39909 struct cm_counter_attribute {
39910 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
39911 struct ib_mad_send_buf *msg = NULL;
39912 int ret;
39913
39914 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39915 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39916 counter[CM_REQ_COUNTER]);
39917
39918 /* Quick state check to discard duplicate REQs. */
39919 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
39920 if (!cm_id_priv)
39921 return;
39922
39923 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39924 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39925 counter[CM_REP_COUNTER]);
39926 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
39927 if (ret)
39928 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
39929 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
39930 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
39931 spin_unlock_irq(&cm_id_priv->lock);
39932 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39933 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39934 counter[CM_RTU_COUNTER]);
39935 goto out;
39936 }
39937 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
39938 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
39939 dreq_msg->local_comm_id);
39940 if (!cm_id_priv) {
39941 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39942 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39943 counter[CM_DREQ_COUNTER]);
39944 cm_issue_drep(work->port, work->mad_recv_wc);
39945 return -EINVAL;
39946 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
39947 case IB_CM_MRA_REP_RCVD:
39948 break;
39949 case IB_CM_TIMEWAIT:
39950 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39951 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39952 counter[CM_DREQ_COUNTER]);
39953 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
39954 goto unlock;
39955 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
39956 cm_free_msg(msg);
39957 goto deref;
39958 case IB_CM_DREQ_RCVD:
39959 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39960 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39961 counter[CM_DREQ_COUNTER]);
39962 goto unlock;
39963 default:
39964 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
39965 ib_modify_mad(cm_id_priv->av.port->mad_agent,
39966 cm_id_priv->msg, timeout)) {
39967 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
39968 - atomic_long_inc(&work->port->
39969 + atomic_long_inc_unchecked(&work->port->
39970 counter_group[CM_RECV_DUPLICATES].
39971 counter[CM_MRA_COUNTER]);
39972 goto out;
39973 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
39974 break;
39975 case IB_CM_MRA_REQ_RCVD:
39976 case IB_CM_MRA_REP_RCVD:
39977 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39978 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39979 counter[CM_MRA_COUNTER]);
39980 /* fall through */
39981 default:
39982 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
39983 case IB_CM_LAP_IDLE:
39984 break;
39985 case IB_CM_MRA_LAP_SENT:
39986 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39987 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39988 counter[CM_LAP_COUNTER]);
39989 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
39990 goto unlock;
39991 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
39992 cm_free_msg(msg);
39993 goto deref;
39994 case IB_CM_LAP_RCVD:
39995 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39996 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39997 counter[CM_LAP_COUNTER]);
39998 goto unlock;
39999 default:
40000 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40001 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40002 if (cur_cm_id_priv) {
40003 spin_unlock_irq(&cm.lock);
40004 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40005 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40006 counter[CM_SIDR_REQ_COUNTER]);
40007 goto out; /* Duplicate message. */
40008 }
40009 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40010 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40011 msg->retries = 1;
40012
40013 - atomic_long_add(1 + msg->retries,
40014 + atomic_long_add_unchecked(1 + msg->retries,
40015 &port->counter_group[CM_XMIT].counter[attr_index]);
40016 if (msg->retries)
40017 - atomic_long_add(msg->retries,
40018 + atomic_long_add_unchecked(msg->retries,
40019 &port->counter_group[CM_XMIT_RETRIES].
40020 counter[attr_index]);
40021
40022 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40023 }
40024
40025 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40026 - atomic_long_inc(&port->counter_group[CM_RECV].
40027 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40028 counter[attr_id - CM_ATTR_ID_OFFSET]);
40029
40030 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40031 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40032 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40033
40034 return sprintf(buf, "%ld\n",
40035 - atomic_long_read(&group->counter[cm_attr->index]));
40036 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40037 }
40038
40039 static const struct sysfs_ops cm_counter_ops = {
40040 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40041 index 9f5ad7c..588cd84 100644
40042 --- a/drivers/infiniband/core/fmr_pool.c
40043 +++ b/drivers/infiniband/core/fmr_pool.c
40044 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40045
40046 struct task_struct *thread;
40047
40048 - atomic_t req_ser;
40049 - atomic_t flush_ser;
40050 + atomic_unchecked_t req_ser;
40051 + atomic_unchecked_t flush_ser;
40052
40053 wait_queue_head_t force_wait;
40054 };
40055 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40056 struct ib_fmr_pool *pool = pool_ptr;
40057
40058 do {
40059 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40060 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40061 ib_fmr_batch_release(pool);
40062
40063 - atomic_inc(&pool->flush_ser);
40064 + atomic_inc_unchecked(&pool->flush_ser);
40065 wake_up_interruptible(&pool->force_wait);
40066
40067 if (pool->flush_function)
40068 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40069 }
40070
40071 set_current_state(TASK_INTERRUPTIBLE);
40072 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40073 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40074 !kthread_should_stop())
40075 schedule();
40076 __set_current_state(TASK_RUNNING);
40077 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40078 pool->dirty_watermark = params->dirty_watermark;
40079 pool->dirty_len = 0;
40080 spin_lock_init(&pool->pool_lock);
40081 - atomic_set(&pool->req_ser, 0);
40082 - atomic_set(&pool->flush_ser, 0);
40083 + atomic_set_unchecked(&pool->req_ser, 0);
40084 + atomic_set_unchecked(&pool->flush_ser, 0);
40085 init_waitqueue_head(&pool->force_wait);
40086
40087 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40088 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40089 }
40090 spin_unlock_irq(&pool->pool_lock);
40091
40092 - serial = atomic_inc_return(&pool->req_ser);
40093 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40094 wake_up_process(pool->thread);
40095
40096 if (wait_event_interruptible(pool->force_wait,
40097 - atomic_read(&pool->flush_ser) - serial >= 0))
40098 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40099 return -EINTR;
40100
40101 return 0;
40102 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40103 } else {
40104 list_add_tail(&fmr->list, &pool->dirty_list);
40105 if (++pool->dirty_len >= pool->dirty_watermark) {
40106 - atomic_inc(&pool->req_ser);
40107 + atomic_inc_unchecked(&pool->req_ser);
40108 wake_up_process(pool->thread);
40109 }
40110 }
40111 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40112 index 4cb8eb2..146bf60 100644
40113 --- a/drivers/infiniband/hw/cxgb4/mem.c
40114 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40115 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40116 int err;
40117 struct fw_ri_tpte tpt;
40118 u32 stag_idx;
40119 - static atomic_t key;
40120 + static atomic_unchecked_t key;
40121
40122 if (c4iw_fatal_error(rdev))
40123 return -EIO;
40124 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40125 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40126 rdev->stats.stag.max = rdev->stats.stag.cur;
40127 mutex_unlock(&rdev->stats.lock);
40128 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40129 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40130 }
40131 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40132 __func__, stag_state, type, pdid, stag_idx);
40133 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40134 index 79b3dbc..96e5fcc 100644
40135 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40136 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40137 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40138 struct ib_atomic_eth *ateth;
40139 struct ipath_ack_entry *e;
40140 u64 vaddr;
40141 - atomic64_t *maddr;
40142 + atomic64_unchecked_t *maddr;
40143 u64 sdata;
40144 u32 rkey;
40145 u8 next;
40146 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40147 IB_ACCESS_REMOTE_ATOMIC)))
40148 goto nack_acc_unlck;
40149 /* Perform atomic OP and save result. */
40150 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40151 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40152 sdata = be64_to_cpu(ateth->swap_data);
40153 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40154 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40155 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40156 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40157 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40158 be64_to_cpu(ateth->compare_data),
40159 sdata);
40160 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40161 index 1f95bba..9530f87 100644
40162 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40163 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40164 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40165 unsigned long flags;
40166 struct ib_wc wc;
40167 u64 sdata;
40168 - atomic64_t *maddr;
40169 + atomic64_unchecked_t *maddr;
40170 enum ib_wc_status send_status;
40171
40172 /*
40173 @@ -382,11 +382,11 @@ again:
40174 IB_ACCESS_REMOTE_ATOMIC)))
40175 goto acc_err;
40176 /* Perform atomic OP and save result. */
40177 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40178 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40179 sdata = wqe->wr.wr.atomic.compare_add;
40180 *(u64 *) sqp->s_sge.sge.vaddr =
40181 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40182 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40183 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40184 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40185 sdata, wqe->wr.wr.atomic.swap);
40186 goto send_comp;
40187 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40188 index f2a3f48..673ec79 100644
40189 --- a/drivers/infiniband/hw/mlx4/mad.c
40190 +++ b/drivers/infiniband/hw/mlx4/mad.c
40191 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40192
40193 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40194 {
40195 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40196 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40197 cpu_to_be64(0xff00000000000000LL);
40198 }
40199
40200 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40201 index 25b2cdf..099ff97 100644
40202 --- a/drivers/infiniband/hw/mlx4/mcg.c
40203 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40204 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40205 {
40206 char name[20];
40207
40208 - atomic_set(&ctx->tid, 0);
40209 + atomic_set_unchecked(&ctx->tid, 0);
40210 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40211 ctx->mcg_wq = create_singlethread_workqueue(name);
40212 if (!ctx->mcg_wq)
40213 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40214 index f61ec26..ebf72cf 100644
40215 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40216 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40217 @@ -398,7 +398,7 @@ struct mlx4_ib_demux_ctx {
40218 struct list_head mcg_mgid0_list;
40219 struct workqueue_struct *mcg_wq;
40220 struct mlx4_ib_demux_pv_ctx **tun;
40221 - atomic_t tid;
40222 + atomic_unchecked_t tid;
40223 int flushing; /* flushing the work queue */
40224 };
40225
40226 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40227 index 9d3e5c1..d9afe4a 100644
40228 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40229 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40230 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40231 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40232 }
40233
40234 -int mthca_QUERY_FW(struct mthca_dev *dev)
40235 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40236 {
40237 struct mthca_mailbox *mailbox;
40238 u32 *outbox;
40239 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40240 index ed9a989..e0c5871 100644
40241 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40242 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40243 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40244 return key;
40245 }
40246
40247 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40248 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40249 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40250 {
40251 struct mthca_mailbox *mailbox;
40252 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40253 index 4291410..d2ab1fb 100644
40254 --- a/drivers/infiniband/hw/nes/nes.c
40255 +++ b/drivers/infiniband/hw/nes/nes.c
40256 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40257 LIST_HEAD(nes_adapter_list);
40258 static LIST_HEAD(nes_dev_list);
40259
40260 -atomic_t qps_destroyed;
40261 +atomic_unchecked_t qps_destroyed;
40262
40263 static unsigned int ee_flsh_adapter;
40264 static unsigned int sysfs_nonidx_addr;
40265 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40266 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40267 struct nes_adapter *nesadapter = nesdev->nesadapter;
40268
40269 - atomic_inc(&qps_destroyed);
40270 + atomic_inc_unchecked(&qps_destroyed);
40271
40272 /* Free the control structures */
40273
40274 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40275 index 33cc589..3bd6538 100644
40276 --- a/drivers/infiniband/hw/nes/nes.h
40277 +++ b/drivers/infiniband/hw/nes/nes.h
40278 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40279 extern unsigned int wqm_quanta;
40280 extern struct list_head nes_adapter_list;
40281
40282 -extern atomic_t cm_connects;
40283 -extern atomic_t cm_accepts;
40284 -extern atomic_t cm_disconnects;
40285 -extern atomic_t cm_closes;
40286 -extern atomic_t cm_connecteds;
40287 -extern atomic_t cm_connect_reqs;
40288 -extern atomic_t cm_rejects;
40289 -extern atomic_t mod_qp_timouts;
40290 -extern atomic_t qps_created;
40291 -extern atomic_t qps_destroyed;
40292 -extern atomic_t sw_qps_destroyed;
40293 +extern atomic_unchecked_t cm_connects;
40294 +extern atomic_unchecked_t cm_accepts;
40295 +extern atomic_unchecked_t cm_disconnects;
40296 +extern atomic_unchecked_t cm_closes;
40297 +extern atomic_unchecked_t cm_connecteds;
40298 +extern atomic_unchecked_t cm_connect_reqs;
40299 +extern atomic_unchecked_t cm_rejects;
40300 +extern atomic_unchecked_t mod_qp_timouts;
40301 +extern atomic_unchecked_t qps_created;
40302 +extern atomic_unchecked_t qps_destroyed;
40303 +extern atomic_unchecked_t sw_qps_destroyed;
40304 extern u32 mh_detected;
40305 extern u32 mh_pauses_sent;
40306 extern u32 cm_packets_sent;
40307 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40308 extern u32 cm_packets_received;
40309 extern u32 cm_packets_dropped;
40310 extern u32 cm_packets_retrans;
40311 -extern atomic_t cm_listens_created;
40312 -extern atomic_t cm_listens_destroyed;
40313 +extern atomic_unchecked_t cm_listens_created;
40314 +extern atomic_unchecked_t cm_listens_destroyed;
40315 extern u32 cm_backlog_drops;
40316 -extern atomic_t cm_loopbacks;
40317 -extern atomic_t cm_nodes_created;
40318 -extern atomic_t cm_nodes_destroyed;
40319 -extern atomic_t cm_accel_dropped_pkts;
40320 -extern atomic_t cm_resets_recvd;
40321 -extern atomic_t pau_qps_created;
40322 -extern atomic_t pau_qps_destroyed;
40323 +extern atomic_unchecked_t cm_loopbacks;
40324 +extern atomic_unchecked_t cm_nodes_created;
40325 +extern atomic_unchecked_t cm_nodes_destroyed;
40326 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40327 +extern atomic_unchecked_t cm_resets_recvd;
40328 +extern atomic_unchecked_t pau_qps_created;
40329 +extern atomic_unchecked_t pau_qps_destroyed;
40330
40331 extern u32 int_mod_timer_init;
40332 extern u32 int_mod_cq_depth_256;
40333 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40334 index 24b9f1a..00fd004 100644
40335 --- a/drivers/infiniband/hw/nes/nes_cm.c
40336 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40337 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40338 u32 cm_packets_retrans;
40339 u32 cm_packets_created;
40340 u32 cm_packets_received;
40341 -atomic_t cm_listens_created;
40342 -atomic_t cm_listens_destroyed;
40343 +atomic_unchecked_t cm_listens_created;
40344 +atomic_unchecked_t cm_listens_destroyed;
40345 u32 cm_backlog_drops;
40346 -atomic_t cm_loopbacks;
40347 -atomic_t cm_nodes_created;
40348 -atomic_t cm_nodes_destroyed;
40349 -atomic_t cm_accel_dropped_pkts;
40350 -atomic_t cm_resets_recvd;
40351 +atomic_unchecked_t cm_loopbacks;
40352 +atomic_unchecked_t cm_nodes_created;
40353 +atomic_unchecked_t cm_nodes_destroyed;
40354 +atomic_unchecked_t cm_accel_dropped_pkts;
40355 +atomic_unchecked_t cm_resets_recvd;
40356
40357 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40358 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40359 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40360
40361 static struct nes_cm_core *g_cm_core;
40362
40363 -atomic_t cm_connects;
40364 -atomic_t cm_accepts;
40365 -atomic_t cm_disconnects;
40366 -atomic_t cm_closes;
40367 -atomic_t cm_connecteds;
40368 -atomic_t cm_connect_reqs;
40369 -atomic_t cm_rejects;
40370 +atomic_unchecked_t cm_connects;
40371 +atomic_unchecked_t cm_accepts;
40372 +atomic_unchecked_t cm_disconnects;
40373 +atomic_unchecked_t cm_closes;
40374 +atomic_unchecked_t cm_connecteds;
40375 +atomic_unchecked_t cm_connect_reqs;
40376 +atomic_unchecked_t cm_rejects;
40377
40378 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40379 {
40380 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40381 kfree(listener);
40382 listener = NULL;
40383 ret = 0;
40384 - atomic_inc(&cm_listens_destroyed);
40385 + atomic_inc_unchecked(&cm_listens_destroyed);
40386 } else {
40387 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40388 }
40389 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40390 cm_node->rem_mac);
40391
40392 add_hte_node(cm_core, cm_node);
40393 - atomic_inc(&cm_nodes_created);
40394 + atomic_inc_unchecked(&cm_nodes_created);
40395
40396 return cm_node;
40397 }
40398 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40399 }
40400
40401 atomic_dec(&cm_core->node_cnt);
40402 - atomic_inc(&cm_nodes_destroyed);
40403 + atomic_inc_unchecked(&cm_nodes_destroyed);
40404 nesqp = cm_node->nesqp;
40405 if (nesqp) {
40406 nesqp->cm_node = NULL;
40407 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40408
40409 static void drop_packet(struct sk_buff *skb)
40410 {
40411 - atomic_inc(&cm_accel_dropped_pkts);
40412 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40413 dev_kfree_skb_any(skb);
40414 }
40415
40416 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40417 {
40418
40419 int reset = 0; /* whether to send reset in case of err.. */
40420 - atomic_inc(&cm_resets_recvd);
40421 + atomic_inc_unchecked(&cm_resets_recvd);
40422 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40423 " refcnt=%d\n", cm_node, cm_node->state,
40424 atomic_read(&cm_node->ref_count));
40425 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40426 rem_ref_cm_node(cm_node->cm_core, cm_node);
40427 return NULL;
40428 }
40429 - atomic_inc(&cm_loopbacks);
40430 + atomic_inc_unchecked(&cm_loopbacks);
40431 loopbackremotenode->loopbackpartner = cm_node;
40432 loopbackremotenode->tcp_cntxt.rcv_wscale =
40433 NES_CM_DEFAULT_RCV_WND_SCALE;
40434 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40435 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40436 else {
40437 rem_ref_cm_node(cm_core, cm_node);
40438 - atomic_inc(&cm_accel_dropped_pkts);
40439 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40440 dev_kfree_skb_any(skb);
40441 }
40442 break;
40443 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40444
40445 if ((cm_id) && (cm_id->event_handler)) {
40446 if (issue_disconn) {
40447 - atomic_inc(&cm_disconnects);
40448 + atomic_inc_unchecked(&cm_disconnects);
40449 cm_event.event = IW_CM_EVENT_DISCONNECT;
40450 cm_event.status = disconn_status;
40451 cm_event.local_addr = cm_id->local_addr;
40452 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40453 }
40454
40455 if (issue_close) {
40456 - atomic_inc(&cm_closes);
40457 + atomic_inc_unchecked(&cm_closes);
40458 nes_disconnect(nesqp, 1);
40459
40460 cm_id->provider_data = nesqp;
40461 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40462
40463 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40464 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40465 - atomic_inc(&cm_accepts);
40466 + atomic_inc_unchecked(&cm_accepts);
40467
40468 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40469 netdev_refcnt_read(nesvnic->netdev));
40470 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40471 struct nes_cm_core *cm_core;
40472 u8 *start_buff;
40473
40474 - atomic_inc(&cm_rejects);
40475 + atomic_inc_unchecked(&cm_rejects);
40476 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40477 loopback = cm_node->loopbackpartner;
40478 cm_core = cm_node->cm_core;
40479 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40480 ntohl(cm_id->local_addr.sin_addr.s_addr),
40481 ntohs(cm_id->local_addr.sin_port));
40482
40483 - atomic_inc(&cm_connects);
40484 + atomic_inc_unchecked(&cm_connects);
40485 nesqp->active_conn = 1;
40486
40487 /* cache the cm_id in the qp */
40488 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40489 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40490 return err;
40491 }
40492 - atomic_inc(&cm_listens_created);
40493 + atomic_inc_unchecked(&cm_listens_created);
40494 }
40495
40496 cm_id->add_ref(cm_id);
40497 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40498
40499 if (nesqp->destroyed)
40500 return;
40501 - atomic_inc(&cm_connecteds);
40502 + atomic_inc_unchecked(&cm_connecteds);
40503 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40504 " local port 0x%04X. jiffies = %lu.\n",
40505 nesqp->hwqp.qp_id,
40506 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40507
40508 cm_id->add_ref(cm_id);
40509 ret = cm_id->event_handler(cm_id, &cm_event);
40510 - atomic_inc(&cm_closes);
40511 + atomic_inc_unchecked(&cm_closes);
40512 cm_event.event = IW_CM_EVENT_CLOSE;
40513 cm_event.status = 0;
40514 cm_event.provider_data = cm_id->provider_data;
40515 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40516 return;
40517 cm_id = cm_node->cm_id;
40518
40519 - atomic_inc(&cm_connect_reqs);
40520 + atomic_inc_unchecked(&cm_connect_reqs);
40521 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40522 cm_node, cm_id, jiffies);
40523
40524 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40525 return;
40526 cm_id = cm_node->cm_id;
40527
40528 - atomic_inc(&cm_connect_reqs);
40529 + atomic_inc_unchecked(&cm_connect_reqs);
40530 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40531 cm_node, cm_id, jiffies);
40532
40533 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40534 index 4166452..fc952c3 100644
40535 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40536 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40537 @@ -40,8 +40,8 @@
40538 #include "nes.h"
40539 #include "nes_mgt.h"
40540
40541 -atomic_t pau_qps_created;
40542 -atomic_t pau_qps_destroyed;
40543 +atomic_unchecked_t pau_qps_created;
40544 +atomic_unchecked_t pau_qps_destroyed;
40545
40546 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40547 {
40548 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40549 {
40550 struct sk_buff *skb;
40551 unsigned long flags;
40552 - atomic_inc(&pau_qps_destroyed);
40553 + atomic_inc_unchecked(&pau_qps_destroyed);
40554
40555 /* Free packets that have not yet been forwarded */
40556 /* Lock is acquired by skb_dequeue when removing the skb */
40557 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40558 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40559 skb_queue_head_init(&nesqp->pau_list);
40560 spin_lock_init(&nesqp->pau_lock);
40561 - atomic_inc(&pau_qps_created);
40562 + atomic_inc_unchecked(&pau_qps_created);
40563 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40564 }
40565
40566 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40567 index 49eb511..a774366 100644
40568 --- a/drivers/infiniband/hw/nes/nes_nic.c
40569 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40570 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40571 target_stat_values[++index] = mh_detected;
40572 target_stat_values[++index] = mh_pauses_sent;
40573 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40574 - target_stat_values[++index] = atomic_read(&cm_connects);
40575 - target_stat_values[++index] = atomic_read(&cm_accepts);
40576 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40577 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40578 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40579 - target_stat_values[++index] = atomic_read(&cm_rejects);
40580 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40581 - target_stat_values[++index] = atomic_read(&qps_created);
40582 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40583 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40584 - target_stat_values[++index] = atomic_read(&cm_closes);
40585 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40586 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40587 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40588 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40589 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40590 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40591 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40592 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40593 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40594 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40595 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40596 target_stat_values[++index] = cm_packets_sent;
40597 target_stat_values[++index] = cm_packets_bounced;
40598 target_stat_values[++index] = cm_packets_created;
40599 target_stat_values[++index] = cm_packets_received;
40600 target_stat_values[++index] = cm_packets_dropped;
40601 target_stat_values[++index] = cm_packets_retrans;
40602 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40603 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40604 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40605 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40606 target_stat_values[++index] = cm_backlog_drops;
40607 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40608 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40609 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40610 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40611 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40612 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40613 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40614 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40615 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40616 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40617 target_stat_values[++index] = nesadapter->free_4kpbl;
40618 target_stat_values[++index] = nesadapter->free_256pbl;
40619 target_stat_values[++index] = int_mod_timer_init;
40620 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40621 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40622 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40623 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40624 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40625 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40626 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40627 }
40628
40629 /**
40630 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40631 index 5b53ca5..443da3c 100644
40632 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40633 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40634 @@ -46,9 +46,9 @@
40635
40636 #include <rdma/ib_umem.h>
40637
40638 -atomic_t mod_qp_timouts;
40639 -atomic_t qps_created;
40640 -atomic_t sw_qps_destroyed;
40641 +atomic_unchecked_t mod_qp_timouts;
40642 +atomic_unchecked_t qps_created;
40643 +atomic_unchecked_t sw_qps_destroyed;
40644
40645 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
40646
40647 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
40648 if (init_attr->create_flags)
40649 return ERR_PTR(-EINVAL);
40650
40651 - atomic_inc(&qps_created);
40652 + atomic_inc_unchecked(&qps_created);
40653 switch (init_attr->qp_type) {
40654 case IB_QPT_RC:
40655 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
40656 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
40657 struct iw_cm_event cm_event;
40658 int ret = 0;
40659
40660 - atomic_inc(&sw_qps_destroyed);
40661 + atomic_inc_unchecked(&sw_qps_destroyed);
40662 nesqp->destroyed = 1;
40663
40664 /* Blow away the connection if it exists. */
40665 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
40666 index 4a9af79..b993f75 100644
40667 --- a/drivers/infiniband/hw/qib/qib.h
40668 +++ b/drivers/infiniband/hw/qib/qib.h
40669 @@ -52,6 +52,7 @@
40670 #include <linux/kref.h>
40671 #include <linux/sched.h>
40672 #include <linux/kthread.h>
40673 +#include <linux/slab.h>
40674
40675 #include "qib_common.h"
40676 #include "qib_verbs.h"
40677 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
40678 index da739d9..da1c7f4 100644
40679 --- a/drivers/input/gameport/gameport.c
40680 +++ b/drivers/input/gameport/gameport.c
40681 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
40682 */
40683 static void gameport_init_port(struct gameport *gameport)
40684 {
40685 - static atomic_t gameport_no = ATOMIC_INIT(0);
40686 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
40687
40688 __module_get(THIS_MODULE);
40689
40690 mutex_init(&gameport->drv_mutex);
40691 device_initialize(&gameport->dev);
40692 dev_set_name(&gameport->dev, "gameport%lu",
40693 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
40694 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
40695 gameport->dev.bus = &gameport_bus;
40696 gameport->dev.release = gameport_release_port;
40697 if (gameport->parent)
40698 diff --git a/drivers/input/input.c b/drivers/input/input.c
40699 index c044699..174d71a 100644
40700 --- a/drivers/input/input.c
40701 +++ b/drivers/input/input.c
40702 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
40703 */
40704 int input_register_device(struct input_dev *dev)
40705 {
40706 - static atomic_t input_no = ATOMIC_INIT(0);
40707 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
40708 struct input_devres *devres = NULL;
40709 struct input_handler *handler;
40710 unsigned int packet_size;
40711 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
40712 dev->setkeycode = input_default_setkeycode;
40713
40714 dev_set_name(&dev->dev, "input%ld",
40715 - (unsigned long) atomic_inc_return(&input_no) - 1);
40716 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
40717
40718 error = device_add(&dev->dev);
40719 if (error)
40720 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
40721 index 04c69af..5f92d00 100644
40722 --- a/drivers/input/joystick/sidewinder.c
40723 +++ b/drivers/input/joystick/sidewinder.c
40724 @@ -30,6 +30,7 @@
40725 #include <linux/kernel.h>
40726 #include <linux/module.h>
40727 #include <linux/slab.h>
40728 +#include <linux/sched.h>
40729 #include <linux/init.h>
40730 #include <linux/input.h>
40731 #include <linux/gameport.h>
40732 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
40733 index 75e3b10..fb390fd 100644
40734 --- a/drivers/input/joystick/xpad.c
40735 +++ b/drivers/input/joystick/xpad.c
40736 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
40737
40738 static int xpad_led_probe(struct usb_xpad *xpad)
40739 {
40740 - static atomic_t led_seq = ATOMIC_INIT(0);
40741 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
40742 long led_no;
40743 struct xpad_led *led;
40744 struct led_classdev *led_cdev;
40745 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
40746 if (!led)
40747 return -ENOMEM;
40748
40749 - led_no = (long)atomic_inc_return(&led_seq) - 1;
40750 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
40751
40752 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
40753 led->xpad = xpad;
40754 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
40755 index e204f26..8459f15 100644
40756 --- a/drivers/input/misc/ims-pcu.c
40757 +++ b/drivers/input/misc/ims-pcu.c
40758 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
40759
40760 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40761 {
40762 - static atomic_t device_no = ATOMIC_INIT(0);
40763 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
40764
40765 const struct ims_pcu_device_info *info;
40766 u8 device_id;
40767 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40768 }
40769
40770 /* Device appears to be operable, complete initialization */
40771 - pcu->device_no = atomic_inc_return(&device_no) - 1;
40772 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
40773
40774 error = ims_pcu_setup_backlight(pcu);
40775 if (error)
40776 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
40777 index 2f0b39d..7370f13 100644
40778 --- a/drivers/input/mouse/psmouse.h
40779 +++ b/drivers/input/mouse/psmouse.h
40780 @@ -116,7 +116,7 @@ struct psmouse_attribute {
40781 ssize_t (*set)(struct psmouse *psmouse, void *data,
40782 const char *buf, size_t count);
40783 bool protect;
40784 -};
40785 +} __do_const;
40786 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
40787
40788 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
40789 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
40790 index 4c842c3..590b0bf 100644
40791 --- a/drivers/input/mousedev.c
40792 +++ b/drivers/input/mousedev.c
40793 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
40794
40795 spin_unlock_irq(&client->packet_lock);
40796
40797 - if (copy_to_user(buffer, data, count))
40798 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
40799 return -EFAULT;
40800
40801 return count;
40802 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
40803 index 25fc597..558bf3b3 100644
40804 --- a/drivers/input/serio/serio.c
40805 +++ b/drivers/input/serio/serio.c
40806 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
40807 */
40808 static void serio_init_port(struct serio *serio)
40809 {
40810 - static atomic_t serio_no = ATOMIC_INIT(0);
40811 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
40812
40813 __module_get(THIS_MODULE);
40814
40815 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
40816 mutex_init(&serio->drv_mutex);
40817 device_initialize(&serio->dev);
40818 dev_set_name(&serio->dev, "serio%ld",
40819 - (long)atomic_inc_return(&serio_no) - 1);
40820 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
40821 serio->dev.bus = &serio_bus;
40822 serio->dev.release = serio_release_port;
40823 serio->dev.groups = serio_device_attr_groups;
40824 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
40825 index 59df2e7..8f1cafb 100644
40826 --- a/drivers/input/serio/serio_raw.c
40827 +++ b/drivers/input/serio/serio_raw.c
40828 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
40829
40830 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
40831 {
40832 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
40833 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
40834 struct serio_raw *serio_raw;
40835 int err;
40836
40837 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
40838 }
40839
40840 snprintf(serio_raw->name, sizeof(serio_raw->name),
40841 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
40842 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
40843 kref_init(&serio_raw->kref);
40844 INIT_LIST_HEAD(&serio_raw->client_list);
40845 init_waitqueue_head(&serio_raw->wait);
40846 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
40847 index fbe9ca7..dbee61d 100644
40848 --- a/drivers/iommu/iommu.c
40849 +++ b/drivers/iommu/iommu.c
40850 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
40851 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
40852 {
40853 bus_register_notifier(bus, &iommu_bus_nb);
40854 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
40855 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
40856 }
40857
40858 /**
40859 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
40860 index 39f81ae..2660096 100644
40861 --- a/drivers/iommu/irq_remapping.c
40862 +++ b/drivers/iommu/irq_remapping.c
40863 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
40864 void panic_if_irq_remap(const char *msg)
40865 {
40866 if (irq_remapping_enabled)
40867 - panic(msg);
40868 + panic("%s", msg);
40869 }
40870
40871 static void ir_ack_apic_edge(struct irq_data *data)
40872 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
40873
40874 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
40875 {
40876 - chip->irq_print_chip = ir_print_prefix;
40877 - chip->irq_ack = ir_ack_apic_edge;
40878 - chip->irq_eoi = ir_ack_apic_level;
40879 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
40880 + pax_open_kernel();
40881 + *(void **)&chip->irq_print_chip = ir_print_prefix;
40882 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
40883 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
40884 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
40885 + pax_close_kernel();
40886 }
40887
40888 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
40889 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
40890 index ee7c503..5d4ce08 100644
40891 --- a/drivers/irqchip/irq-gic.c
40892 +++ b/drivers/irqchip/irq-gic.c
40893 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
40894 * Supported arch specific GIC irq extension.
40895 * Default make them NULL.
40896 */
40897 -struct irq_chip gic_arch_extn = {
40898 +irq_chip_no_const gic_arch_extn = {
40899 .irq_eoi = NULL,
40900 .irq_mask = NULL,
40901 .irq_unmask = NULL,
40902 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
40903 chained_irq_exit(chip, desc);
40904 }
40905
40906 -static struct irq_chip gic_chip = {
40907 +static irq_chip_no_const gic_chip __read_only = {
40908 .name = "GIC",
40909 .irq_mask = gic_mask_irq,
40910 .irq_unmask = gic_unmask_irq,
40911 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
40912 index ac6f72b..81150f2 100644
40913 --- a/drivers/isdn/capi/capi.c
40914 +++ b/drivers/isdn/capi/capi.c
40915 @@ -81,8 +81,8 @@ struct capiminor {
40916
40917 struct capi20_appl *ap;
40918 u32 ncci;
40919 - atomic_t datahandle;
40920 - atomic_t msgid;
40921 + atomic_unchecked_t datahandle;
40922 + atomic_unchecked_t msgid;
40923
40924 struct tty_port port;
40925 int ttyinstop;
40926 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
40927 capimsg_setu16(s, 2, mp->ap->applid);
40928 capimsg_setu8 (s, 4, CAPI_DATA_B3);
40929 capimsg_setu8 (s, 5, CAPI_RESP);
40930 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
40931 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
40932 capimsg_setu32(s, 8, mp->ncci);
40933 capimsg_setu16(s, 12, datahandle);
40934 }
40935 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
40936 mp->outbytes -= len;
40937 spin_unlock_bh(&mp->outlock);
40938
40939 - datahandle = atomic_inc_return(&mp->datahandle);
40940 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
40941 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
40942 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
40943 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
40944 capimsg_setu16(skb->data, 2, mp->ap->applid);
40945 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
40946 capimsg_setu8 (skb->data, 5, CAPI_REQ);
40947 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
40948 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
40949 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
40950 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
40951 capimsg_setu16(skb->data, 16, len); /* Data length */
40952 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
40953 index 600c79b..3752bab 100644
40954 --- a/drivers/isdn/gigaset/interface.c
40955 +++ b/drivers/isdn/gigaset/interface.c
40956 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
40957 }
40958 tty->driver_data = cs;
40959
40960 - ++cs->port.count;
40961 + atomic_inc(&cs->port.count);
40962
40963 - if (cs->port.count == 1) {
40964 + if (atomic_read(&cs->port.count) == 1) {
40965 tty_port_tty_set(&cs->port, tty);
40966 cs->port.low_latency = 1;
40967 }
40968 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
40969
40970 if (!cs->connected)
40971 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
40972 - else if (!cs->port.count)
40973 + else if (!atomic_read(&cs->port.count))
40974 dev_warn(cs->dev, "%s: device not opened\n", __func__);
40975 - else if (!--cs->port.count)
40976 + else if (!atomic_dec_return(&cs->port.count))
40977 tty_port_tty_set(&cs->port, NULL);
40978
40979 mutex_unlock(&cs->mutex);
40980 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
40981 index d0a41cb..f0cdb8c 100644
40982 --- a/drivers/isdn/gigaset/usb-gigaset.c
40983 +++ b/drivers/isdn/gigaset/usb-gigaset.c
40984 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
40985 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
40986 memcpy(cs->hw.usb->bchars, buf, 6);
40987 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
40988 - 0, 0, &buf, 6, 2000);
40989 + 0, 0, buf, 6, 2000);
40990 }
40991
40992 static void gigaset_freebcshw(struct bc_state *bcs)
40993 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
40994 index 4d9b195..455075c 100644
40995 --- a/drivers/isdn/hardware/avm/b1.c
40996 +++ b/drivers/isdn/hardware/avm/b1.c
40997 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
40998 }
40999 if (left) {
41000 if (t4file->user) {
41001 - if (copy_from_user(buf, dp, left))
41002 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41003 return -EFAULT;
41004 } else {
41005 memcpy(buf, dp, left);
41006 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41007 }
41008 if (left) {
41009 if (config->user) {
41010 - if (copy_from_user(buf, dp, left))
41011 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41012 return -EFAULT;
41013 } else {
41014 memcpy(buf, dp, left);
41015 diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
41016 index 1063bab..36817e0 100644
41017 --- a/drivers/isdn/hisax/amd7930_fn.c
41018 +++ b/drivers/isdn/hisax/amd7930_fn.c
41019 @@ -314,7 +314,7 @@ Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag)
41020
41021 t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx);
41022 QuickHex(t, cs->rcvbuf, cs->rcvidx);
41023 - debugl1(cs, cs->dlog);
41024 + debugl1(cs, "%s", cs->dlog);
41025 }
41026 /* moves received data in sk-buffer */
41027 memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx);
41028 @@ -406,7 +406,7 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs)
41029
41030 t += sprintf(t, "Amd7930: fill_Dfifo cnt: %d |", count);
41031 QuickHex(t, deb_ptr, count);
41032 - debugl1(cs, cs->dlog);
41033 + debugl1(cs, "%s", cs->dlog);
41034 }
41035 /* AMD interrupts on */
41036 AmdIrqOn(cs);
41037 diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
41038 index ee9b9a0..d1427bd 100644
41039 --- a/drivers/isdn/hisax/avm_pci.c
41040 +++ b/drivers/isdn/hisax/avm_pci.c
41041 @@ -285,7 +285,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count)
41042 t += sprintf(t, "hdlc_empty_fifo %c cnt %d",
41043 bcs->channel ? 'B' : 'A', count);
41044 QuickHex(t, p, count);
41045 - debugl1(cs, bcs->blog);
41046 + debugl1(cs, "%s", bcs->blog);
41047 }
41048 }
41049
41050 @@ -345,7 +345,7 @@ hdlc_fill_fifo(struct BCState *bcs)
41051 t += sprintf(t, "hdlc_fill_fifo %c cnt %d",
41052 bcs->channel ? 'B' : 'A', count);
41053 QuickHex(t, p, count);
41054 - debugl1(cs, bcs->blog);
41055 + debugl1(cs, "%s", bcs->blog);
41056 }
41057 }
41058
41059 diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
41060 index bf04d2a..b33f53b 100644
41061 --- a/drivers/isdn/hisax/config.c
41062 +++ b/drivers/isdn/hisax/config.c
41063 @@ -1896,7 +1896,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
41064 ptr--;
41065 *ptr++ = '\n';
41066 *ptr = 0;
41067 - HiSax_putstatus(cs, NULL, cs->dlog);
41068 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41069 } else
41070 HiSax_putstatus(cs, "LogEcho: ",
41071 "warning Frame too big (%d)",
41072 diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
41073 index 8d0cf6e..4fc90de 100644
41074 --- a/drivers/isdn/hisax/diva.c
41075 +++ b/drivers/isdn/hisax/diva.c
41076 @@ -427,7 +427,7 @@ Memhscx_empty_fifo(struct BCState *bcs, int count)
41077 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41078 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41079 QuickHex(t, ptr, count);
41080 - debugl1(cs, bcs->blog);
41081 + debugl1(cs, "%s", bcs->blog);
41082 }
41083 }
41084
41085 @@ -469,7 +469,7 @@ Memhscx_fill_fifo(struct BCState *bcs)
41086 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41087 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41088 QuickHex(t, ptr, count);
41089 - debugl1(cs, bcs->blog);
41090 + debugl1(cs, "%s", bcs->blog);
41091 }
41092 }
41093
41094 diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
41095 index 1df6f9a..2be1c8a 100644
41096 --- a/drivers/isdn/hisax/elsa.c
41097 +++ b/drivers/isdn/hisax/elsa.c
41098 @@ -535,7 +535,7 @@ check_arcofi(struct IsdnCardState *cs)
41099 t = tmp;
41100 t += sprintf(tmp, "Arcofi data");
41101 QuickHex(t, p, cs->dc.isac.mon_rxp);
41102 - debugl1(cs, tmp);
41103 + debugl1(cs, "%s", tmp);
41104 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
41105 switch (cs->dc.isac.mon_rx[1]) {
41106 case 0x80:
41107 diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
41108 index d4c98d3..3f84dd8 100644
41109 --- a/drivers/isdn/hisax/elsa_ser.c
41110 +++ b/drivers/isdn/hisax/elsa_ser.c
41111 @@ -344,7 +344,7 @@ static inline void receive_chars(struct IsdnCardState *cs,
41112
41113 t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt);
41114 QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt);
41115 - debugl1(cs, tmp);
41116 + debugl1(cs, "%s", tmp);
41117 }
41118 cs->hw.elsa.rcvcnt = 0;
41119 }
41120 diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
41121 index 3ccd724..497bd02 100644
41122 --- a/drivers/isdn/hisax/hfc_pci.c
41123 +++ b/drivers/isdn/hisax/hfc_pci.c
41124 @@ -901,7 +901,7 @@ Begin:
41125 ptr--;
41126 *ptr++ = '\n';
41127 *ptr = 0;
41128 - HiSax_putstatus(cs, NULL, cs->dlog);
41129 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41130 } else
41131 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3);
41132 }
41133 diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
41134 index dc4574f..fa1fefd 100644
41135 --- a/drivers/isdn/hisax/hfc_sx.c
41136 +++ b/drivers/isdn/hisax/hfc_sx.c
41137 @@ -674,7 +674,7 @@ receive_emsg(struct IsdnCardState *cs)
41138 ptr--;
41139 *ptr++ = '\n';
41140 *ptr = 0;
41141 - HiSax_putstatus(cs, NULL, cs->dlog);
41142 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41143 } else
41144 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len);
41145 }
41146 diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
41147 index f398d48..a8d6188 100644
41148 --- a/drivers/isdn/hisax/hscx_irq.c
41149 +++ b/drivers/isdn/hisax/hscx_irq.c
41150 @@ -75,7 +75,7 @@ hscx_empty_fifo(struct BCState *bcs, int count)
41151 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41152 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41153 QuickHex(t, ptr, count);
41154 - debugl1(cs, bcs->blog);
41155 + debugl1(cs, "%s", bcs->blog);
41156 }
41157 }
41158
41159 @@ -115,7 +115,7 @@ hscx_fill_fifo(struct BCState *bcs)
41160 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41161 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41162 QuickHex(t, ptr, count);
41163 - debugl1(cs, bcs->blog);
41164 + debugl1(cs, "%s", bcs->blog);
41165 }
41166 }
41167
41168 diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
41169 index db5321f..51dae91 100644
41170 --- a/drivers/isdn/hisax/icc.c
41171 +++ b/drivers/isdn/hisax/icc.c
41172 @@ -134,7 +134,7 @@ icc_empty_fifo(struct IsdnCardState *cs, int count)
41173
41174 t += sprintf(t, "icc_empty_fifo cnt %d", count);
41175 QuickHex(t, ptr, count);
41176 - debugl1(cs, cs->dlog);
41177 + debugl1(cs, "%s", cs->dlog);
41178 }
41179 }
41180
41181 @@ -176,7 +176,7 @@ icc_fill_fifo(struct IsdnCardState *cs)
41182
41183 t += sprintf(t, "icc_fill_fifo cnt %d", count);
41184 QuickHex(t, ptr, count);
41185 - debugl1(cs, cs->dlog);
41186 + debugl1(cs, "%s", cs->dlog);
41187 }
41188 }
41189
41190 diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
41191 index 74feb5c..5faa5de 100644
41192 --- a/drivers/isdn/hisax/ipacx.c
41193 +++ b/drivers/isdn/hisax/ipacx.c
41194 @@ -260,7 +260,7 @@ dch_empty_fifo(struct IsdnCardState *cs, int count)
41195
41196 t += sprintf(t, "dch_empty_fifo() cnt %d", count);
41197 QuickHex(t, ptr, count);
41198 - debugl1(cs, cs->dlog);
41199 + debugl1(cs, "%s", cs->dlog);
41200 }
41201 }
41202
41203 @@ -307,7 +307,7 @@ dch_fill_fifo(struct IsdnCardState *cs)
41204
41205 t += sprintf(t, "dch_fill_fifo() cnt %d", count);
41206 QuickHex(t, ptr, count);
41207 - debugl1(cs, cs->dlog);
41208 + debugl1(cs, "%s", cs->dlog);
41209 }
41210 }
41211
41212 @@ -539,7 +539,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
41213
41214 t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count);
41215 QuickHex(t, ptr, count);
41216 - debugl1(cs, bcs->blog);
41217 + debugl1(cs, "%s", bcs->blog);
41218 }
41219 }
41220
41221 @@ -582,7 +582,7 @@ bch_fill_fifo(struct BCState *bcs)
41222
41223 t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count);
41224 QuickHex(t, ptr, count);
41225 - debugl1(cs, bcs->blog);
41226 + debugl1(cs, "%s", bcs->blog);
41227 }
41228 }
41229
41230 diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
41231 index a365ccc..7fdf78f 100644
41232 --- a/drivers/isdn/hisax/isac.c
41233 +++ b/drivers/isdn/hisax/isac.c
41234 @@ -137,7 +137,7 @@ isac_empty_fifo(struct IsdnCardState *cs, int count)
41235
41236 t += sprintf(t, "isac_empty_fifo cnt %d", count);
41237 QuickHex(t, ptr, count);
41238 - debugl1(cs, cs->dlog);
41239 + debugl1(cs, "%s", cs->dlog);
41240 }
41241 }
41242
41243 @@ -179,7 +179,7 @@ isac_fill_fifo(struct IsdnCardState *cs)
41244
41245 t += sprintf(t, "isac_fill_fifo cnt %d", count);
41246 QuickHex(t, ptr, count);
41247 - debugl1(cs, cs->dlog);
41248 + debugl1(cs, "%s", cs->dlog);
41249 }
41250 }
41251
41252 diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
41253 index 7fdf347..f4956c7 100644
41254 --- a/drivers/isdn/hisax/isar.c
41255 +++ b/drivers/isdn/hisax/isar.c
41256 @@ -74,7 +74,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
41257 t = tmp;
41258 t += sprintf(t, "sendmbox cnt %d", len);
41259 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i);
41260 - debugl1(cs, tmp);
41261 + debugl1(cs, "%s", tmp);
41262 i -= 64;
41263 }
41264 }
41265 @@ -105,7 +105,7 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
41266 t = tmp;
41267 t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb);
41268 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i);
41269 - debugl1(cs, tmp);
41270 + debugl1(cs, "%s", tmp);
41271 i -= 64;
41272 }
41273 }
41274 @@ -1248,7 +1248,7 @@ isar_int_main(struct IsdnCardState *cs)
41275 tp += sprintf(debbuf, "msg iis(%x) msb(%x)",
41276 ireg->iis, ireg->cmsb);
41277 QuickHex(tp, (u_char *)ireg->par, ireg->clsb);
41278 - debugl1(cs, debbuf);
41279 + debugl1(cs, "%s", debbuf);
41280 }
41281 break;
41282 case ISAR_IIS_INVMSG:
41283 diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
41284 index f946c58..e2ae787 100644
41285 --- a/drivers/isdn/hisax/jade.c
41286 +++ b/drivers/isdn/hisax/jade.c
41287 @@ -81,10 +81,7 @@ modejade(struct BCState *bcs, int mode, int bc)
41288 int jade = bcs->hw.hscx.hscx;
41289
41290 if (cs->debug & L1_DEB_HSCX) {
41291 - char tmp[40];
41292 - sprintf(tmp, "jade %c mode %d ichan %d",
41293 - 'A' + jade, mode, bc);
41294 - debugl1(cs, tmp);
41295 + debugl1(cs, "jade %c mode %d ichan %d", 'A' + jade, mode, bc);
41296 }
41297 bcs->mode = mode;
41298 bcs->channel = bc;
41299 @@ -257,23 +254,18 @@ void
41300 clear_pending_jade_ints(struct IsdnCardState *cs)
41301 {
41302 int val;
41303 - char tmp[64];
41304
41305 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
41306 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
41307
41308 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR);
41309 - sprintf(tmp, "jade B ISTA %x", val);
41310 - debugl1(cs, tmp);
41311 + debugl1(cs, "jade B ISTA %x", val);
41312 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR);
41313 - sprintf(tmp, "jade A ISTA %x", val);
41314 - debugl1(cs, tmp);
41315 + debugl1(cs, "jade A ISTA %x", val);
41316 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR);
41317 - sprintf(tmp, "jade B STAR %x", val);
41318 - debugl1(cs, tmp);
41319 + debugl1(cs, "jade B STAR %x", val);
41320 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR);
41321 - sprintf(tmp, "jade A STAR %x", val);
41322 - debugl1(cs, tmp);
41323 + debugl1(cs, "jade A STAR %x", val);
41324 /* Unmask ints */
41325 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8);
41326 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
41327 diff --git a/drivers/isdn/hisax/jade_irq.c b/drivers/isdn/hisax/jade_irq.c
41328 index f521fc8..b930da9 100644
41329 --- a/drivers/isdn/hisax/jade_irq.c
41330 +++ b/drivers/isdn/hisax/jade_irq.c
41331 @@ -65,7 +65,7 @@ jade_empty_fifo(struct BCState *bcs, int count)
41332 t += sprintf(t, "jade_empty_fifo %c cnt %d",
41333 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41334 QuickHex(t, ptr, count);
41335 - debugl1(cs, bcs->blog);
41336 + debugl1(cs, "%s", bcs->blog);
41337 }
41338 }
41339
41340 @@ -105,7 +105,7 @@ jade_fill_fifo(struct BCState *bcs)
41341 t += sprintf(t, "jade_fill_fifo %c cnt %d",
41342 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41343 QuickHex(t, ptr, count);
41344 - debugl1(cs, bcs->blog);
41345 + debugl1(cs, "%s", bcs->blog);
41346 }
41347 }
41348
41349 diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
41350 index 4c1bca5..875402e 100644
41351 --- a/drivers/isdn/hisax/l3_1tr6.c
41352 +++ b/drivers/isdn/hisax/l3_1tr6.c
41353 @@ -63,7 +63,7 @@ l3_1tr6_error(struct l3_process *pc, u_char *msg, struct sk_buff *skb)
41354 {
41355 dev_kfree_skb(skb);
41356 if (pc->st->l3.debug & L3_DEB_WARN)
41357 - l3_debug(pc->st, msg);
41358 + l3_debug(pc->st, "%s", msg);
41359 l3_1tr6_release_req(pc, 0, NULL);
41360 }
41361
41362 @@ -161,7 +161,6 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41363 {
41364 u_char *p;
41365 int bcfound = 0;
41366 - char tmp[80];
41367 struct sk_buff *skb = arg;
41368
41369 /* Channel Identification */
41370 @@ -214,10 +213,9 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41371 /* Signal all services, linklevel takes care of Service-Indicator */
41372 if (bcfound) {
41373 if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) {
41374 - sprintf(tmp, "non-digital call: %s -> %s",
41375 + l3_debug(pc->st, "non-digital call: %s -> %s",
41376 pc->para.setup.phone,
41377 pc->para.setup.eazmsn);
41378 - l3_debug(pc->st, tmp);
41379 }
41380 newl3state(pc, 6);
41381 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
41382 @@ -301,7 +299,7 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41383 {
41384 u_char *p;
41385 int i, tmpcharge = 0;
41386 - char a_charge[8], tmp[32];
41387 + char a_charge[8];
41388 struct sk_buff *skb = arg;
41389
41390 p = skb->data;
41391 @@ -316,8 +314,8 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41392 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41393 }
41394 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41395 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41396 - l3_debug(pc->st, tmp);
41397 + l3_debug(pc->st, "charging info %d",
41398 + pc->para.chargeinfo);
41399 }
41400 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41401 l3_debug(pc->st, "charging info not found");
41402 @@ -399,7 +397,7 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41403 struct sk_buff *skb = arg;
41404 u_char *p;
41405 int i, tmpcharge = 0;
41406 - char a_charge[8], tmp[32];
41407 + char a_charge[8];
41408
41409 StopAllL3Timer(pc);
41410 p = skb->data;
41411 @@ -414,8 +412,8 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41412 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41413 }
41414 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41415 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41416 - l3_debug(pc->st, tmp);
41417 + l3_debug(pc->st, "charging info %d",
41418 + pc->para.chargeinfo);
41419 }
41420 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41421 l3_debug(pc->st, "charging info not found");
41422 @@ -746,7 +744,6 @@ up1tr6(struct PStack *st, int pr, void *arg)
41423 int i, mt, cr;
41424 struct l3_process *proc;
41425 struct sk_buff *skb = arg;
41426 - char tmp[80];
41427
41428 switch (pr) {
41429 case (DL_DATA | INDICATION):
41430 @@ -762,26 +759,23 @@ up1tr6(struct PStack *st, int pr, void *arg)
41431 }
41432 if (skb->len < 4) {
41433 if (st->l3.debug & L3_DEB_PROTERR) {
41434 - sprintf(tmp, "up1tr6 len only %d", skb->len);
41435 - l3_debug(st, tmp);
41436 + l3_debug(st, "up1tr6 len only %d", skb->len);
41437 }
41438 dev_kfree_skb(skb);
41439 return;
41440 }
41441 if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) {
41442 if (st->l3.debug & L3_DEB_PROTERR) {
41443 - sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d",
41444 + l3_debug(st, "up1tr6%sunexpected discriminator %x message len %d",
41445 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41446 skb->data[0], skb->len);
41447 - l3_debug(st, tmp);
41448 }
41449 dev_kfree_skb(skb);
41450 return;
41451 }
41452 if (skb->data[1] != 1) {
41453 if (st->l3.debug & L3_DEB_PROTERR) {
41454 - sprintf(tmp, "up1tr6 CR len not 1");
41455 - l3_debug(st, tmp);
41456 + l3_debug(st, "up1tr6 CR len not 1");
41457 }
41458 dev_kfree_skb(skb);
41459 return;
41460 @@ -791,9 +785,8 @@ up1tr6(struct PStack *st, int pr, void *arg)
41461 if (skb->data[0] == PROTO_DIS_N0) {
41462 dev_kfree_skb(skb);
41463 if (st->l3.debug & L3_DEB_STATE) {
41464 - sprintf(tmp, "up1tr6%s N0 mt %x unhandled",
41465 + l3_debug(st, "up1tr6%s N0 mt %x unhandled",
41466 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt);
41467 - l3_debug(st, tmp);
41468 }
41469 } else if (skb->data[0] == PROTO_DIS_N1) {
41470 if (!(proc = getl3proc(st, cr))) {
41471 @@ -801,8 +794,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41472 if (cr < 128) {
41473 if (!(proc = new_l3_process(st, cr))) {
41474 if (st->l3.debug & L3_DEB_PROTERR) {
41475 - sprintf(tmp, "up1tr6 no roc mem");
41476 - l3_debug(st, tmp);
41477 + l3_debug(st, "up1tr6 no roc mem");
41478 }
41479 dev_kfree_skb(skb);
41480 return;
41481 @@ -821,8 +813,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41482 } else {
41483 if (!(proc = new_l3_process(st, cr))) {
41484 if (st->l3.debug & L3_DEB_PROTERR) {
41485 - sprintf(tmp, "up1tr6 no roc mem");
41486 - l3_debug(st, tmp);
41487 + l3_debug(st, "up1tr6 no roc mem");
41488 }
41489 dev_kfree_skb(skb);
41490 return;
41491 @@ -837,18 +828,16 @@ up1tr6(struct PStack *st, int pr, void *arg)
41492 if (i == ARRAY_SIZE(datastln1)) {
41493 dev_kfree_skb(skb);
41494 if (st->l3.debug & L3_DEB_STATE) {
41495 - sprintf(tmp, "up1tr6%sstate %d mt %x unhandled",
41496 + l3_debug(st, "up1tr6%sstate %d mt %x unhandled",
41497 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41498 proc->state, mt);
41499 - l3_debug(st, tmp);
41500 }
41501 return;
41502 } else {
41503 if (st->l3.debug & L3_DEB_STATE) {
41504 - sprintf(tmp, "up1tr6%sstate %d mt %x",
41505 + l3_debug(st, "up1tr6%sstate %d mt %x",
41506 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41507 proc->state, mt);
41508 - l3_debug(st, tmp);
41509 }
41510 datastln1[i].rout(proc, pr, skb);
41511 }
41512 @@ -861,7 +850,6 @@ down1tr6(struct PStack *st, int pr, void *arg)
41513 int i, cr;
41514 struct l3_process *proc;
41515 struct Channel *chan;
41516 - char tmp[80];
41517
41518 if ((DL_ESTABLISH | REQUEST) == pr) {
41519 l3_msg(st, pr, NULL);
41520 @@ -888,15 +876,13 @@ down1tr6(struct PStack *st, int pr, void *arg)
41521 break;
41522 if (i == ARRAY_SIZE(downstl)) {
41523 if (st->l3.debug & L3_DEB_STATE) {
41524 - sprintf(tmp, "down1tr6 state %d prim %d unhandled",
41525 + l3_debug(st, "down1tr6 state %d prim %d unhandled",
41526 proc->state, pr);
41527 - l3_debug(st, tmp);
41528 }
41529 } else {
41530 if (st->l3.debug & L3_DEB_STATE) {
41531 - sprintf(tmp, "down1tr6 state %d prim %d",
41532 + l3_debug(st, "down1tr6 state %d prim %d",
41533 proc->state, pr);
41534 - l3_debug(st, tmp);
41535 }
41536 downstl[i].rout(proc, pr, arg);
41537 }
41538 diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
41539 index b646eed..233e432 100644
41540 --- a/drivers/isdn/hisax/netjet.c
41541 +++ b/drivers/isdn/hisax/netjet.c
41542 @@ -176,7 +176,7 @@ static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s
41543 else
41544 j = i;
41545 QuickHex(t, p, j);
41546 - debugl1(cs, tmp);
41547 + debugl1(cs, "%s", tmp);
41548 p += j;
41549 i -= j;
41550 t = tmp;
41551 diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
41552 index 041bf52..af1b020 100644
41553 --- a/drivers/isdn/hisax/q931.c
41554 +++ b/drivers/isdn/hisax/q931.c
41555 @@ -1179,7 +1179,7 @@ LogFrame(struct IsdnCardState *cs, u_char *buf, int size)
41556 dp--;
41557 *dp++ = '\n';
41558 *dp = 0;
41559 - HiSax_putstatus(cs, NULL, cs->dlog);
41560 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41561 } else
41562 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size);
41563 }
41564 @@ -1246,7 +1246,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41565 }
41566 if (finish) {
41567 *dp = 0;
41568 - HiSax_putstatus(cs, NULL, cs->dlog);
41569 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41570 return;
41571 }
41572 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */
41573 @@ -1509,5 +1509,5 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41574 dp += sprintf(dp, "Unknown protocol %x!", buf[0]);
41575 }
41576 *dp = 0;
41577 - HiSax_putstatus(cs, NULL, cs->dlog);
41578 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41579 }
41580 diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
41581 index d8cac69..a858955 100644
41582 --- a/drivers/isdn/hisax/w6692.c
41583 +++ b/drivers/isdn/hisax/w6692.c
41584 @@ -154,7 +154,7 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count)
41585
41586 t += sprintf(t, "W6692_empty_fifo cnt %d", count);
41587 QuickHex(t, ptr, count);
41588 - debugl1(cs, cs->dlog);
41589 + debugl1(cs, "%s", cs->dlog);
41590 }
41591 }
41592
41593 @@ -196,7 +196,7 @@ W6692_fill_fifo(struct IsdnCardState *cs)
41594
41595 t += sprintf(t, "W6692_fill_fifo cnt %d", count);
41596 QuickHex(t, ptr, count);
41597 - debugl1(cs, cs->dlog);
41598 + debugl1(cs, "%s", cs->dlog);
41599 }
41600 }
41601
41602 @@ -226,7 +226,7 @@ W6692B_empty_fifo(struct BCState *bcs, int count)
41603 t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
41604 bcs->channel + '1', count);
41605 QuickHex(t, ptr, count);
41606 - debugl1(cs, bcs->blog);
41607 + debugl1(cs, "%s", bcs->blog);
41608 }
41609 }
41610
41611 @@ -264,7 +264,7 @@ W6692B_fill_fifo(struct BCState *bcs)
41612 t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
41613 bcs->channel + '1', count);
41614 QuickHex(t, ptr, count);
41615 - debugl1(cs, bcs->blog);
41616 + debugl1(cs, "%s", bcs->blog);
41617 }
41618 }
41619
41620 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41621 index 9bb12ba..d4262f7 100644
41622 --- a/drivers/isdn/i4l/isdn_common.c
41623 +++ b/drivers/isdn/i4l/isdn_common.c
41624 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41625 } else
41626 return -EINVAL;
41627 case IIOCDBGVAR:
41628 + if (!capable(CAP_SYS_RAWIO))
41629 + return -EPERM;
41630 if (arg) {
41631 if (copy_to_user(argp, &dev, sizeof(ulong)))
41632 return -EFAULT;
41633 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41634 index 3c5f249..5fac4d0 100644
41635 --- a/drivers/isdn/i4l/isdn_tty.c
41636 +++ b/drivers/isdn/i4l/isdn_tty.c
41637 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41638
41639 #ifdef ISDN_DEBUG_MODEM_OPEN
41640 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41641 - port->count);
41642 + atomic_read(&port->count));
41643 #endif
41644 - port->count++;
41645 + atomic_inc(&port->count);
41646 port->tty = tty;
41647 /*
41648 * Start up serial port
41649 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41650 #endif
41651 return;
41652 }
41653 - if ((tty->count == 1) && (port->count != 1)) {
41654 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41655 /*
41656 * Uh, oh. tty->count is 1, which means that the tty
41657 * structure will be freed. Info->count should always
41658 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41659 * serial port won't be shutdown.
41660 */
41661 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41662 - "info->count is %d\n", port->count);
41663 - port->count = 1;
41664 + "info->count is %d\n", atomic_read(&port->count));
41665 + atomic_set(&port->count, 1);
41666 }
41667 - if (--port->count < 0) {
41668 + if (atomic_dec_return(&port->count) < 0) {
41669 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41670 - info->line, port->count);
41671 - port->count = 0;
41672 + info->line, atomic_read(&port->count));
41673 + atomic_set(&port->count, 0);
41674 }
41675 - if (port->count) {
41676 + if (atomic_read(&port->count)) {
41677 #ifdef ISDN_DEBUG_MODEM_OPEN
41678 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41679 #endif
41680 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41681 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41682 return;
41683 isdn_tty_shutdown(info);
41684 - port->count = 0;
41685 + atomic_set(&port->count, 0);
41686 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41687 port->tty = NULL;
41688 wake_up_interruptible(&port->open_wait);
41689 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41690 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41691 modem_info *info = &dev->mdm.info[i];
41692
41693 - if (info->port.count == 0)
41694 + if (atomic_read(&info->port.count) == 0)
41695 continue;
41696 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41697 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41698 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41699 index e74df7c..03a03ba 100644
41700 --- a/drivers/isdn/icn/icn.c
41701 +++ b/drivers/isdn/icn/icn.c
41702 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41703 if (count > len)
41704 count = len;
41705 if (user) {
41706 - if (copy_from_user(msg, buf, count))
41707 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41708 return -EFAULT;
41709 } else
41710 memcpy(msg, buf, count);
41711 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41712 index 6a8405d..0bd1c7e 100644
41713 --- a/drivers/leds/leds-clevo-mail.c
41714 +++ b/drivers/leds/leds-clevo-mail.c
41715 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41716 * detected as working, but in reality it is not) as low as
41717 * possible.
41718 */
41719 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
41720 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
41721 {
41722 .callback = clevo_mail_led_dmi_callback,
41723 .ident = "Clevo D410J",
41724 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41725 index 64e204e..c6bf189 100644
41726 --- a/drivers/leds/leds-ss4200.c
41727 +++ b/drivers/leds/leds-ss4200.c
41728 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41729 * detected as working, but in reality it is not) as low as
41730 * possible.
41731 */
41732 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
41733 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
41734 {
41735 .callback = ss4200_led_dmi_callback,
41736 .ident = "Intel SS4200-E",
41737 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41738 index 0bf1e4e..b4bf44e 100644
41739 --- a/drivers/lguest/core.c
41740 +++ b/drivers/lguest/core.c
41741 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41742 * The end address needs +1 because __get_vm_area allocates an
41743 * extra guard page, so we need space for that.
41744 */
41745 +
41746 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41747 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41748 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41749 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41750 +#else
41751 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41752 VM_ALLOC, switcher_addr, switcher_addr
41753 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41754 +#endif
41755 +
41756 if (!switcher_vma) {
41757 err = -ENOMEM;
41758 printk("lguest: could not map switcher pages high\n");
41759 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41760 * Now the Switcher is mapped at the right address, we can't fail!
41761 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41762 */
41763 - memcpy(switcher_vma->addr, start_switcher_text,
41764 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41765 end_switcher_text - start_switcher_text);
41766
41767 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41768 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41769 index a35d8d1..59fb772 100644
41770 --- a/drivers/lguest/page_tables.c
41771 +++ b/drivers/lguest/page_tables.c
41772 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41773 /*:*/
41774
41775 #ifdef CONFIG_X86_PAE
41776 -static void release_pmd(pmd_t *spmd)
41777 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41778 {
41779 /* If the entry's not present, there's nothing to release. */
41780 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41781 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41782 index 5169239..47cb4db 100644
41783 --- a/drivers/lguest/x86/core.c
41784 +++ b/drivers/lguest/x86/core.c
41785 @@ -59,7 +59,7 @@ static struct {
41786 /* Offset from where switcher.S was compiled to where we've copied it */
41787 static unsigned long switcher_offset(void)
41788 {
41789 - return switcher_addr - (unsigned long)start_switcher_text;
41790 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
41791 }
41792
41793 /* This cpu's struct lguest_pages (after the Switcher text page) */
41794 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
41795 * These copies are pretty cheap, so we do them unconditionally: */
41796 /* Save the current Host top-level page directory.
41797 */
41798 +
41799 +#ifdef CONFIG_PAX_PER_CPU_PGD
41800 + pages->state.host_cr3 = read_cr3();
41801 +#else
41802 pages->state.host_cr3 = __pa(current->mm->pgd);
41803 +#endif
41804 +
41805 /*
41806 * Set up the Guest's page tables to see this CPU's pages (and no
41807 * other CPU's pages).
41808 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
41809 * compiled-in switcher code and the high-mapped copy we just made.
41810 */
41811 for (i = 0; i < IDT_ENTRIES; i++)
41812 - default_idt_entries[i] += switcher_offset();
41813 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
41814
41815 /*
41816 * Set up the Switcher's per-cpu areas.
41817 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
41818 * it will be undisturbed when we switch. To change %cs and jump we
41819 * need this structure to feed to Intel's "lcall" instruction.
41820 */
41821 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
41822 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
41823 lguest_entry.segment = LGUEST_CS;
41824
41825 /*
41826 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
41827 index 40634b0..4f5855e 100644
41828 --- a/drivers/lguest/x86/switcher_32.S
41829 +++ b/drivers/lguest/x86/switcher_32.S
41830 @@ -87,6 +87,7 @@
41831 #include <asm/page.h>
41832 #include <asm/segment.h>
41833 #include <asm/lguest.h>
41834 +#include <asm/processor-flags.h>
41835
41836 // We mark the start of the code to copy
41837 // It's placed in .text tho it's never run here
41838 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
41839 // Changes type when we load it: damn Intel!
41840 // For after we switch over our page tables
41841 // That entry will be read-only: we'd crash.
41842 +
41843 +#ifdef CONFIG_PAX_KERNEXEC
41844 + mov %cr0, %edx
41845 + xor $X86_CR0_WP, %edx
41846 + mov %edx, %cr0
41847 +#endif
41848 +
41849 movl $(GDT_ENTRY_TSS*8), %edx
41850 ltr %dx
41851
41852 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
41853 // Let's clear it again for our return.
41854 // The GDT descriptor of the Host
41855 // Points to the table after two "size" bytes
41856 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
41857 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
41858 // Clear "used" from type field (byte 5, bit 2)
41859 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
41860 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
41861 +
41862 +#ifdef CONFIG_PAX_KERNEXEC
41863 + mov %cr0, %eax
41864 + xor $X86_CR0_WP, %eax
41865 + mov %eax, %cr0
41866 +#endif
41867
41868 // Once our page table's switched, the Guest is live!
41869 // The Host fades as we run this final step.
41870 @@ -295,13 +309,12 @@ deliver_to_host:
41871 // I consulted gcc, and it gave
41872 // These instructions, which I gladly credit:
41873 leal (%edx,%ebx,8), %eax
41874 - movzwl (%eax),%edx
41875 - movl 4(%eax), %eax
41876 - xorw %ax, %ax
41877 - orl %eax, %edx
41878 + movl 4(%eax), %edx
41879 + movw (%eax), %dx
41880 // Now the address of the handler's in %edx
41881 // We call it now: its "iret" drops us home.
41882 - jmp *%edx
41883 + ljmp $__KERNEL_CS, $1f
41884 +1: jmp *%edx
41885
41886 // Every interrupt can come to us here
41887 // But we must truly tell each apart.
41888 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
41889 index 0003992..854bbce 100644
41890 --- a/drivers/md/bcache/closure.h
41891 +++ b/drivers/md/bcache/closure.h
41892 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
41893 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
41894 struct workqueue_struct *wq)
41895 {
41896 - BUG_ON(object_is_on_stack(cl));
41897 + BUG_ON(object_starts_on_stack(cl));
41898 closure_set_ip(cl);
41899 cl->fn = fn;
41900 cl->wq = wq;
41901 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
41902 index 547c4c5..5be1de4 100644
41903 --- a/drivers/md/bcache/super.c
41904 +++ b/drivers/md/bcache/super.c
41905 @@ -1644,7 +1644,7 @@ err_unlock_gc:
41906 err:
41907 closure_sync(&op.cl);
41908 /* XXX: test this, it's broken */
41909 - bch_cache_set_error(c, err);
41910 + bch_cache_set_error(c, "%s", err);
41911 }
41912
41913 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
41914 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
41915 index a7fd821..9dcf6c3 100644
41916 --- a/drivers/md/bitmap.c
41917 +++ b/drivers/md/bitmap.c
41918 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
41919 chunk_kb ? "KB" : "B");
41920 if (bitmap->storage.file) {
41921 seq_printf(seq, ", file: ");
41922 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
41923 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
41924 }
41925
41926 seq_printf(seq, "\n");
41927 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
41928 index f1b7586..a49c4bd 100644
41929 --- a/drivers/md/dm-ioctl.c
41930 +++ b/drivers/md/dm-ioctl.c
41931 @@ -1739,7 +1739,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
41932 cmd == DM_LIST_VERSIONS_CMD)
41933 return 0;
41934
41935 - if ((cmd == DM_DEV_CREATE_CMD)) {
41936 + if (cmd == DM_DEV_CREATE_CMD) {
41937 if (!*param->name) {
41938 DMWARN("name not supplied when creating device");
41939 return -EINVAL;
41940 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
41941 index 699b5be..eac0a15 100644
41942 --- a/drivers/md/dm-raid1.c
41943 +++ b/drivers/md/dm-raid1.c
41944 @@ -40,7 +40,7 @@ enum dm_raid1_error {
41945
41946 struct mirror {
41947 struct mirror_set *ms;
41948 - atomic_t error_count;
41949 + atomic_unchecked_t error_count;
41950 unsigned long error_type;
41951 struct dm_dev *dev;
41952 sector_t offset;
41953 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
41954 struct mirror *m;
41955
41956 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
41957 - if (!atomic_read(&m->error_count))
41958 + if (!atomic_read_unchecked(&m->error_count))
41959 return m;
41960
41961 return NULL;
41962 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
41963 * simple way to tell if a device has encountered
41964 * errors.
41965 */
41966 - atomic_inc(&m->error_count);
41967 + atomic_inc_unchecked(&m->error_count);
41968
41969 if (test_and_set_bit(error_type, &m->error_type))
41970 return;
41971 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
41972 struct mirror *m = get_default_mirror(ms);
41973
41974 do {
41975 - if (likely(!atomic_read(&m->error_count)))
41976 + if (likely(!atomic_read_unchecked(&m->error_count)))
41977 return m;
41978
41979 if (m-- == ms->mirror)
41980 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
41981 {
41982 struct mirror *default_mirror = get_default_mirror(m->ms);
41983
41984 - return !atomic_read(&default_mirror->error_count);
41985 + return !atomic_read_unchecked(&default_mirror->error_count);
41986 }
41987
41988 static int mirror_available(struct mirror_set *ms, struct bio *bio)
41989 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
41990 */
41991 if (likely(region_in_sync(ms, region, 1)))
41992 m = choose_mirror(ms, bio->bi_sector);
41993 - else if (m && atomic_read(&m->error_count))
41994 + else if (m && atomic_read_unchecked(&m->error_count))
41995 m = NULL;
41996
41997 if (likely(m))
41998 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
41999 }
42000
42001 ms->mirror[mirror].ms = ms;
42002 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42003 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42004 ms->mirror[mirror].error_type = 0;
42005 ms->mirror[mirror].offset = offset;
42006
42007 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
42008 */
42009 static char device_status_char(struct mirror *m)
42010 {
42011 - if (!atomic_read(&(m->error_count)))
42012 + if (!atomic_read_unchecked(&(m->error_count)))
42013 return 'A';
42014
42015 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42016 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42017 index d907ca6..cfb8384 100644
42018 --- a/drivers/md/dm-stripe.c
42019 +++ b/drivers/md/dm-stripe.c
42020 @@ -20,7 +20,7 @@ struct stripe {
42021 struct dm_dev *dev;
42022 sector_t physical_start;
42023
42024 - atomic_t error_count;
42025 + atomic_unchecked_t error_count;
42026 };
42027
42028 struct stripe_c {
42029 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42030 kfree(sc);
42031 return r;
42032 }
42033 - atomic_set(&(sc->stripe[i].error_count), 0);
42034 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42035 }
42036
42037 ti->private = sc;
42038 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42039 DMEMIT("%d ", sc->stripes);
42040 for (i = 0; i < sc->stripes; i++) {
42041 DMEMIT("%s ", sc->stripe[i].dev->name);
42042 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42043 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42044 'D' : 'A';
42045 }
42046 buffer[i] = '\0';
42047 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42048 */
42049 for (i = 0; i < sc->stripes; i++)
42050 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42051 - atomic_inc(&(sc->stripe[i].error_count));
42052 - if (atomic_read(&(sc->stripe[i].error_count)) <
42053 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42054 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42055 DM_IO_ERROR_THRESHOLD)
42056 schedule_work(&sc->trigger_event);
42057 }
42058 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42059 index f221812..aca962b 100644
42060 --- a/drivers/md/dm-table.c
42061 +++ b/drivers/md/dm-table.c
42062 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42063 if (!dev_size)
42064 return 0;
42065
42066 - if ((start >= dev_size) || (start + len > dev_size)) {
42067 + if ((start >= dev_size) || (len > dev_size - start)) {
42068 DMWARN("%s: %s too small for target: "
42069 "start=%llu, len=%llu, dev_size=%llu",
42070 dm_device_name(ti->table->md), bdevname(bdev, b),
42071 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42072 index 60bce43..9b997d0 100644
42073 --- a/drivers/md/dm-thin-metadata.c
42074 +++ b/drivers/md/dm-thin-metadata.c
42075 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42076 {
42077 pmd->info.tm = pmd->tm;
42078 pmd->info.levels = 2;
42079 - pmd->info.value_type.context = pmd->data_sm;
42080 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42081 pmd->info.value_type.size = sizeof(__le64);
42082 pmd->info.value_type.inc = data_block_inc;
42083 pmd->info.value_type.dec = data_block_dec;
42084 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42085
42086 pmd->bl_info.tm = pmd->tm;
42087 pmd->bl_info.levels = 1;
42088 - pmd->bl_info.value_type.context = pmd->data_sm;
42089 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42090 pmd->bl_info.value_type.size = sizeof(__le64);
42091 pmd->bl_info.value_type.inc = data_block_inc;
42092 pmd->bl_info.value_type.dec = data_block_dec;
42093 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42094 index 9e39d2b..fb879a7 100644
42095 --- a/drivers/md/dm.c
42096 +++ b/drivers/md/dm.c
42097 @@ -178,9 +178,9 @@ struct mapped_device {
42098 /*
42099 * Event handling.
42100 */
42101 - atomic_t event_nr;
42102 + atomic_unchecked_t event_nr;
42103 wait_queue_head_t eventq;
42104 - atomic_t uevent_seq;
42105 + atomic_unchecked_t uevent_seq;
42106 struct list_head uevent_list;
42107 spinlock_t uevent_lock; /* Protect access to uevent_list */
42108
42109 @@ -1916,8 +1916,8 @@ static struct mapped_device *alloc_dev(int minor)
42110 spin_lock_init(&md->deferred_lock);
42111 atomic_set(&md->holders, 1);
42112 atomic_set(&md->open_count, 0);
42113 - atomic_set(&md->event_nr, 0);
42114 - atomic_set(&md->uevent_seq, 0);
42115 + atomic_set_unchecked(&md->event_nr, 0);
42116 + atomic_set_unchecked(&md->uevent_seq, 0);
42117 INIT_LIST_HEAD(&md->uevent_list);
42118 spin_lock_init(&md->uevent_lock);
42119
42120 @@ -2068,7 +2068,7 @@ static void event_callback(void *context)
42121
42122 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42123
42124 - atomic_inc(&md->event_nr);
42125 + atomic_inc_unchecked(&md->event_nr);
42126 wake_up(&md->eventq);
42127 }
42128
42129 @@ -2716,18 +2716,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42130
42131 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42132 {
42133 - return atomic_add_return(1, &md->uevent_seq);
42134 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42135 }
42136
42137 uint32_t dm_get_event_nr(struct mapped_device *md)
42138 {
42139 - return atomic_read(&md->event_nr);
42140 + return atomic_read_unchecked(&md->event_nr);
42141 }
42142
42143 int dm_wait_event(struct mapped_device *md, int event_nr)
42144 {
42145 return wait_event_interruptible(md->eventq,
42146 - (event_nr != atomic_read(&md->event_nr)));
42147 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42148 }
42149
42150 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42151 diff --git a/drivers/md/md.c b/drivers/md/md.c
42152 index 9f13e13..411a5b8 100644
42153 --- a/drivers/md/md.c
42154 +++ b/drivers/md/md.c
42155 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42156 * start build, activate spare
42157 */
42158 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42159 -static atomic_t md_event_count;
42160 +static atomic_unchecked_t md_event_count;
42161 void md_new_event(struct mddev *mddev)
42162 {
42163 - atomic_inc(&md_event_count);
42164 + atomic_inc_unchecked(&md_event_count);
42165 wake_up(&md_event_waiters);
42166 }
42167 EXPORT_SYMBOL_GPL(md_new_event);
42168 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42169 */
42170 static void md_new_event_inintr(struct mddev *mddev)
42171 {
42172 - atomic_inc(&md_event_count);
42173 + atomic_inc_unchecked(&md_event_count);
42174 wake_up(&md_event_waiters);
42175 }
42176
42177 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42178 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42179 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42180 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42181 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42182 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42183
42184 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42185 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42186 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42187 else
42188 sb->resync_offset = cpu_to_le64(0);
42189
42190 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42191 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42192
42193 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42194 sb->size = cpu_to_le64(mddev->dev_sectors);
42195 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42196 static ssize_t
42197 errors_show(struct md_rdev *rdev, char *page)
42198 {
42199 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42200 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42201 }
42202
42203 static ssize_t
42204 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42205 char *e;
42206 unsigned long n = simple_strtoul(buf, &e, 10);
42207 if (*buf && (*e == 0 || *e == '\n')) {
42208 - atomic_set(&rdev->corrected_errors, n);
42209 + atomic_set_unchecked(&rdev->corrected_errors, n);
42210 return len;
42211 }
42212 return -EINVAL;
42213 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42214 rdev->sb_loaded = 0;
42215 rdev->bb_page = NULL;
42216 atomic_set(&rdev->nr_pending, 0);
42217 - atomic_set(&rdev->read_errors, 0);
42218 - atomic_set(&rdev->corrected_errors, 0);
42219 + atomic_set_unchecked(&rdev->read_errors, 0);
42220 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42221
42222 INIT_LIST_HEAD(&rdev->same_set);
42223 init_waitqueue_head(&rdev->blocked_wait);
42224 @@ -7024,7 +7024,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42225
42226 spin_unlock(&pers_lock);
42227 seq_printf(seq, "\n");
42228 - seq->poll_event = atomic_read(&md_event_count);
42229 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42230 return 0;
42231 }
42232 if (v == (void*)2) {
42233 @@ -7127,7 +7127,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42234 return error;
42235
42236 seq = file->private_data;
42237 - seq->poll_event = atomic_read(&md_event_count);
42238 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42239 return error;
42240 }
42241
42242 @@ -7141,7 +7141,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42243 /* always allow read */
42244 mask = POLLIN | POLLRDNORM;
42245
42246 - if (seq->poll_event != atomic_read(&md_event_count))
42247 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42248 mask |= POLLERR | POLLPRI;
42249 return mask;
42250 }
42251 @@ -7185,7 +7185,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42252 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42253 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42254 (int)part_stat_read(&disk->part0, sectors[1]) -
42255 - atomic_read(&disk->sync_io);
42256 + atomic_read_unchecked(&disk->sync_io);
42257 /* sync IO will cause sync_io to increase before the disk_stats
42258 * as sync_io is counted when a request starts, and
42259 * disk_stats is counted when it completes.
42260 diff --git a/drivers/md/md.h b/drivers/md/md.h
42261 index 20f02c0..fd8c821 100644
42262 --- a/drivers/md/md.h
42263 +++ b/drivers/md/md.h
42264 @@ -94,13 +94,13 @@ struct md_rdev {
42265 * only maintained for arrays that
42266 * support hot removal
42267 */
42268 - atomic_t read_errors; /* number of consecutive read errors that
42269 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42270 * we have tried to ignore.
42271 */
42272 struct timespec last_read_error; /* monotonic time since our
42273 * last read error
42274 */
42275 - atomic_t corrected_errors; /* number of corrected read errors,
42276 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42277 * for reporting to userspace and storing
42278 * in superblock.
42279 */
42280 @@ -442,7 +442,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42281
42282 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42283 {
42284 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42285 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42286 }
42287
42288 struct md_personality
42289 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42290 index 3e6d115..ffecdeb 100644
42291 --- a/drivers/md/persistent-data/dm-space-map.h
42292 +++ b/drivers/md/persistent-data/dm-space-map.h
42293 @@ -71,6 +71,7 @@ struct dm_space_map {
42294 dm_sm_threshold_fn fn,
42295 void *context);
42296 };
42297 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42298
42299 /*----------------------------------------------------------------*/
42300
42301 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42302 index d60412c..8d4c982 100644
42303 --- a/drivers/md/raid1.c
42304 +++ b/drivers/md/raid1.c
42305 @@ -1823,7 +1823,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42306 if (r1_sync_page_io(rdev, sect, s,
42307 bio->bi_io_vec[idx].bv_page,
42308 READ) != 0)
42309 - atomic_add(s, &rdev->corrected_errors);
42310 + atomic_add_unchecked(s, &rdev->corrected_errors);
42311 }
42312 sectors -= s;
42313 sect += s;
42314 @@ -2050,7 +2050,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42315 test_bit(In_sync, &rdev->flags)) {
42316 if (r1_sync_page_io(rdev, sect, s,
42317 conf->tmppage, READ)) {
42318 - atomic_add(s, &rdev->corrected_errors);
42319 + atomic_add_unchecked(s, &rdev->corrected_errors);
42320 printk(KERN_INFO
42321 "md/raid1:%s: read error corrected "
42322 "(%d sectors at %llu on %s)\n",
42323 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42324 index df7b0a0..a257495 100644
42325 --- a/drivers/md/raid10.c
42326 +++ b/drivers/md/raid10.c
42327 @@ -1962,7 +1962,7 @@ static void end_sync_read(struct bio *bio, int error)
42328 /* The write handler will notice the lack of
42329 * R10BIO_Uptodate and record any errors etc
42330 */
42331 - atomic_add(r10_bio->sectors,
42332 + atomic_add_unchecked(r10_bio->sectors,
42333 &conf->mirrors[d].rdev->corrected_errors);
42334
42335 /* for reconstruct, we always reschedule after a read.
42336 @@ -2320,7 +2320,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42337 {
42338 struct timespec cur_time_mon;
42339 unsigned long hours_since_last;
42340 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42341 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42342
42343 ktime_get_ts(&cur_time_mon);
42344
42345 @@ -2342,9 +2342,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42346 * overflowing the shift of read_errors by hours_since_last.
42347 */
42348 if (hours_since_last >= 8 * sizeof(read_errors))
42349 - atomic_set(&rdev->read_errors, 0);
42350 + atomic_set_unchecked(&rdev->read_errors, 0);
42351 else
42352 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42353 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42354 }
42355
42356 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42357 @@ -2398,8 +2398,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42358 return;
42359
42360 check_decay_read_errors(mddev, rdev);
42361 - atomic_inc(&rdev->read_errors);
42362 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42363 + atomic_inc_unchecked(&rdev->read_errors);
42364 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42365 char b[BDEVNAME_SIZE];
42366 bdevname(rdev->bdev, b);
42367
42368 @@ -2407,7 +2407,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42369 "md/raid10:%s: %s: Raid device exceeded "
42370 "read_error threshold [cur %d:max %d]\n",
42371 mdname(mddev), b,
42372 - atomic_read(&rdev->read_errors), max_read_errors);
42373 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42374 printk(KERN_NOTICE
42375 "md/raid10:%s: %s: Failing raid device\n",
42376 mdname(mddev), b);
42377 @@ -2562,7 +2562,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42378 sect +
42379 choose_data_offset(r10_bio, rdev)),
42380 bdevname(rdev->bdev, b));
42381 - atomic_add(s, &rdev->corrected_errors);
42382 + atomic_add_unchecked(s, &rdev->corrected_errors);
42383 }
42384
42385 rdev_dec_pending(rdev, mddev);
42386 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42387 index 78ea443..7d57513 100644
42388 --- a/drivers/md/raid5.c
42389 +++ b/drivers/md/raid5.c
42390 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42391 mdname(conf->mddev), STRIPE_SECTORS,
42392 (unsigned long long)s,
42393 bdevname(rdev->bdev, b));
42394 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42395 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42396 clear_bit(R5_ReadError, &sh->dev[i].flags);
42397 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42398 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42399 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42400
42401 - if (atomic_read(&rdev->read_errors))
42402 - atomic_set(&rdev->read_errors, 0);
42403 + if (atomic_read_unchecked(&rdev->read_errors))
42404 + atomic_set_unchecked(&rdev->read_errors, 0);
42405 } else {
42406 const char *bdn = bdevname(rdev->bdev, b);
42407 int retry = 0;
42408 int set_bad = 0;
42409
42410 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42411 - atomic_inc(&rdev->read_errors);
42412 + atomic_inc_unchecked(&rdev->read_errors);
42413 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42414 printk_ratelimited(
42415 KERN_WARNING
42416 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42417 mdname(conf->mddev),
42418 (unsigned long long)s,
42419 bdn);
42420 - } else if (atomic_read(&rdev->read_errors)
42421 + } else if (atomic_read_unchecked(&rdev->read_errors)
42422 > conf->max_nr_stripes)
42423 printk(KERN_WARNING
42424 "md/raid:%s: Too many read errors, failing device %s.\n",
42425 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42426 index 401ef64..836e563 100644
42427 --- a/drivers/media/dvb-core/dvbdev.c
42428 +++ b/drivers/media/dvb-core/dvbdev.c
42429 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42430 const struct dvb_device *template, void *priv, int type)
42431 {
42432 struct dvb_device *dvbdev;
42433 - struct file_operations *dvbdevfops;
42434 + file_operations_no_const *dvbdevfops;
42435 struct device *clsdev;
42436 int minor;
42437 int id;
42438 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42439 index 9b6c3bb..baeb5c7 100644
42440 --- a/drivers/media/dvb-frontends/dib3000.h
42441 +++ b/drivers/media/dvb-frontends/dib3000.h
42442 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42443 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42444 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42445 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42446 -};
42447 +} __no_const;
42448
42449 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42450 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42451 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42452 index ecf21d9..b992428d 100644
42453 --- a/drivers/media/pci/cx88/cx88-video.c
42454 +++ b/drivers/media/pci/cx88/cx88-video.c
42455 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42456
42457 /* ------------------------------------------------------------------ */
42458
42459 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42460 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42461 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42462 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42463 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42464 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42465
42466 module_param_array(video_nr, int, NULL, 0444);
42467 module_param_array(vbi_nr, int, NULL, 0444);
42468 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42469 index c08ae3e..eb59af1 100644
42470 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42471 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42472 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42473 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42474
42475 /* ivtv instance counter */
42476 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42477 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42478
42479 /* Parameter declarations */
42480 static int cardtype[IVTV_MAX_CARDS];
42481 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42482 index dfd0a21..6bbb465 100644
42483 --- a/drivers/media/platform/omap/omap_vout.c
42484 +++ b/drivers/media/platform/omap/omap_vout.c
42485 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42486 OMAP_VIDEO2,
42487 };
42488
42489 -static struct videobuf_queue_ops video_vbq_ops;
42490 /* Variables configurable through module params*/
42491 static u32 video1_numbuffers = 3;
42492 static u32 video2_numbuffers = 3;
42493 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42494 {
42495 struct videobuf_queue *q;
42496 struct omap_vout_device *vout = NULL;
42497 + static struct videobuf_queue_ops video_vbq_ops = {
42498 + .buf_setup = omap_vout_buffer_setup,
42499 + .buf_prepare = omap_vout_buffer_prepare,
42500 + .buf_release = omap_vout_buffer_release,
42501 + .buf_queue = omap_vout_buffer_queue,
42502 + };
42503
42504 vout = video_drvdata(file);
42505 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42506 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42507 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42508
42509 q = &vout->vbq;
42510 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42511 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42512 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42513 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42514 spin_lock_init(&vout->vbq_lock);
42515
42516 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42517 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42518 index 04e6490..2df65bf 100644
42519 --- a/drivers/media/platform/s5p-tv/mixer.h
42520 +++ b/drivers/media/platform/s5p-tv/mixer.h
42521 @@ -156,7 +156,7 @@ struct mxr_layer {
42522 /** layer index (unique identifier) */
42523 int idx;
42524 /** callbacks for layer methods */
42525 - struct mxr_layer_ops ops;
42526 + struct mxr_layer_ops *ops;
42527 /** format array */
42528 const struct mxr_format **fmt_array;
42529 /** size of format array */
42530 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42531 index b93a21f..2535195 100644
42532 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42533 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42534 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42535 {
42536 struct mxr_layer *layer;
42537 int ret;
42538 - struct mxr_layer_ops ops = {
42539 + static struct mxr_layer_ops ops = {
42540 .release = mxr_graph_layer_release,
42541 .buffer_set = mxr_graph_buffer_set,
42542 .stream_set = mxr_graph_stream_set,
42543 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42544 index b713403..53cb5ad 100644
42545 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42546 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42547 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42548 layer->update_buf = next;
42549 }
42550
42551 - layer->ops.buffer_set(layer, layer->update_buf);
42552 + layer->ops->buffer_set(layer, layer->update_buf);
42553
42554 if (done && done != layer->shadow_buf)
42555 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42556 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42557 index 641b1f0..49cff30 100644
42558 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42559 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42560 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42561 layer->geo.src.height = layer->geo.src.full_height;
42562
42563 mxr_geometry_dump(mdev, &layer->geo);
42564 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42565 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42566 mxr_geometry_dump(mdev, &layer->geo);
42567 }
42568
42569 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42570 layer->geo.dst.full_width = mbus_fmt.width;
42571 layer->geo.dst.full_height = mbus_fmt.height;
42572 layer->geo.dst.field = mbus_fmt.field;
42573 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42574 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42575
42576 mxr_geometry_dump(mdev, &layer->geo);
42577 }
42578 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42579 /* set source size to highest accepted value */
42580 geo->src.full_width = max(geo->dst.full_width, pix->width);
42581 geo->src.full_height = max(geo->dst.full_height, pix->height);
42582 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42583 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42584 mxr_geometry_dump(mdev, &layer->geo);
42585 /* set cropping to total visible screen */
42586 geo->src.width = pix->width;
42587 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42588 geo->src.x_offset = 0;
42589 geo->src.y_offset = 0;
42590 /* assure consistency of geometry */
42591 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42592 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42593 mxr_geometry_dump(mdev, &layer->geo);
42594 /* set full size to lowest possible value */
42595 geo->src.full_width = 0;
42596 geo->src.full_height = 0;
42597 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42598 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42599 mxr_geometry_dump(mdev, &layer->geo);
42600
42601 /* returning results */
42602 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42603 target->width = s->r.width;
42604 target->height = s->r.height;
42605
42606 - layer->ops.fix_geometry(layer, stage, s->flags);
42607 + layer->ops->fix_geometry(layer, stage, s->flags);
42608
42609 /* retrieve update selection rectangle */
42610 res.left = target->x_offset;
42611 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42612 mxr_output_get(mdev);
42613
42614 mxr_layer_update_output(layer);
42615 - layer->ops.format_set(layer);
42616 + layer->ops->format_set(layer);
42617 /* enabling layer in hardware */
42618 spin_lock_irqsave(&layer->enq_slock, flags);
42619 layer->state = MXR_LAYER_STREAMING;
42620 spin_unlock_irqrestore(&layer->enq_slock, flags);
42621
42622 - layer->ops.stream_set(layer, MXR_ENABLE);
42623 + layer->ops->stream_set(layer, MXR_ENABLE);
42624 mxr_streamer_get(mdev);
42625
42626 return 0;
42627 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42628 spin_unlock_irqrestore(&layer->enq_slock, flags);
42629
42630 /* disabling layer in hardware */
42631 - layer->ops.stream_set(layer, MXR_DISABLE);
42632 + layer->ops->stream_set(layer, MXR_DISABLE);
42633 /* remove one streamer */
42634 mxr_streamer_put(mdev);
42635 /* allow changes in output configuration */
42636 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42637
42638 void mxr_layer_release(struct mxr_layer *layer)
42639 {
42640 - if (layer->ops.release)
42641 - layer->ops.release(layer);
42642 + if (layer->ops->release)
42643 + layer->ops->release(layer);
42644 }
42645
42646 void mxr_base_layer_release(struct mxr_layer *layer)
42647 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42648
42649 layer->mdev = mdev;
42650 layer->idx = idx;
42651 - layer->ops = *ops;
42652 + layer->ops = ops;
42653
42654 spin_lock_init(&layer->enq_slock);
42655 INIT_LIST_HEAD(&layer->enq_list);
42656 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42657 index 3d13a63..da31bf1 100644
42658 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42659 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42660 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42661 {
42662 struct mxr_layer *layer;
42663 int ret;
42664 - struct mxr_layer_ops ops = {
42665 + static struct mxr_layer_ops ops = {
42666 .release = mxr_vp_layer_release,
42667 .buffer_set = mxr_vp_buffer_set,
42668 .stream_set = mxr_vp_stream_set,
42669 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42670 index 545c04c..a14bded 100644
42671 --- a/drivers/media/radio/radio-cadet.c
42672 +++ b/drivers/media/radio/radio-cadet.c
42673 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42674 unsigned char readbuf[RDS_BUFFER];
42675 int i = 0;
42676
42677 + if (count > RDS_BUFFER)
42678 + return -EFAULT;
42679 mutex_lock(&dev->lock);
42680 if (dev->rdsstat == 0)
42681 cadet_start_rds(dev);
42682 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42683 while (i < count && dev->rdsin != dev->rdsout)
42684 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42685
42686 - if (i && copy_to_user(data, readbuf, i))
42687 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42688 i = -EFAULT;
42689 unlock:
42690 mutex_unlock(&dev->lock);
42691 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42692 index bd4d3a7..ffc0b9d 100644
42693 --- a/drivers/media/radio/radio-maxiradio.c
42694 +++ b/drivers/media/radio/radio-maxiradio.c
42695 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42696 /* TEA5757 pin mappings */
42697 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42698
42699 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42700 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42701
42702 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42703 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42704 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42705 index 8fa18ab..caee70f 100644
42706 --- a/drivers/media/radio/radio-shark.c
42707 +++ b/drivers/media/radio/radio-shark.c
42708 @@ -79,7 +79,7 @@ struct shark_device {
42709 u32 last_val;
42710 };
42711
42712 -static atomic_t shark_instance = ATOMIC_INIT(0);
42713 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42714
42715 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42716 {
42717 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42718 index 9fb6697..f167415 100644
42719 --- a/drivers/media/radio/radio-shark2.c
42720 +++ b/drivers/media/radio/radio-shark2.c
42721 @@ -74,7 +74,7 @@ struct shark_device {
42722 u8 *transfer_buffer;
42723 };
42724
42725 -static atomic_t shark_instance = ATOMIC_INIT(0);
42726 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42727
42728 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42729 {
42730 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42731 index 9c9084c..a9e8dfb 100644
42732 --- a/drivers/media/radio/radio-si476x.c
42733 +++ b/drivers/media/radio/radio-si476x.c
42734 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42735 struct si476x_radio *radio;
42736 struct v4l2_ctrl *ctrl;
42737
42738 - static atomic_t instance = ATOMIC_INIT(0);
42739 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42740
42741 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42742 if (!radio)
42743 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42744 index 1cf382a..c22998c 100644
42745 --- a/drivers/media/rc/rc-main.c
42746 +++ b/drivers/media/rc/rc-main.c
42747 @@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42748 int rc_register_device(struct rc_dev *dev)
42749 {
42750 static bool raw_init = false; /* raw decoders loaded? */
42751 - static atomic_t devno = ATOMIC_INIT(0);
42752 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42753 struct rc_map *rc_map;
42754 const char *path;
42755 int rc;
42756 @@ -1061,7 +1061,7 @@ int rc_register_device(struct rc_dev *dev)
42757 */
42758 mutex_lock(&dev->lock);
42759
42760 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
42761 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
42762 dev_set_name(&dev->dev, "rc%ld", dev->devno);
42763 dev_set_drvdata(&dev->dev, dev);
42764 rc = device_add(&dev->dev);
42765 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
42766 index 3940bb0..fb3952a 100644
42767 --- a/drivers/media/usb/dvb-usb/cxusb.c
42768 +++ b/drivers/media/usb/dvb-usb/cxusb.c
42769 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
42770
42771 struct dib0700_adapter_state {
42772 int (*set_param_save) (struct dvb_frontend *);
42773 -};
42774 +} __no_const;
42775
42776 static int dib7070_set_param_override(struct dvb_frontend *fe)
42777 {
42778 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
42779 index 6e237b6..dc25556 100644
42780 --- a/drivers/media/usb/dvb-usb/dw2102.c
42781 +++ b/drivers/media/usb/dvb-usb/dw2102.c
42782 @@ -118,7 +118,7 @@ struct su3000_state {
42783
42784 struct s6x0_state {
42785 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
42786 -};
42787 +} __no_const;
42788
42789 /* debug */
42790 static int dvb_usb_dw2102_debug;
42791 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42792 index 8f7a6a4..59502dd 100644
42793 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42794 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42795 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
42796 __u32 reserved;
42797 };
42798
42799 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42800 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42801 enum v4l2_memory memory)
42802 {
42803 void __user *up_pln;
42804 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42805 return 0;
42806 }
42807
42808 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42809 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42810 enum v4l2_memory memory)
42811 {
42812 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
42813 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
42814 put_user(kp->start_block, &up->start_block) ||
42815 put_user(kp->blocks, &up->blocks) ||
42816 put_user(tmp, &up->edid) ||
42817 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
42818 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
42819 return -EFAULT;
42820 return 0;
42821 }
42822 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
42823 index 02d1b63..5fd6b16 100644
42824 --- a/drivers/media/v4l2-core/v4l2-device.c
42825 +++ b/drivers/media/v4l2-core/v4l2-device.c
42826 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
42827 EXPORT_SYMBOL_GPL(v4l2_device_put);
42828
42829 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
42830 - atomic_t *instance)
42831 + atomic_unchecked_t *instance)
42832 {
42833 - int num = atomic_inc_return(instance) - 1;
42834 + int num = atomic_inc_return_unchecked(instance) - 1;
42835 int len = strlen(basename);
42836
42837 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
42838 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
42839 index 68e6b5e..d8b923e 100644
42840 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
42841 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
42842 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
42843 struct file *file, void *fh, void *p);
42844 } u;
42845 void (*debug)(const void *arg, bool write_only);
42846 -};
42847 +} __do_const;
42848 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
42849
42850 /* This control needs a priority check */
42851 #define INFO_FL_PRIO (1 << 0)
42852 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
42853 struct video_device *vfd = video_devdata(file);
42854 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
42855 bool write_only = false;
42856 - struct v4l2_ioctl_info default_info;
42857 + v4l2_ioctl_info_no_const default_info;
42858 const struct v4l2_ioctl_info *info;
42859 void *fh = file->private_data;
42860 struct v4l2_fh *vfh = NULL;
42861 @@ -2194,7 +2195,7 @@ done:
42862 }
42863
42864 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42865 - void * __user *user_ptr, void ***kernel_ptr)
42866 + void __user **user_ptr, void ***kernel_ptr)
42867 {
42868 int ret = 0;
42869
42870 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42871 ret = -EINVAL;
42872 break;
42873 }
42874 - *user_ptr = (void __user *)buf->m.planes;
42875 + *user_ptr = (void __force_user *)buf->m.planes;
42876 *kernel_ptr = (void *)&buf->m.planes;
42877 *array_size = sizeof(struct v4l2_plane) * buf->length;
42878 ret = 1;
42879 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42880 ret = -EINVAL;
42881 break;
42882 }
42883 - *user_ptr = (void __user *)ctrls->controls;
42884 + *user_ptr = (void __force_user *)ctrls->controls;
42885 *kernel_ptr = (void *)&ctrls->controls;
42886 *array_size = sizeof(struct v4l2_ext_control)
42887 * ctrls->count;
42888 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
42889 index 767ff4d..c69d259 100644
42890 --- a/drivers/message/fusion/mptbase.c
42891 +++ b/drivers/message/fusion/mptbase.c
42892 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42893 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
42894 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
42895
42896 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42897 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
42898 +#else
42899 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
42900 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
42901 +#endif
42902 +
42903 /*
42904 * Rounding UP to nearest 4-kB boundary here...
42905 */
42906 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42907 ioc->facts.GlobalCredits);
42908
42909 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
42910 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42911 + NULL, NULL);
42912 +#else
42913 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
42914 +#endif
42915 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
42916 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
42917 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
42918 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
42919 index dd239bd..689c4f7 100644
42920 --- a/drivers/message/fusion/mptsas.c
42921 +++ b/drivers/message/fusion/mptsas.c
42922 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
42923 return 0;
42924 }
42925
42926 +static inline void
42927 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42928 +{
42929 + if (phy_info->port_details) {
42930 + phy_info->port_details->rphy = rphy;
42931 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42932 + ioc->name, rphy));
42933 + }
42934 +
42935 + if (rphy) {
42936 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42937 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42938 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42939 + ioc->name, rphy, rphy->dev.release));
42940 + }
42941 +}
42942 +
42943 /* no mutex */
42944 static void
42945 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
42946 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
42947 return NULL;
42948 }
42949
42950 -static inline void
42951 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42952 -{
42953 - if (phy_info->port_details) {
42954 - phy_info->port_details->rphy = rphy;
42955 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42956 - ioc->name, rphy));
42957 - }
42958 -
42959 - if (rphy) {
42960 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42961 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42962 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42963 - ioc->name, rphy, rphy->dev.release));
42964 - }
42965 -}
42966 -
42967 static inline struct sas_port *
42968 mptsas_get_port(struct mptsas_phyinfo *phy_info)
42969 {
42970 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
42971 index 727819c..ad74694 100644
42972 --- a/drivers/message/fusion/mptscsih.c
42973 +++ b/drivers/message/fusion/mptscsih.c
42974 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
42975
42976 h = shost_priv(SChost);
42977
42978 - if (h) {
42979 - if (h->info_kbuf == NULL)
42980 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42981 - return h->info_kbuf;
42982 - h->info_kbuf[0] = '\0';
42983 + if (!h)
42984 + return NULL;
42985
42986 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
42987 - h->info_kbuf[size-1] = '\0';
42988 - }
42989 + if (h->info_kbuf == NULL)
42990 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42991 + return h->info_kbuf;
42992 + h->info_kbuf[0] = '\0';
42993 +
42994 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
42995 + h->info_kbuf[size-1] = '\0';
42996
42997 return h->info_kbuf;
42998 }
42999 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43000 index b7d87cd..9890039 100644
43001 --- a/drivers/message/i2o/i2o_proc.c
43002 +++ b/drivers/message/i2o/i2o_proc.c
43003 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43004 "Array Controller Device"
43005 };
43006
43007 -static char *chtostr(char *tmp, u8 *chars, int n)
43008 -{
43009 - tmp[0] = 0;
43010 - return strncat(tmp, (char *)chars, n);
43011 -}
43012 -
43013 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43014 char *group)
43015 {
43016 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43017 } *result;
43018
43019 i2o_exec_execute_ddm_table ddm_table;
43020 - char tmp[28 + 1];
43021
43022 result = kmalloc(sizeof(*result), GFP_KERNEL);
43023 if (!result)
43024 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43025
43026 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43027 seq_printf(seq, "%-#8x", ddm_table.module_id);
43028 - seq_printf(seq, "%-29s",
43029 - chtostr(tmp, ddm_table.module_name_version, 28));
43030 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43031 seq_printf(seq, "%9d ", ddm_table.data_size);
43032 seq_printf(seq, "%8d", ddm_table.code_size);
43033
43034 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43035
43036 i2o_driver_result_table *result;
43037 i2o_driver_store_table *dst;
43038 - char tmp[28 + 1];
43039
43040 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43041 if (result == NULL)
43042 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43043
43044 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43045 seq_printf(seq, "%-#8x", dst->module_id);
43046 - seq_printf(seq, "%-29s",
43047 - chtostr(tmp, dst->module_name_version, 28));
43048 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43049 + seq_printf(seq, "%-.28s", dst->module_name_version);
43050 + seq_printf(seq, "%-.8s", dst->date);
43051 seq_printf(seq, "%8d ", dst->module_size);
43052 seq_printf(seq, "%8d ", dst->mpb_size);
43053 seq_printf(seq, "0x%04x", dst->module_flags);
43054 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43055 // == (allow) 512d bytes (max)
43056 static u16 *work16 = (u16 *) work32;
43057 int token;
43058 - char tmp[16 + 1];
43059
43060 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43061
43062 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43063 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43064 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43065 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43066 - seq_printf(seq, "Vendor info : %s\n",
43067 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43068 - seq_printf(seq, "Product info : %s\n",
43069 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43070 - seq_printf(seq, "Description : %s\n",
43071 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43072 - seq_printf(seq, "Product rev. : %s\n",
43073 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43074 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43075 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43076 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43077 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43078
43079 seq_printf(seq, "Serial number : ");
43080 print_serial_number(seq, (u8 *) (work32 + 16),
43081 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43082 u8 pad[256]; // allow up to 256 byte (max) serial number
43083 } result;
43084
43085 - char tmp[24 + 1];
43086 -
43087 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43088
43089 if (token < 0) {
43090 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43091 }
43092
43093 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43094 - seq_printf(seq, "Module name : %s\n",
43095 - chtostr(tmp, result.module_name, 24));
43096 - seq_printf(seq, "Module revision : %s\n",
43097 - chtostr(tmp, result.module_rev, 8));
43098 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43099 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43100
43101 seq_printf(seq, "Serial number : ");
43102 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43103 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43104 u8 instance_number[4];
43105 } result;
43106
43107 - char tmp[64 + 1];
43108 -
43109 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43110
43111 if (token < 0) {
43112 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43113 return 0;
43114 }
43115
43116 - seq_printf(seq, "Device name : %s\n",
43117 - chtostr(tmp, result.device_name, 64));
43118 - seq_printf(seq, "Service name : %s\n",
43119 - chtostr(tmp, result.service_name, 64));
43120 - seq_printf(seq, "Physical name : %s\n",
43121 - chtostr(tmp, result.physical_location, 64));
43122 - seq_printf(seq, "Instance number : %s\n",
43123 - chtostr(tmp, result.instance_number, 4));
43124 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43125 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43126 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43127 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43128
43129 return 0;
43130 }
43131 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43132 index a8c08f3..155fe3d 100644
43133 --- a/drivers/message/i2o/iop.c
43134 +++ b/drivers/message/i2o/iop.c
43135 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43136
43137 spin_lock_irqsave(&c->context_list_lock, flags);
43138
43139 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43140 - atomic_inc(&c->context_list_counter);
43141 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43142 + atomic_inc_unchecked(&c->context_list_counter);
43143
43144 - entry->context = atomic_read(&c->context_list_counter);
43145 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43146
43147 list_add(&entry->list, &c->context_list);
43148
43149 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43150
43151 #if BITS_PER_LONG == 64
43152 spin_lock_init(&c->context_list_lock);
43153 - atomic_set(&c->context_list_counter, 0);
43154 + atomic_set_unchecked(&c->context_list_counter, 0);
43155 INIT_LIST_HEAD(&c->context_list);
43156 #endif
43157
43158 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43159 index fcbb2e9..2635e11 100644
43160 --- a/drivers/mfd/janz-cmodio.c
43161 +++ b/drivers/mfd/janz-cmodio.c
43162 @@ -13,6 +13,7 @@
43163
43164 #include <linux/kernel.h>
43165 #include <linux/module.h>
43166 +#include <linux/slab.h>
43167 #include <linux/init.h>
43168 #include <linux/pci.h>
43169 #include <linux/interrupt.h>
43170 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43171 index 9aa6d1e..1631bfc 100644
43172 --- a/drivers/mfd/twl4030-irq.c
43173 +++ b/drivers/mfd/twl4030-irq.c
43174 @@ -35,6 +35,7 @@
43175 #include <linux/of.h>
43176 #include <linux/irqdomain.h>
43177 #include <linux/i2c/twl.h>
43178 +#include <asm/pgtable.h>
43179
43180 #include "twl-core.h"
43181
43182 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43183 * Install an irq handler for each of the SIH modules;
43184 * clone dummy irq_chip since PIH can't *do* anything
43185 */
43186 - twl4030_irq_chip = dummy_irq_chip;
43187 - twl4030_irq_chip.name = "twl4030";
43188 + pax_open_kernel();
43189 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43190 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43191
43192 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43193 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43194 + pax_close_kernel();
43195
43196 for (i = irq_base; i < irq_end; i++) {
43197 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43198 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
43199 index 277a8db..0e0b754 100644
43200 --- a/drivers/mfd/twl6030-irq.c
43201 +++ b/drivers/mfd/twl6030-irq.c
43202 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
43203 * install an irq handler for each of the modules;
43204 * clone dummy irq_chip since PIH can't *do* anything
43205 */
43206 - twl6030_irq_chip = dummy_irq_chip;
43207 - twl6030_irq_chip.name = "twl6030";
43208 - twl6030_irq_chip.irq_set_type = NULL;
43209 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43210 + pax_open_kernel();
43211 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
43212 + *(const char **)&twl6030_irq_chip.name = "twl6030";
43213 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
43214 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43215 + pax_close_kernel();
43216
43217 for (i = irq_base; i < irq_end; i++) {
43218 irq_set_chip_and_handler(i, &twl6030_irq_chip,
43219 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43220 index f32550a..e3e52a2 100644
43221 --- a/drivers/misc/c2port/core.c
43222 +++ b/drivers/misc/c2port/core.c
43223 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
43224 mutex_init(&c2dev->mutex);
43225
43226 /* Create binary file */
43227 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43228 + pax_open_kernel();
43229 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43230 + pax_close_kernel();
43231 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
43232 if (unlikely(ret))
43233 goto error_device_create_bin_file;
43234 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43235 index 36f5d52..32311c3 100644
43236 --- a/drivers/misc/kgdbts.c
43237 +++ b/drivers/misc/kgdbts.c
43238 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43239 char before[BREAK_INSTR_SIZE];
43240 char after[BREAK_INSTR_SIZE];
43241
43242 - probe_kernel_read(before, (char *)kgdbts_break_test,
43243 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43244 BREAK_INSTR_SIZE);
43245 init_simple_test();
43246 ts.tst = plant_and_detach_test;
43247 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43248 /* Activate test with initial breakpoint */
43249 if (!is_early)
43250 kgdb_breakpoint();
43251 - probe_kernel_read(after, (char *)kgdbts_break_test,
43252 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43253 BREAK_INSTR_SIZE);
43254 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43255 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43256 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43257 index 036effe..b3a6336 100644
43258 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43259 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43260 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43261 * the lid is closed. This leads to interrupts as soon as a little move
43262 * is done.
43263 */
43264 - atomic_inc(&lis3->count);
43265 + atomic_inc_unchecked(&lis3->count);
43266
43267 wake_up_interruptible(&lis3->misc_wait);
43268 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43269 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43270 if (lis3->pm_dev)
43271 pm_runtime_get_sync(lis3->pm_dev);
43272
43273 - atomic_set(&lis3->count, 0);
43274 + atomic_set_unchecked(&lis3->count, 0);
43275 return 0;
43276 }
43277
43278 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43279 add_wait_queue(&lis3->misc_wait, &wait);
43280 while (true) {
43281 set_current_state(TASK_INTERRUPTIBLE);
43282 - data = atomic_xchg(&lis3->count, 0);
43283 + data = atomic_xchg_unchecked(&lis3->count, 0);
43284 if (data)
43285 break;
43286
43287 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43288 struct lis3lv02d, miscdev);
43289
43290 poll_wait(file, &lis3->misc_wait, wait);
43291 - if (atomic_read(&lis3->count))
43292 + if (atomic_read_unchecked(&lis3->count))
43293 return POLLIN | POLLRDNORM;
43294 return 0;
43295 }
43296 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43297 index c439c82..1f20f57 100644
43298 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43299 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43300 @@ -297,7 +297,7 @@ struct lis3lv02d {
43301 struct input_polled_dev *idev; /* input device */
43302 struct platform_device *pdev; /* platform device */
43303 struct regulator_bulk_data regulators[2];
43304 - atomic_t count; /* interrupt count after last read */
43305 + atomic_unchecked_t count; /* interrupt count after last read */
43306 union axis_conversion ac; /* hw -> logical axis */
43307 int mapped_btns[3];
43308
43309 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43310 index 2f30bad..c4c13d0 100644
43311 --- a/drivers/misc/sgi-gru/gruhandles.c
43312 +++ b/drivers/misc/sgi-gru/gruhandles.c
43313 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43314 unsigned long nsec;
43315
43316 nsec = CLKS2NSEC(clks);
43317 - atomic_long_inc(&mcs_op_statistics[op].count);
43318 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43319 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43320 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43321 if (mcs_op_statistics[op].max < nsec)
43322 mcs_op_statistics[op].max = nsec;
43323 }
43324 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43325 index 4f76359..cdfcb2e 100644
43326 --- a/drivers/misc/sgi-gru/gruprocfs.c
43327 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43328 @@ -32,9 +32,9 @@
43329
43330 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43331
43332 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43333 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43334 {
43335 - unsigned long val = atomic_long_read(v);
43336 + unsigned long val = atomic_long_read_unchecked(v);
43337
43338 seq_printf(s, "%16lu %s\n", val, id);
43339 }
43340 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43341
43342 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43343 for (op = 0; op < mcsop_last; op++) {
43344 - count = atomic_long_read(&mcs_op_statistics[op].count);
43345 - total = atomic_long_read(&mcs_op_statistics[op].total);
43346 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43347 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43348 max = mcs_op_statistics[op].max;
43349 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43350 count ? total / count : 0, max);
43351 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43352 index 5c3ce24..4915ccb 100644
43353 --- a/drivers/misc/sgi-gru/grutables.h
43354 +++ b/drivers/misc/sgi-gru/grutables.h
43355 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43356 * GRU statistics.
43357 */
43358 struct gru_stats_s {
43359 - atomic_long_t vdata_alloc;
43360 - atomic_long_t vdata_free;
43361 - atomic_long_t gts_alloc;
43362 - atomic_long_t gts_free;
43363 - atomic_long_t gms_alloc;
43364 - atomic_long_t gms_free;
43365 - atomic_long_t gts_double_allocate;
43366 - atomic_long_t assign_context;
43367 - atomic_long_t assign_context_failed;
43368 - atomic_long_t free_context;
43369 - atomic_long_t load_user_context;
43370 - atomic_long_t load_kernel_context;
43371 - atomic_long_t lock_kernel_context;
43372 - atomic_long_t unlock_kernel_context;
43373 - atomic_long_t steal_user_context;
43374 - atomic_long_t steal_kernel_context;
43375 - atomic_long_t steal_context_failed;
43376 - atomic_long_t nopfn;
43377 - atomic_long_t asid_new;
43378 - atomic_long_t asid_next;
43379 - atomic_long_t asid_wrap;
43380 - atomic_long_t asid_reuse;
43381 - atomic_long_t intr;
43382 - atomic_long_t intr_cbr;
43383 - atomic_long_t intr_tfh;
43384 - atomic_long_t intr_spurious;
43385 - atomic_long_t intr_mm_lock_failed;
43386 - atomic_long_t call_os;
43387 - atomic_long_t call_os_wait_queue;
43388 - atomic_long_t user_flush_tlb;
43389 - atomic_long_t user_unload_context;
43390 - atomic_long_t user_exception;
43391 - atomic_long_t set_context_option;
43392 - atomic_long_t check_context_retarget_intr;
43393 - atomic_long_t check_context_unload;
43394 - atomic_long_t tlb_dropin;
43395 - atomic_long_t tlb_preload_page;
43396 - atomic_long_t tlb_dropin_fail_no_asid;
43397 - atomic_long_t tlb_dropin_fail_upm;
43398 - atomic_long_t tlb_dropin_fail_invalid;
43399 - atomic_long_t tlb_dropin_fail_range_active;
43400 - atomic_long_t tlb_dropin_fail_idle;
43401 - atomic_long_t tlb_dropin_fail_fmm;
43402 - atomic_long_t tlb_dropin_fail_no_exception;
43403 - atomic_long_t tfh_stale_on_fault;
43404 - atomic_long_t mmu_invalidate_range;
43405 - atomic_long_t mmu_invalidate_page;
43406 - atomic_long_t flush_tlb;
43407 - atomic_long_t flush_tlb_gru;
43408 - atomic_long_t flush_tlb_gru_tgh;
43409 - atomic_long_t flush_tlb_gru_zero_asid;
43410 + atomic_long_unchecked_t vdata_alloc;
43411 + atomic_long_unchecked_t vdata_free;
43412 + atomic_long_unchecked_t gts_alloc;
43413 + atomic_long_unchecked_t gts_free;
43414 + atomic_long_unchecked_t gms_alloc;
43415 + atomic_long_unchecked_t gms_free;
43416 + atomic_long_unchecked_t gts_double_allocate;
43417 + atomic_long_unchecked_t assign_context;
43418 + atomic_long_unchecked_t assign_context_failed;
43419 + atomic_long_unchecked_t free_context;
43420 + atomic_long_unchecked_t load_user_context;
43421 + atomic_long_unchecked_t load_kernel_context;
43422 + atomic_long_unchecked_t lock_kernel_context;
43423 + atomic_long_unchecked_t unlock_kernel_context;
43424 + atomic_long_unchecked_t steal_user_context;
43425 + atomic_long_unchecked_t steal_kernel_context;
43426 + atomic_long_unchecked_t steal_context_failed;
43427 + atomic_long_unchecked_t nopfn;
43428 + atomic_long_unchecked_t asid_new;
43429 + atomic_long_unchecked_t asid_next;
43430 + atomic_long_unchecked_t asid_wrap;
43431 + atomic_long_unchecked_t asid_reuse;
43432 + atomic_long_unchecked_t intr;
43433 + atomic_long_unchecked_t intr_cbr;
43434 + atomic_long_unchecked_t intr_tfh;
43435 + atomic_long_unchecked_t intr_spurious;
43436 + atomic_long_unchecked_t intr_mm_lock_failed;
43437 + atomic_long_unchecked_t call_os;
43438 + atomic_long_unchecked_t call_os_wait_queue;
43439 + atomic_long_unchecked_t user_flush_tlb;
43440 + atomic_long_unchecked_t user_unload_context;
43441 + atomic_long_unchecked_t user_exception;
43442 + atomic_long_unchecked_t set_context_option;
43443 + atomic_long_unchecked_t check_context_retarget_intr;
43444 + atomic_long_unchecked_t check_context_unload;
43445 + atomic_long_unchecked_t tlb_dropin;
43446 + atomic_long_unchecked_t tlb_preload_page;
43447 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43448 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43449 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43450 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43451 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43452 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43453 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43454 + atomic_long_unchecked_t tfh_stale_on_fault;
43455 + atomic_long_unchecked_t mmu_invalidate_range;
43456 + atomic_long_unchecked_t mmu_invalidate_page;
43457 + atomic_long_unchecked_t flush_tlb;
43458 + atomic_long_unchecked_t flush_tlb_gru;
43459 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43460 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43461
43462 - atomic_long_t copy_gpa;
43463 - atomic_long_t read_gpa;
43464 + atomic_long_unchecked_t copy_gpa;
43465 + atomic_long_unchecked_t read_gpa;
43466
43467 - atomic_long_t mesq_receive;
43468 - atomic_long_t mesq_receive_none;
43469 - atomic_long_t mesq_send;
43470 - atomic_long_t mesq_send_failed;
43471 - atomic_long_t mesq_noop;
43472 - atomic_long_t mesq_send_unexpected_error;
43473 - atomic_long_t mesq_send_lb_overflow;
43474 - atomic_long_t mesq_send_qlimit_reached;
43475 - atomic_long_t mesq_send_amo_nacked;
43476 - atomic_long_t mesq_send_put_nacked;
43477 - atomic_long_t mesq_page_overflow;
43478 - atomic_long_t mesq_qf_locked;
43479 - atomic_long_t mesq_qf_noop_not_full;
43480 - atomic_long_t mesq_qf_switch_head_failed;
43481 - atomic_long_t mesq_qf_unexpected_error;
43482 - atomic_long_t mesq_noop_unexpected_error;
43483 - atomic_long_t mesq_noop_lb_overflow;
43484 - atomic_long_t mesq_noop_qlimit_reached;
43485 - atomic_long_t mesq_noop_amo_nacked;
43486 - atomic_long_t mesq_noop_put_nacked;
43487 - atomic_long_t mesq_noop_page_overflow;
43488 + atomic_long_unchecked_t mesq_receive;
43489 + atomic_long_unchecked_t mesq_receive_none;
43490 + atomic_long_unchecked_t mesq_send;
43491 + atomic_long_unchecked_t mesq_send_failed;
43492 + atomic_long_unchecked_t mesq_noop;
43493 + atomic_long_unchecked_t mesq_send_unexpected_error;
43494 + atomic_long_unchecked_t mesq_send_lb_overflow;
43495 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43496 + atomic_long_unchecked_t mesq_send_amo_nacked;
43497 + atomic_long_unchecked_t mesq_send_put_nacked;
43498 + atomic_long_unchecked_t mesq_page_overflow;
43499 + atomic_long_unchecked_t mesq_qf_locked;
43500 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43501 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43502 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43503 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43504 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43505 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43506 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43507 + atomic_long_unchecked_t mesq_noop_put_nacked;
43508 + atomic_long_unchecked_t mesq_noop_page_overflow;
43509
43510 };
43511
43512 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43513 tghop_invalidate, mcsop_last};
43514
43515 struct mcs_op_statistic {
43516 - atomic_long_t count;
43517 - atomic_long_t total;
43518 + atomic_long_unchecked_t count;
43519 + atomic_long_unchecked_t total;
43520 unsigned long max;
43521 };
43522
43523 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43524
43525 #define STAT(id) do { \
43526 if (gru_options & OPT_STATS) \
43527 - atomic_long_inc(&gru_stats.id); \
43528 + atomic_long_inc_unchecked(&gru_stats.id); \
43529 } while (0)
43530
43531 #ifdef CONFIG_SGI_GRU_DEBUG
43532 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43533 index c862cd4..0d176fe 100644
43534 --- a/drivers/misc/sgi-xp/xp.h
43535 +++ b/drivers/misc/sgi-xp/xp.h
43536 @@ -288,7 +288,7 @@ struct xpc_interface {
43537 xpc_notify_func, void *);
43538 void (*received) (short, int, void *);
43539 enum xp_retval (*partid_to_nasids) (short, void *);
43540 -};
43541 +} __no_const;
43542
43543 extern struct xpc_interface xpc_interface;
43544
43545 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43546 index b94d5f7..7f494c5 100644
43547 --- a/drivers/misc/sgi-xp/xpc.h
43548 +++ b/drivers/misc/sgi-xp/xpc.h
43549 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43550 void (*received_payload) (struct xpc_channel *, void *);
43551 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43552 };
43553 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43554
43555 /* struct xpc_partition act_state values (for XPC HB) */
43556
43557 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43558 /* found in xpc_main.c */
43559 extern struct device *xpc_part;
43560 extern struct device *xpc_chan;
43561 -extern struct xpc_arch_operations xpc_arch_ops;
43562 +extern xpc_arch_operations_no_const xpc_arch_ops;
43563 extern int xpc_disengage_timelimit;
43564 extern int xpc_disengage_timedout;
43565 extern int xpc_activate_IRQ_rcvd;
43566 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43567 index 82dc574..8539ab2 100644
43568 --- a/drivers/misc/sgi-xp/xpc_main.c
43569 +++ b/drivers/misc/sgi-xp/xpc_main.c
43570 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43571 .notifier_call = xpc_system_die,
43572 };
43573
43574 -struct xpc_arch_operations xpc_arch_ops;
43575 +xpc_arch_operations_no_const xpc_arch_ops;
43576
43577 /*
43578 * Timer function to enforce the timelimit on the partition disengage.
43579 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43580
43581 if (((die_args->trapnr == X86_TRAP_MF) ||
43582 (die_args->trapnr == X86_TRAP_XF)) &&
43583 - !user_mode_vm(die_args->regs))
43584 + !user_mode(die_args->regs))
43585 xpc_die_deactivate();
43586
43587 break;
43588 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43589 index 837fc73..acb5862 100644
43590 --- a/drivers/mmc/core/mmc_ops.c
43591 +++ b/drivers/mmc/core/mmc_ops.c
43592 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43593 void *data_buf;
43594 int is_on_stack;
43595
43596 - is_on_stack = object_is_on_stack(buf);
43597 + is_on_stack = object_starts_on_stack(buf);
43598 if (is_on_stack) {
43599 /*
43600 * dma onto stack is unsafe/nonportable, but callers to this
43601 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43602 index 81b2994..dce857e 100644
43603 --- a/drivers/mmc/host/dw_mmc.h
43604 +++ b/drivers/mmc/host/dw_mmc.h
43605 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43606 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43607 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43608 int (*parse_dt)(struct dw_mci *host);
43609 -};
43610 +} __do_const;
43611 #endif /* _DW_MMC_H_ */
43612 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43613 index c3785ed..1984c44 100644
43614 --- a/drivers/mmc/host/mmci.c
43615 +++ b/drivers/mmc/host/mmci.c
43616 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43617 }
43618
43619 if (variant->busy_detect) {
43620 - mmci_ops.card_busy = mmci_card_busy;
43621 + pax_open_kernel();
43622 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43623 + pax_close_kernel();
43624 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43625 }
43626
43627 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43628 index 926aaf6..8e153e2 100644
43629 --- a/drivers/mmc/host/sdhci-s3c.c
43630 +++ b/drivers/mmc/host/sdhci-s3c.c
43631 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43632 * we can use overriding functions instead of default.
43633 */
43634 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43635 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43636 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43637 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43638 + pax_open_kernel();
43639 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43640 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43641 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43642 + pax_close_kernel();
43643 }
43644
43645 /* It supports additional host capabilities if needed */
43646 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43647 index 0c8bb6b..6f35deb 100644
43648 --- a/drivers/mtd/nand/denali.c
43649 +++ b/drivers/mtd/nand/denali.c
43650 @@ -24,6 +24,7 @@
43651 #include <linux/slab.h>
43652 #include <linux/mtd/mtd.h>
43653 #include <linux/module.h>
43654 +#include <linux/slab.h>
43655
43656 #include "denali.h"
43657
43658 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43659 index 51b9d6a..52af9a7 100644
43660 --- a/drivers/mtd/nftlmount.c
43661 +++ b/drivers/mtd/nftlmount.c
43662 @@ -24,6 +24,7 @@
43663 #include <asm/errno.h>
43664 #include <linux/delay.h>
43665 #include <linux/slab.h>
43666 +#include <linux/sched.h>
43667 #include <linux/mtd/mtd.h>
43668 #include <linux/mtd/nand.h>
43669 #include <linux/mtd/nftl.h>
43670 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43671 index f9d5615..99dd95f 100644
43672 --- a/drivers/mtd/sm_ftl.c
43673 +++ b/drivers/mtd/sm_ftl.c
43674 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43675 #define SM_CIS_VENDOR_OFFSET 0x59
43676 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43677 {
43678 - struct attribute_group *attr_group;
43679 + attribute_group_no_const *attr_group;
43680 struct attribute **attributes;
43681 struct sm_sysfs_attribute *vendor_attribute;
43682
43683 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43684 index e48cb33..72e73fc 100644
43685 --- a/drivers/net/bonding/bond_main.c
43686 +++ b/drivers/net/bonding/bond_main.c
43687 @@ -4832,7 +4832,7 @@ static unsigned int bond_get_num_tx_queues(void)
43688 return tx_queues;
43689 }
43690
43691 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43692 +static struct rtnl_link_ops bond_link_ops = {
43693 .kind = "bond",
43694 .priv_size = sizeof(struct bonding),
43695 .setup = bond_setup,
43696 @@ -4957,8 +4957,8 @@ static void __exit bonding_exit(void)
43697
43698 bond_destroy_debugfs();
43699
43700 - rtnl_link_unregister(&bond_link_ops);
43701 unregister_pernet_subsys(&bond_net_ops);
43702 + rtnl_link_unregister(&bond_link_ops);
43703
43704 #ifdef CONFIG_NET_POLL_CONTROLLER
43705 /*
43706 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
43707 index e1d2643..7f4133b 100644
43708 --- a/drivers/net/ethernet/8390/ax88796.c
43709 +++ b/drivers/net/ethernet/8390/ax88796.c
43710 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
43711 if (ax->plat->reg_offsets)
43712 ei_local->reg_offset = ax->plat->reg_offsets;
43713 else {
43714 + resource_size_t _mem_size = mem_size;
43715 + do_div(_mem_size, 0x18);
43716 ei_local->reg_offset = ax->reg_offsets;
43717 for (ret = 0; ret < 0x18; ret++)
43718 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
43719 + ax->reg_offsets[ret] = _mem_size * ret;
43720 }
43721
43722 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
43723 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43724 index c07a6d0..ca88c45 100644
43725 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43726 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43727 @@ -1137,7 +1137,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
43728 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
43729 {
43730 /* RX_MODE controlling object */
43731 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
43732 + bnx2x_init_rx_mode_obj(bp);
43733
43734 /* multicast configuration controlling object */
43735 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
43736 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43737 index 8f03c98..dd0ef10 100644
43738 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43739 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43740 @@ -2345,15 +2345,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
43741 return rc;
43742 }
43743
43744 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43745 - struct bnx2x_rx_mode_obj *o)
43746 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
43747 {
43748 if (CHIP_IS_E1x(bp)) {
43749 - o->wait_comp = bnx2x_empty_rx_mode_wait;
43750 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
43751 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
43752 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
43753 } else {
43754 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
43755 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
43756 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
43757 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
43758 }
43759 }
43760
43761 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43762 index 798dfe9..05d0a44 100644
43763 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43764 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43765 @@ -1311,8 +1311,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
43766
43767 /********************* RX MODE ****************/
43768
43769 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43770 - struct bnx2x_rx_mode_obj *o);
43771 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
43772
43773 /**
43774 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
43775 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
43776 index cd63d11..b67dd78 100644
43777 --- a/drivers/net/ethernet/broadcom/tg3.h
43778 +++ b/drivers/net/ethernet/broadcom/tg3.h
43779 @@ -147,6 +147,7 @@
43780 #define CHIPREV_ID_5750_A0 0x4000
43781 #define CHIPREV_ID_5750_A1 0x4001
43782 #define CHIPREV_ID_5750_A3 0x4003
43783 +#define CHIPREV_ID_5750_C1 0x4201
43784 #define CHIPREV_ID_5750_C2 0x4202
43785 #define CHIPREV_ID_5752_A0_HW 0x5000
43786 #define CHIPREV_ID_5752_A0 0x6000
43787 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43788 index 8cffcdf..aadf043 100644
43789 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43790 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43791 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
43792 */
43793 struct l2t_skb_cb {
43794 arp_failure_handler_func arp_failure_handler;
43795 -};
43796 +} __no_const;
43797
43798 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
43799
43800 diff --git a/drivers/net/ethernet/chelsio/cxgb3/sge.c b/drivers/net/ethernet/chelsio/cxgb3/sge.c
43801 index 9c89dc8..725ecc3 100644
43802 --- a/drivers/net/ethernet/chelsio/cxgb3/sge.c
43803 +++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c
43804 @@ -1599,7 +1599,7 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
43805 flits = skb_transport_offset(skb) / 8;
43806 sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
43807 sgl_flits = make_sgl(skb, sgp, skb_transport_header(skb),
43808 - skb->tail - skb->transport_header,
43809 + skb_tail_pointer(skb) - skb_transport_header(skb),
43810 adap->pdev);
43811 if (need_skb_unmap()) {
43812 setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits);
43813 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
43814 index 4c83003..2a2a5b9 100644
43815 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
43816 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
43817 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43818 for (i=0; i<ETH_ALEN; i++) {
43819 tmp.addr[i] = dev->dev_addr[i];
43820 }
43821 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43822 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43823 break;
43824
43825 case DE4X5_SET_HWADDR: /* Set the hardware address */
43826 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43827 spin_lock_irqsave(&lp->lock, flags);
43828 memcpy(&statbuf, &lp->pktStats, ioc->len);
43829 spin_unlock_irqrestore(&lp->lock, flags);
43830 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
43831 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
43832 return -EFAULT;
43833 break;
43834 }
43835 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
43836 index 3d91a5e..1014702 100644
43837 --- a/drivers/net/ethernet/emulex/benet/be_main.c
43838 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
43839 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
43840
43841 if (wrapped)
43842 newacc += 65536;
43843 - ACCESS_ONCE(*acc) = newacc;
43844 + ACCESS_ONCE_RW(*acc) = newacc;
43845 }
43846
43847 void populate_erx_stats(struct be_adapter *adapter,
43848 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
43849 index 934e1ae..b262e6b 100644
43850 --- a/drivers/net/ethernet/faraday/ftgmac100.c
43851 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
43852 @@ -31,6 +31,8 @@
43853 #include <linux/netdevice.h>
43854 #include <linux/phy.h>
43855 #include <linux/platform_device.h>
43856 +#include <linux/interrupt.h>
43857 +#include <linux/irqreturn.h>
43858 #include <net/ip.h>
43859
43860 #include "ftgmac100.h"
43861 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
43862 index 4658f4c..407d155 100644
43863 --- a/drivers/net/ethernet/faraday/ftmac100.c
43864 +++ b/drivers/net/ethernet/faraday/ftmac100.c
43865 @@ -31,6 +31,8 @@
43866 #include <linux/module.h>
43867 #include <linux/netdevice.h>
43868 #include <linux/platform_device.h>
43869 +#include <linux/interrupt.h>
43870 +#include <linux/irqreturn.h>
43871
43872 #include "ftmac100.h"
43873
43874 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43875 index 331987d..3be1135 100644
43876 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43877 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43878 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
43879 }
43880
43881 /* update the base incval used to calculate frequency adjustment */
43882 - ACCESS_ONCE(adapter->base_incval) = incval;
43883 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
43884 smp_mb();
43885
43886 /* need lock to prevent incorrect read while modifying cyclecounter */
43887 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43888 index fbe5363..266b4e3 100644
43889 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
43890 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43891 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
43892 struct __vxge_hw_fifo *fifo;
43893 struct vxge_hw_fifo_config *config;
43894 u32 txdl_size, txdl_per_memblock;
43895 - struct vxge_hw_mempool_cbs fifo_mp_callback;
43896 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
43897 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
43898 + };
43899 +
43900 struct __vxge_hw_virtualpath *vpath;
43901
43902 if ((vp == NULL) || (attr == NULL)) {
43903 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
43904 goto exit;
43905 }
43906
43907 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
43908 -
43909 fifo->mempool =
43910 __vxge_hw_mempool_create(vpath->hldev,
43911 fifo->config->memblock_size,
43912 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43913 index 345d987..af69721 100644
43914 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43915 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43916 @@ -2011,7 +2011,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
43917 op_mode = QLC_83XX_DEFAULT_OPMODE;
43918
43919 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
43920 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
43921 + pax_open_kernel();
43922 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
43923 + pax_close_kernel();
43924 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43925 } else {
43926 return -EIO;
43927 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43928 index 599d1fd..59868fe 100644
43929 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43930 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43931 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
43932 case QLCNIC_NON_PRIV_FUNC:
43933 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
43934 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43935 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
43936 + pax_open_kernel();
43937 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
43938 + pax_close_kernel();
43939 break;
43940 case QLCNIC_PRIV_FUNC:
43941 ahw->op_mode = QLCNIC_PRIV_FUNC;
43942 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
43943 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
43944 + pax_open_kernel();
43945 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
43946 + pax_close_kernel();
43947 break;
43948 case QLCNIC_MGMT_FUNC:
43949 ahw->op_mode = QLCNIC_MGMT_FUNC;
43950 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43951 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
43952 + pax_open_kernel();
43953 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
43954 + pax_close_kernel();
43955 break;
43956 default:
43957 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
43958 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
43959 index 85e5c97..76f97ec 100644
43960 --- a/drivers/net/ethernet/realtek/r8169.c
43961 +++ b/drivers/net/ethernet/realtek/r8169.c
43962 @@ -759,22 +759,22 @@ struct rtl8169_private {
43963 struct mdio_ops {
43964 void (*write)(struct rtl8169_private *, int, int);
43965 int (*read)(struct rtl8169_private *, int);
43966 - } mdio_ops;
43967 + } __no_const mdio_ops;
43968
43969 struct pll_power_ops {
43970 void (*down)(struct rtl8169_private *);
43971 void (*up)(struct rtl8169_private *);
43972 - } pll_power_ops;
43973 + } __no_const pll_power_ops;
43974
43975 struct jumbo_ops {
43976 void (*enable)(struct rtl8169_private *);
43977 void (*disable)(struct rtl8169_private *);
43978 - } jumbo_ops;
43979 + } __no_const jumbo_ops;
43980
43981 struct csi_ops {
43982 void (*write)(struct rtl8169_private *, int, int);
43983 u32 (*read)(struct rtl8169_private *, int);
43984 - } csi_ops;
43985 + } __no_const csi_ops;
43986
43987 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
43988 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
43989 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
43990 index b495394..0748c54 100644
43991 --- a/drivers/net/ethernet/sfc/ptp.c
43992 +++ b/drivers/net/ethernet/sfc/ptp.c
43993 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
43994 (u32)((u64)ptp->start.dma_addr >> 32));
43995
43996 /* Clear flag that signals MC ready */
43997 - ACCESS_ONCE(*start) = 0;
43998 + ACCESS_ONCE_RW(*start) = 0;
43999 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44000 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44001
44002 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44003 index 50617c5..b13724c 100644
44004 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44005 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44006 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44007
44008 writel(value, ioaddr + MMC_CNTRL);
44009
44010 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44011 - MMC_CNTRL, value);
44012 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44013 +// MMC_CNTRL, value);
44014 }
44015
44016 /* To mask all all interrupts.*/
44017 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44018 index e6fe0d8..2b7d752 100644
44019 --- a/drivers/net/hyperv/hyperv_net.h
44020 +++ b/drivers/net/hyperv/hyperv_net.h
44021 @@ -101,7 +101,7 @@ struct rndis_device {
44022
44023 enum rndis_device_state state;
44024 bool link_state;
44025 - atomic_t new_req_id;
44026 + atomic_unchecked_t new_req_id;
44027
44028 spinlock_t request_lock;
44029 struct list_head req_list;
44030 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44031 index 0775f0a..d4fb316 100644
44032 --- a/drivers/net/hyperv/rndis_filter.c
44033 +++ b/drivers/net/hyperv/rndis_filter.c
44034 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44035 * template
44036 */
44037 set = &rndis_msg->msg.set_req;
44038 - set->req_id = atomic_inc_return(&dev->new_req_id);
44039 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44040
44041 /* Add to the request list */
44042 spin_lock_irqsave(&dev->request_lock, flags);
44043 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44044
44045 /* Setup the rndis set */
44046 halt = &request->request_msg.msg.halt_req;
44047 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44048 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44049
44050 /* Ignore return since this msg is optional. */
44051 rndis_filter_send_request(dev, request);
44052 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44053 index bf0d55e..82bcfbd1 100644
44054 --- a/drivers/net/ieee802154/fakehard.c
44055 +++ b/drivers/net/ieee802154/fakehard.c
44056 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44057 phy->transmit_power = 0xbf;
44058
44059 dev->netdev_ops = &fake_ops;
44060 - dev->ml_priv = &fake_mlme;
44061 + dev->ml_priv = (void *)&fake_mlme;
44062
44063 priv = netdev_priv(dev);
44064 priv->phy = phy;
44065 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44066 index 16b43bf..ead0c35 100644
44067 --- a/drivers/net/macvlan.c
44068 +++ b/drivers/net/macvlan.c
44069 @@ -934,13 +934,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44070 int macvlan_link_register(struct rtnl_link_ops *ops)
44071 {
44072 /* common fields */
44073 - ops->priv_size = sizeof(struct macvlan_dev);
44074 - ops->validate = macvlan_validate;
44075 - ops->maxtype = IFLA_MACVLAN_MAX;
44076 - ops->policy = macvlan_policy;
44077 - ops->changelink = macvlan_changelink;
44078 - ops->get_size = macvlan_get_size;
44079 - ops->fill_info = macvlan_fill_info;
44080 + pax_open_kernel();
44081 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44082 + *(void **)&ops->validate = macvlan_validate;
44083 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44084 + *(const void **)&ops->policy = macvlan_policy;
44085 + *(void **)&ops->changelink = macvlan_changelink;
44086 + *(void **)&ops->get_size = macvlan_get_size;
44087 + *(void **)&ops->fill_info = macvlan_fill_info;
44088 + pax_close_kernel();
44089
44090 return rtnl_link_register(ops);
44091 };
44092 @@ -996,7 +998,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44093 return NOTIFY_DONE;
44094 }
44095
44096 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44097 +static struct notifier_block macvlan_notifier_block = {
44098 .notifier_call = macvlan_device_event,
44099 };
44100
44101 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44102 index ea53abb..2e4d087 100644
44103 --- a/drivers/net/macvtap.c
44104 +++ b/drivers/net/macvtap.c
44105 @@ -1286,7 +1286,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44106 return NOTIFY_DONE;
44107 }
44108
44109 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44110 +static struct notifier_block macvtap_notifier_block = {
44111 .notifier_call = macvtap_device_event,
44112 };
44113
44114 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44115 index daec9b0..6428fcb 100644
44116 --- a/drivers/net/phy/mdio-bitbang.c
44117 +++ b/drivers/net/phy/mdio-bitbang.c
44118 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44119 struct mdiobb_ctrl *ctrl = bus->priv;
44120
44121 module_put(ctrl->ops->owner);
44122 + mdiobus_unregister(bus);
44123 mdiobus_free(bus);
44124 }
44125 EXPORT_SYMBOL(free_mdio_bitbang);
44126 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44127 index 72ff14b..11d442d 100644
44128 --- a/drivers/net/ppp/ppp_generic.c
44129 +++ b/drivers/net/ppp/ppp_generic.c
44130 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44131 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44132 struct ppp_stats stats;
44133 struct ppp_comp_stats cstats;
44134 - char *vers;
44135
44136 switch (cmd) {
44137 case SIOCGPPPSTATS:
44138 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44139 break;
44140
44141 case SIOCGPPPVER:
44142 - vers = PPP_VERSION;
44143 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44144 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44145 break;
44146 err = 0;
44147 break;
44148 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44149 index 1252d9c..80e660b 100644
44150 --- a/drivers/net/slip/slhc.c
44151 +++ b/drivers/net/slip/slhc.c
44152 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44153 register struct tcphdr *thp;
44154 register struct iphdr *ip;
44155 register struct cstate *cs;
44156 - int len, hdrlen;
44157 + long len, hdrlen;
44158 unsigned char *cp = icp;
44159
44160 /* We've got a compressed packet; read the change byte */
44161 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44162 index bff7e0b..7315137 100644
44163 --- a/drivers/net/team/team.c
44164 +++ b/drivers/net/team/team.c
44165 @@ -2702,7 +2702,7 @@ static int team_device_event(struct notifier_block *unused,
44166 return NOTIFY_DONE;
44167 }
44168
44169 -static struct notifier_block team_notifier_block __read_mostly = {
44170 +static struct notifier_block team_notifier_block = {
44171 .notifier_call = team_device_event,
44172 };
44173
44174 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44175 index 71af122..b3c20f3 100644
44176 --- a/drivers/net/tun.c
44177 +++ b/drivers/net/tun.c
44178 @@ -1691,11 +1691,11 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
44179 INIT_LIST_HEAD(&tun->disabled);
44180 err = tun_attach(tun, file);
44181 if (err < 0)
44182 - goto err_free_dev;
44183 + goto err_free_flow;
44184
44185 err = register_netdevice(tun->dev);
44186 if (err < 0)
44187 - goto err_free_dev;
44188 + goto err_detach;
44189
44190 if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) ||
44191 device_create_file(&tun->dev->dev, &dev_attr_owner) ||
44192 @@ -1739,7 +1739,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
44193 strcpy(ifr->ifr_name, tun->dev->name);
44194 return 0;
44195
44196 - err_free_dev:
44197 +err_detach:
44198 + tun_detach_all(dev);
44199 +err_free_flow:
44200 + tun_flow_uninit(tun);
44201 + security_tun_dev_free_security(tun->security);
44202 +err_free_dev:
44203 free_netdev(dev);
44204 return err;
44205 }
44206 @@ -1869,7 +1874,7 @@ unlock:
44207 }
44208
44209 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44210 - unsigned long arg, int ifreq_len)
44211 + unsigned long arg, size_t ifreq_len)
44212 {
44213 struct tun_file *tfile = file->private_data;
44214 struct tun_struct *tun;
44215 @@ -1881,6 +1886,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44216 int vnet_hdr_sz;
44217 int ret;
44218
44219 + if (ifreq_len > sizeof ifr)
44220 + return -EFAULT;
44221 +
44222 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44223 if (copy_from_user(&ifr, argp, ifreq_len))
44224 return -EFAULT;
44225 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44226 index 86292e6..8d34433 100644
44227 --- a/drivers/net/usb/hso.c
44228 +++ b/drivers/net/usb/hso.c
44229 @@ -71,7 +71,7 @@
44230 #include <asm/byteorder.h>
44231 #include <linux/serial_core.h>
44232 #include <linux/serial.h>
44233 -
44234 +#include <asm/local.h>
44235
44236 #define MOD_AUTHOR "Option Wireless"
44237 #define MOD_DESCRIPTION "USB High Speed Option driver"
44238 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44239 struct urb *urb;
44240
44241 urb = serial->rx_urb[0];
44242 - if (serial->port.count > 0) {
44243 + if (atomic_read(&serial->port.count) > 0) {
44244 count = put_rxbuf_data(urb, serial);
44245 if (count == -1)
44246 return;
44247 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44248 DUMP1(urb->transfer_buffer, urb->actual_length);
44249
44250 /* Anyone listening? */
44251 - if (serial->port.count == 0)
44252 + if (atomic_read(&serial->port.count) == 0)
44253 return;
44254
44255 if (status == 0) {
44256 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44257 tty_port_tty_set(&serial->port, tty);
44258
44259 /* check for port already opened, if not set the termios */
44260 - serial->port.count++;
44261 - if (serial->port.count == 1) {
44262 + if (atomic_inc_return(&serial->port.count) == 1) {
44263 serial->rx_state = RX_IDLE;
44264 /* Force default termio settings */
44265 _hso_serial_set_termios(tty, NULL);
44266 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44267 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44268 if (result) {
44269 hso_stop_serial_device(serial->parent);
44270 - serial->port.count--;
44271 + atomic_dec(&serial->port.count);
44272 kref_put(&serial->parent->ref, hso_serial_ref_free);
44273 }
44274 } else {
44275 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44276
44277 /* reset the rts and dtr */
44278 /* do the actual close */
44279 - serial->port.count--;
44280 + atomic_dec(&serial->port.count);
44281
44282 - if (serial->port.count <= 0) {
44283 - serial->port.count = 0;
44284 + if (atomic_read(&serial->port.count) <= 0) {
44285 + atomic_set(&serial->port.count, 0);
44286 tty_port_tty_set(&serial->port, NULL);
44287 if (!usb_gone)
44288 hso_stop_serial_device(serial->parent);
44289 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44290
44291 /* the actual setup */
44292 spin_lock_irqsave(&serial->serial_lock, flags);
44293 - if (serial->port.count)
44294 + if (atomic_read(&serial->port.count))
44295 _hso_serial_set_termios(tty, old);
44296 else
44297 tty->termios = *old;
44298 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44299 D1("Pending read interrupt on port %d\n", i);
44300 spin_lock(&serial->serial_lock);
44301 if (serial->rx_state == RX_IDLE &&
44302 - serial->port.count > 0) {
44303 + atomic_read(&serial->port.count) > 0) {
44304 /* Setup and send a ctrl req read on
44305 * port i */
44306 if (!serial->rx_urb_filled[0]) {
44307 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44308 /* Start all serial ports */
44309 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44310 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44311 - if (dev2ser(serial_table[i])->port.count) {
44312 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44313 result =
44314 hso_start_serial_device(serial_table[i], GFP_NOIO);
44315 hso_kick_transmit(dev2ser(serial_table[i]));
44316 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44317 index a79e9d3..78cd4fa 100644
44318 --- a/drivers/net/usb/sierra_net.c
44319 +++ b/drivers/net/usb/sierra_net.c
44320 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44321 /* atomic counter partially included in MAC address to make sure 2 devices
44322 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44323 */
44324 -static atomic_t iface_counter = ATOMIC_INIT(0);
44325 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44326
44327 /*
44328 * SYNC Timer Delay definition used to set the expiry time
44329 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44330 dev->net->netdev_ops = &sierra_net_device_ops;
44331
44332 /* change MAC addr to include, ifacenum, and to be unique */
44333 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44334 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44335 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44336
44337 /* we will have to manufacture ethernet headers, prepare template */
44338 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44339 index 767f7af..8162b9d 100644
44340 --- a/drivers/net/vxlan.c
44341 +++ b/drivers/net/vxlan.c
44342 @@ -1868,7 +1868,7 @@ nla_put_failure:
44343 return -EMSGSIZE;
44344 }
44345
44346 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44347 +static struct rtnl_link_ops vxlan_link_ops = {
44348 .kind = "vxlan",
44349 .maxtype = IFLA_VXLAN_MAX,
44350 .policy = vxlan_policy,
44351 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44352 index 0b60295..b8bfa5b 100644
44353 --- a/drivers/net/wimax/i2400m/rx.c
44354 +++ b/drivers/net/wimax/i2400m/rx.c
44355 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44356 if (i2400m->rx_roq == NULL)
44357 goto error_roq_alloc;
44358
44359 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44360 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44361 GFP_KERNEL);
44362 if (rd == NULL) {
44363 result = -ENOMEM;
44364 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44365 index 34c8a33..3261fdc 100644
44366 --- a/drivers/net/wireless/at76c50x-usb.c
44367 +++ b/drivers/net/wireless/at76c50x-usb.c
44368 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44369 }
44370
44371 /* Convert timeout from the DFU status to jiffies */
44372 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44373 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44374 {
44375 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44376 | (s->poll_timeout[1] << 8)
44377 diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
44378 index 2b3426b..1f564be 100644
44379 --- a/drivers/net/wireless/ath/ath10k/core.c
44380 +++ b/drivers/net/wireless/ath/ath10k/core.c
44381 @@ -507,7 +507,9 @@ EXPORT_SYMBOL(ath10k_core_destroy);
44382
44383 int ath10k_core_register(struct ath10k *ar)
44384 {
44385 - struct ath10k_htc_ops htc_ops;
44386 + static struct ath10k_htc_ops htc_ops = {
44387 + .target_send_suspend_complete = ath10k_send_suspend_complete,
44388 + };
44389 struct bmi_target_info target_info;
44390 int status;
44391
44392 @@ -536,8 +538,6 @@ int ath10k_core_register(struct ath10k *ar)
44393 if (status)
44394 goto err;
44395
44396 - htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete;
44397 -
44398 ar->htc = ath10k_htc_create(ar, &htc_ops);
44399 if (IS_ERR(ar->htc)) {
44400 status = PTR_ERR(ar->htc);
44401 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44402 index 74363c9..237b926 100644
44403 --- a/drivers/net/wireless/ath/ath10k/htc.c
44404 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44405 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44406 struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44407 struct ath10k_htc_ops *htc_ops)
44408 {
44409 - struct ath10k_hif_cb htc_callbacks;
44410 + static struct ath10k_hif_cb htc_callbacks = {
44411 + .rx_completion = ath10k_htc_rx_completion_handler,
44412 + .tx_completion = ath10k_htc_tx_completion_handler,
44413 + };
44414 struct ath10k_htc_ep *ep = NULL;
44415 struct ath10k_htc *htc = NULL;
44416
44417 @@ -979,8 +982,6 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44418 ath10k_htc_reset_endpoint_states(htc);
44419
44420 /* setup HIF layer callbacks */
44421 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44422 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44423 htc->ar = ar;
44424
44425 /* Get HIF default pipe for HTC message exchange */
44426 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44427 index 8d78253..bebbb68 100644
44428 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44429 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44430 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44431 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44432 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44433
44434 - ACCESS_ONCE(ads->ds_link) = i->link;
44435 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44436 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44437 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44438
44439 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44440 ctl6 = SM(i->keytype, AR_EncrType);
44441 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44442
44443 if ((i->is_first || i->is_last) &&
44444 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44445 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44446 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44447 | set11nTries(i->rates, 1)
44448 | set11nTries(i->rates, 2)
44449 | set11nTries(i->rates, 3)
44450 | (i->dur_update ? AR_DurUpdateEna : 0)
44451 | SM(0, AR_BurstDur);
44452
44453 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44454 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44455 | set11nRate(i->rates, 1)
44456 | set11nRate(i->rates, 2)
44457 | set11nRate(i->rates, 3);
44458 } else {
44459 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44460 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44461 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44462 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44463 }
44464
44465 if (!i->is_first) {
44466 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44467 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44468 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44469 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44470 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44471 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44472 return;
44473 }
44474
44475 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44476 break;
44477 }
44478
44479 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44480 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44481 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44482 | SM(i->txpower, AR_XmitPower)
44483 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44484 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44485 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44486 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44487
44488 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44489 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44490 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44491 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44492
44493 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44494 return;
44495
44496 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44497 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44498 | set11nPktDurRTSCTS(i->rates, 1);
44499
44500 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44501 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44502 | set11nPktDurRTSCTS(i->rates, 3);
44503
44504 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44505 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44506 | set11nRateFlags(i->rates, 1)
44507 | set11nRateFlags(i->rates, 2)
44508 | set11nRateFlags(i->rates, 3)
44509 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44510 index 5163abd..3ada4c2 100644
44511 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44512 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44513 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44514 (i->qcu << AR_TxQcuNum_S) | desc_len;
44515
44516 checksum += val;
44517 - ACCESS_ONCE(ads->info) = val;
44518 + ACCESS_ONCE_RW(ads->info) = val;
44519
44520 checksum += i->link;
44521 - ACCESS_ONCE(ads->link) = i->link;
44522 + ACCESS_ONCE_RW(ads->link) = i->link;
44523
44524 checksum += i->buf_addr[0];
44525 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44526 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44527 checksum += i->buf_addr[1];
44528 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44529 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44530 checksum += i->buf_addr[2];
44531 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44532 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44533 checksum += i->buf_addr[3];
44534 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44535 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44536
44537 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44538 - ACCESS_ONCE(ads->ctl3) = val;
44539 + ACCESS_ONCE_RW(ads->ctl3) = val;
44540 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44541 - ACCESS_ONCE(ads->ctl5) = val;
44542 + ACCESS_ONCE_RW(ads->ctl5) = val;
44543 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44544 - ACCESS_ONCE(ads->ctl7) = val;
44545 + ACCESS_ONCE_RW(ads->ctl7) = val;
44546 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44547 - ACCESS_ONCE(ads->ctl9) = val;
44548 + ACCESS_ONCE_RW(ads->ctl9) = val;
44549
44550 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44551 - ACCESS_ONCE(ads->ctl10) = checksum;
44552 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44553
44554 if (i->is_first || i->is_last) {
44555 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44556 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44557 | set11nTries(i->rates, 1)
44558 | set11nTries(i->rates, 2)
44559 | set11nTries(i->rates, 3)
44560 | (i->dur_update ? AR_DurUpdateEna : 0)
44561 | SM(0, AR_BurstDur);
44562
44563 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44564 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44565 | set11nRate(i->rates, 1)
44566 | set11nRate(i->rates, 2)
44567 | set11nRate(i->rates, 3);
44568 } else {
44569 - ACCESS_ONCE(ads->ctl13) = 0;
44570 - ACCESS_ONCE(ads->ctl14) = 0;
44571 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44572 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44573 }
44574
44575 ads->ctl20 = 0;
44576 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44577
44578 ctl17 = SM(i->keytype, AR_EncrType);
44579 if (!i->is_first) {
44580 - ACCESS_ONCE(ads->ctl11) = 0;
44581 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44582 - ACCESS_ONCE(ads->ctl15) = 0;
44583 - ACCESS_ONCE(ads->ctl16) = 0;
44584 - ACCESS_ONCE(ads->ctl17) = ctl17;
44585 - ACCESS_ONCE(ads->ctl18) = 0;
44586 - ACCESS_ONCE(ads->ctl19) = 0;
44587 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44588 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44589 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44590 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44591 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44592 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44593 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44594 return;
44595 }
44596
44597 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44598 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44599 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44600 | SM(i->txpower, AR_XmitPower)
44601 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44602 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44603 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44604 ctl12 |= SM(val, AR_PAPRDChainMask);
44605
44606 - ACCESS_ONCE(ads->ctl12) = ctl12;
44607 - ACCESS_ONCE(ads->ctl17) = ctl17;
44608 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44609 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44610
44611 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44612 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44613 | set11nPktDurRTSCTS(i->rates, 1);
44614
44615 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44616 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44617 | set11nPktDurRTSCTS(i->rates, 3);
44618
44619 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44620 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44621 | set11nRateFlags(i->rates, 1)
44622 | set11nRateFlags(i->rates, 2)
44623 | set11nRateFlags(i->rates, 3)
44624 | SM(i->rtscts_rate, AR_RTSCTSRate);
44625
44626 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44627 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44628 }
44629
44630 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44631 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44632 index cd74b3a..6a28d24 100644
44633 --- a/drivers/net/wireless/ath/ath9k/hw.h
44634 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44635 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
44636
44637 /* ANI */
44638 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44639 -};
44640 +} __no_const;
44641
44642 /**
44643 * struct ath_spec_scan - parameters for Atheros spectral scan
44644 @@ -721,7 +721,7 @@ struct ath_hw_ops {
44645 struct ath_spec_scan *param);
44646 void (*spectral_scan_trigger)(struct ath_hw *ah);
44647 void (*spectral_scan_wait)(struct ath_hw *ah);
44648 -};
44649 +} __no_const;
44650
44651 struct ath_nf_limits {
44652 s16 max;
44653 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44654 index 9581d07..84f6a76 100644
44655 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44656 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44657 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44658 */
44659 if (il3945_mod_params.disable_hw_scan) {
44660 D_INFO("Disabling hw_scan\n");
44661 - il3945_mac_ops.hw_scan = NULL;
44662 + pax_open_kernel();
44663 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44664 + pax_close_kernel();
44665 }
44666
44667 D_INFO("*** LOAD DRIVER ***\n");
44668 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44669 index d532948..e0d8bb1 100644
44670 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44671 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44672 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44673 {
44674 struct iwl_priv *priv = file->private_data;
44675 char buf[64];
44676 - int buf_size;
44677 + size_t buf_size;
44678 u32 offset, len;
44679
44680 memset(buf, 0, sizeof(buf));
44681 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44682 struct iwl_priv *priv = file->private_data;
44683
44684 char buf[8];
44685 - int buf_size;
44686 + size_t buf_size;
44687 u32 reset_flag;
44688
44689 memset(buf, 0, sizeof(buf));
44690 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44691 {
44692 struct iwl_priv *priv = file->private_data;
44693 char buf[8];
44694 - int buf_size;
44695 + size_t buf_size;
44696 int ht40;
44697
44698 memset(buf, 0, sizeof(buf));
44699 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
44700 {
44701 struct iwl_priv *priv = file->private_data;
44702 char buf[8];
44703 - int buf_size;
44704 + size_t buf_size;
44705 int value;
44706
44707 memset(buf, 0, sizeof(buf));
44708 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
44709 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
44710 DEBUGFS_READ_FILE_OPS(current_sleep_command);
44711
44712 -static const char *fmt_value = " %-30s %10u\n";
44713 -static const char *fmt_hex = " %-30s 0x%02X\n";
44714 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
44715 -static const char *fmt_header =
44716 +static const char fmt_value[] = " %-30s %10u\n";
44717 +static const char fmt_hex[] = " %-30s 0x%02X\n";
44718 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
44719 +static const char fmt_header[] =
44720 "%-32s current cumulative delta max\n";
44721
44722 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
44723 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
44724 {
44725 struct iwl_priv *priv = file->private_data;
44726 char buf[8];
44727 - int buf_size;
44728 + size_t buf_size;
44729 int clear;
44730
44731 memset(buf, 0, sizeof(buf));
44732 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
44733 {
44734 struct iwl_priv *priv = file->private_data;
44735 char buf[8];
44736 - int buf_size;
44737 + size_t buf_size;
44738 int trace;
44739
44740 memset(buf, 0, sizeof(buf));
44741 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
44742 {
44743 struct iwl_priv *priv = file->private_data;
44744 char buf[8];
44745 - int buf_size;
44746 + size_t buf_size;
44747 int missed;
44748
44749 memset(buf, 0, sizeof(buf));
44750 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
44751
44752 struct iwl_priv *priv = file->private_data;
44753 char buf[8];
44754 - int buf_size;
44755 + size_t buf_size;
44756 int plcp;
44757
44758 memset(buf, 0, sizeof(buf));
44759 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
44760
44761 struct iwl_priv *priv = file->private_data;
44762 char buf[8];
44763 - int buf_size;
44764 + size_t buf_size;
44765 int flush;
44766
44767 memset(buf, 0, sizeof(buf));
44768 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
44769
44770 struct iwl_priv *priv = file->private_data;
44771 char buf[8];
44772 - int buf_size;
44773 + size_t buf_size;
44774 int rts;
44775
44776 if (!priv->cfg->ht_params)
44777 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
44778 {
44779 struct iwl_priv *priv = file->private_data;
44780 char buf[8];
44781 - int buf_size;
44782 + size_t buf_size;
44783
44784 memset(buf, 0, sizeof(buf));
44785 buf_size = min(count, sizeof(buf) - 1);
44786 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
44787 struct iwl_priv *priv = file->private_data;
44788 u32 event_log_flag;
44789 char buf[8];
44790 - int buf_size;
44791 + size_t buf_size;
44792
44793 /* check that the interface is up */
44794 if (!iwl_is_ready(priv))
44795 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
44796 struct iwl_priv *priv = file->private_data;
44797 char buf[8];
44798 u32 calib_disabled;
44799 - int buf_size;
44800 + size_t buf_size;
44801
44802 memset(buf, 0, sizeof(buf));
44803 buf_size = min(count, sizeof(buf) - 1);
44804 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
44805 index 1531a4f..21d2641 100644
44806 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
44807 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
44808 @@ -1180,7 +1180,7 @@ static void iwl_option_config(struct iwl_priv *priv)
44809 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44810 {
44811 struct iwl_nvm_data *data = priv->nvm_data;
44812 - char *debug_msg;
44813 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44814
44815 if (data->sku_cap_11n_enable &&
44816 !priv->cfg->ht_params) {
44817 @@ -1194,7 +1194,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44818 return -EINVAL;
44819 }
44820
44821 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44822 IWL_DEBUG_INFO(priv, debug_msg,
44823 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
44824 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
44825 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
44826 index 390e2f0..75cfbaf 100644
44827 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
44828 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
44829 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
44830 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
44831
44832 char buf[8];
44833 - int buf_size;
44834 + size_t buf_size;
44835 u32 reset_flag;
44836
44837 memset(buf, 0, sizeof(buf));
44838 @@ -1371,7 +1371,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
44839 {
44840 struct iwl_trans *trans = file->private_data;
44841 char buf[8];
44842 - int buf_size;
44843 + size_t buf_size;
44844 int csr;
44845
44846 memset(buf, 0, sizeof(buf));
44847 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
44848 index cb34c78..9fec0dc 100644
44849 --- a/drivers/net/wireless/mac80211_hwsim.c
44850 +++ b/drivers/net/wireless/mac80211_hwsim.c
44851 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
44852
44853 if (channels > 1) {
44854 hwsim_if_comb.num_different_channels = channels;
44855 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44856 - mac80211_hwsim_ops.cancel_hw_scan =
44857 - mac80211_hwsim_cancel_hw_scan;
44858 - mac80211_hwsim_ops.sw_scan_start = NULL;
44859 - mac80211_hwsim_ops.sw_scan_complete = NULL;
44860 - mac80211_hwsim_ops.remain_on_channel =
44861 - mac80211_hwsim_roc;
44862 - mac80211_hwsim_ops.cancel_remain_on_channel =
44863 - mac80211_hwsim_croc;
44864 - mac80211_hwsim_ops.add_chanctx =
44865 - mac80211_hwsim_add_chanctx;
44866 - mac80211_hwsim_ops.remove_chanctx =
44867 - mac80211_hwsim_remove_chanctx;
44868 - mac80211_hwsim_ops.change_chanctx =
44869 - mac80211_hwsim_change_chanctx;
44870 - mac80211_hwsim_ops.assign_vif_chanctx =
44871 - mac80211_hwsim_assign_vif_chanctx;
44872 - mac80211_hwsim_ops.unassign_vif_chanctx =
44873 - mac80211_hwsim_unassign_vif_chanctx;
44874 + pax_open_kernel();
44875 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44876 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
44877 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
44878 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
44879 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
44880 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
44881 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
44882 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
44883 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
44884 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
44885 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
44886 + pax_close_kernel();
44887 }
44888
44889 spin_lock_init(&hwsim_radio_lock);
44890 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
44891 index 8169a85..7fa3b47 100644
44892 --- a/drivers/net/wireless/rndis_wlan.c
44893 +++ b/drivers/net/wireless/rndis_wlan.c
44894 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
44895
44896 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
44897
44898 - if (rts_threshold < 0 || rts_threshold > 2347)
44899 + if (rts_threshold > 2347)
44900 rts_threshold = 2347;
44901
44902 tmp = cpu_to_le32(rts_threshold);
44903 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
44904 index ee3fc57..ed5ddc9 100644
44905 --- a/drivers/net/wireless/rt2x00/rt2x00.h
44906 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
44907 @@ -386,7 +386,7 @@ struct rt2x00_intf {
44908 * for hardware which doesn't support hardware
44909 * sequence counting.
44910 */
44911 - atomic_t seqno;
44912 + atomic_unchecked_t seqno;
44913 };
44914
44915 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
44916 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
44917 index aa95c6c..a59dd67 100644
44918 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
44919 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
44920 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
44921 * sequence counter given by mac80211.
44922 */
44923 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
44924 - seqno = atomic_add_return(0x10, &intf->seqno);
44925 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
44926 else
44927 - seqno = atomic_read(&intf->seqno);
44928 + seqno = atomic_read_unchecked(&intf->seqno);
44929
44930 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
44931 hdr->seq_ctrl |= cpu_to_le16(seqno);
44932 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
44933 index e2b3d9c..67a5184 100644
44934 --- a/drivers/net/wireless/ti/wl1251/sdio.c
44935 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
44936 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
44937
44938 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
44939
44940 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
44941 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
44942 + pax_open_kernel();
44943 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
44944 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
44945 + pax_close_kernel();
44946
44947 wl1251_info("using dedicated interrupt line");
44948 } else {
44949 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
44950 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
44951 + pax_open_kernel();
44952 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
44953 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
44954 + pax_close_kernel();
44955
44956 wl1251_info("using SDIO interrupt");
44957 }
44958 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
44959 index 1c627da..69f7d17 100644
44960 --- a/drivers/net/wireless/ti/wl12xx/main.c
44961 +++ b/drivers/net/wireless/ti/wl12xx/main.c
44962 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
44963 sizeof(wl->conf.mem));
44964
44965 /* read data preparation is only needed by wl127x */
44966 - wl->ops->prepare_read = wl127x_prepare_read;
44967 + pax_open_kernel();
44968 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
44969 + pax_close_kernel();
44970
44971 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
44972 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
44973 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
44974 sizeof(wl->conf.mem));
44975
44976 /* read data preparation is only needed by wl127x */
44977 - wl->ops->prepare_read = wl127x_prepare_read;
44978 + pax_open_kernel();
44979 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
44980 + pax_close_kernel();
44981
44982 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
44983 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
44984 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
44985 index 7aa0eb8..5a9ef38 100644
44986 --- a/drivers/net/wireless/ti/wl18xx/main.c
44987 +++ b/drivers/net/wireless/ti/wl18xx/main.c
44988 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
44989 }
44990
44991 if (!checksum_param) {
44992 - wl18xx_ops.set_rx_csum = NULL;
44993 - wl18xx_ops.init_vif = NULL;
44994 + pax_open_kernel();
44995 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
44996 + *(void **)&wl18xx_ops.init_vif = NULL;
44997 + pax_close_kernel();
44998 }
44999
45000 /* Enable 11a Band only if we have 5G antennas */
45001 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45002 index 7ef0b4a..ff65c28 100644
45003 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45004 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45005 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45006 {
45007 struct zd_usb *usb = urb->context;
45008 struct zd_usb_interrupt *intr = &usb->intr;
45009 - int len;
45010 + unsigned int len;
45011 u16 int_num;
45012
45013 ZD_ASSERT(in_interrupt());
45014 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45015 index d93b2b6..ae50401 100644
45016 --- a/drivers/oprofile/buffer_sync.c
45017 +++ b/drivers/oprofile/buffer_sync.c
45018 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45019 if (cookie == NO_COOKIE)
45020 offset = pc;
45021 if (cookie == INVALID_COOKIE) {
45022 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45023 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45024 offset = pc;
45025 }
45026 if (cookie != last_cookie) {
45027 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45028 /* add userspace sample */
45029
45030 if (!mm) {
45031 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45032 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45033 return 0;
45034 }
45035
45036 cookie = lookup_dcookie(mm, s->eip, &offset);
45037
45038 if (cookie == INVALID_COOKIE) {
45039 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45040 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45041 return 0;
45042 }
45043
45044 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45045 /* ignore backtraces if failed to add a sample */
45046 if (state == sb_bt_start) {
45047 state = sb_bt_ignore;
45048 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45049 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45050 }
45051 }
45052 release_mm(mm);
45053 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45054 index c0cc4e7..44d4e54 100644
45055 --- a/drivers/oprofile/event_buffer.c
45056 +++ b/drivers/oprofile/event_buffer.c
45057 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45058 }
45059
45060 if (buffer_pos == buffer_size) {
45061 - atomic_inc(&oprofile_stats.event_lost_overflow);
45062 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45063 return;
45064 }
45065
45066 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45067 index ed2c3ec..deda85a 100644
45068 --- a/drivers/oprofile/oprof.c
45069 +++ b/drivers/oprofile/oprof.c
45070 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45071 if (oprofile_ops.switch_events())
45072 return;
45073
45074 - atomic_inc(&oprofile_stats.multiplex_counter);
45075 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45076 start_switch_worker();
45077 }
45078
45079 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45080 index 84a208d..d61b0a1 100644
45081 --- a/drivers/oprofile/oprofile_files.c
45082 +++ b/drivers/oprofile/oprofile_files.c
45083 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45084
45085 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45086
45087 -static ssize_t timeout_read(struct file *file, char __user *buf,
45088 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45089 size_t count, loff_t *offset)
45090 {
45091 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45092 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45093 index 917d28e..d62d981 100644
45094 --- a/drivers/oprofile/oprofile_stats.c
45095 +++ b/drivers/oprofile/oprofile_stats.c
45096 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45097 cpu_buf->sample_invalid_eip = 0;
45098 }
45099
45100 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45101 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45102 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45103 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45104 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45105 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45106 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45107 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45108 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45109 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45110 }
45111
45112
45113 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45114 index 38b6fc0..b5cbfce 100644
45115 --- a/drivers/oprofile/oprofile_stats.h
45116 +++ b/drivers/oprofile/oprofile_stats.h
45117 @@ -13,11 +13,11 @@
45118 #include <linux/atomic.h>
45119
45120 struct oprofile_stat_struct {
45121 - atomic_t sample_lost_no_mm;
45122 - atomic_t sample_lost_no_mapping;
45123 - atomic_t bt_lost_no_mapping;
45124 - atomic_t event_lost_overflow;
45125 - atomic_t multiplex_counter;
45126 + atomic_unchecked_t sample_lost_no_mm;
45127 + atomic_unchecked_t sample_lost_no_mapping;
45128 + atomic_unchecked_t bt_lost_no_mapping;
45129 + atomic_unchecked_t event_lost_overflow;
45130 + atomic_unchecked_t multiplex_counter;
45131 };
45132
45133 extern struct oprofile_stat_struct oprofile_stats;
45134 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45135 index 7c12d9c..558bf3bb 100644
45136 --- a/drivers/oprofile/oprofilefs.c
45137 +++ b/drivers/oprofile/oprofilefs.c
45138 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
45139
45140
45141 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
45142 - char const *name, atomic_t *val)
45143 + char const *name, atomic_unchecked_t *val)
45144 {
45145 return __oprofilefs_create_file(sb, root, name,
45146 &atomic_ro_fops, 0444, val);
45147 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45148 index 61be1d9..dec05d7 100644
45149 --- a/drivers/oprofile/timer_int.c
45150 +++ b/drivers/oprofile/timer_int.c
45151 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45152 return NOTIFY_OK;
45153 }
45154
45155 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45156 +static struct notifier_block oprofile_cpu_notifier = {
45157 .notifier_call = oprofile_cpu_notify,
45158 };
45159
45160 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45161 index 92ed045..62d39bd7 100644
45162 --- a/drivers/parport/procfs.c
45163 +++ b/drivers/parport/procfs.c
45164 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45165
45166 *ppos += len;
45167
45168 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45169 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45170 }
45171
45172 #ifdef CONFIG_PARPORT_1284
45173 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45174
45175 *ppos += len;
45176
45177 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45178 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45179 }
45180 #endif /* IEEE1284.3 support. */
45181
45182 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45183 index c35e8ad..fc33beb 100644
45184 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45185 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45186 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
45187 goto init_cleanup;
45188 }
45189
45190 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45191 + pax_open_kernel();
45192 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45193 + pax_close_kernel();
45194 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45195
45196 return retval;
45197 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45198 index a6a71c4..c91097b 100644
45199 --- a/drivers/pci/hotplug/cpcihp_generic.c
45200 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45201 @@ -73,7 +73,6 @@ static u16 port;
45202 static unsigned int enum_bit;
45203 static u8 enum_mask;
45204
45205 -static struct cpci_hp_controller_ops generic_hpc_ops;
45206 static struct cpci_hp_controller generic_hpc;
45207
45208 static int __init validate_parameters(void)
45209 @@ -139,6 +138,10 @@ static int query_enum(void)
45210 return ((value & enum_mask) == enum_mask);
45211 }
45212
45213 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45214 + .query_enum = query_enum,
45215 +};
45216 +
45217 static int __init cpcihp_generic_init(void)
45218 {
45219 int status;
45220 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45221 pci_dev_put(dev);
45222
45223 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45224 - generic_hpc_ops.query_enum = query_enum;
45225 generic_hpc.ops = &generic_hpc_ops;
45226
45227 status = cpci_hp_register_controller(&generic_hpc);
45228 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45229 index 449b4bb..257e2e8 100644
45230 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45231 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45232 @@ -59,7 +59,6 @@
45233 /* local variables */
45234 static bool debug;
45235 static bool poll;
45236 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45237 static struct cpci_hp_controller zt5550_hpc;
45238
45239 /* Primary cPCI bus bridge device */
45240 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45241 return 0;
45242 }
45243
45244 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45245 + .query_enum = zt5550_hc_query_enum,
45246 +};
45247 +
45248 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45249 {
45250 int status;
45251 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45252 dbg("returned from zt5550_hc_config");
45253
45254 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45255 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45256 zt5550_hpc.ops = &zt5550_hpc_ops;
45257 if(!poll) {
45258 zt5550_hpc.irq = hc_dev->irq;
45259 zt5550_hpc.irq_flags = IRQF_SHARED;
45260 zt5550_hpc.dev_id = hc_dev;
45261
45262 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45263 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45264 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45265 + pax_open_kernel();
45266 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45267 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45268 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45269 + pax_open_kernel();
45270 } else {
45271 info("using ENUM# polling mode");
45272 }
45273 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45274 index 76ba8a1..20ca857 100644
45275 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45276 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45277 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45278
45279 void compaq_nvram_init (void __iomem *rom_start)
45280 {
45281 +
45282 +#ifndef CONFIG_PAX_KERNEXEC
45283 if (rom_start) {
45284 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45285 }
45286 +#endif
45287 +
45288 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45289
45290 /* initialize our int15 lock */
45291 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45292 index ec20f74..c1d961e 100644
45293 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45294 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45295 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45296 return -EINVAL;
45297 }
45298
45299 - slot->ops->owner = owner;
45300 - slot->ops->mod_name = mod_name;
45301 + pax_open_kernel();
45302 + *(struct module **)&slot->ops->owner = owner;
45303 + *(const char **)&slot->ops->mod_name = mod_name;
45304 + pax_close_kernel();
45305
45306 mutex_lock(&pci_hp_mutex);
45307 /*
45308 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45309 index 7d72c5e..edce02c 100644
45310 --- a/drivers/pci/hotplug/pciehp_core.c
45311 +++ b/drivers/pci/hotplug/pciehp_core.c
45312 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
45313 struct slot *slot = ctrl->slot;
45314 struct hotplug_slot *hotplug = NULL;
45315 struct hotplug_slot_info *info = NULL;
45316 - struct hotplug_slot_ops *ops = NULL;
45317 + hotplug_slot_ops_no_const *ops = NULL;
45318 char name[SLOT_NAME_SIZE];
45319 int retval = -ENOMEM;
45320
45321 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45322 index c0dbe1f..94cf3d8 100644
45323 --- a/drivers/pci/pci-sysfs.c
45324 +++ b/drivers/pci/pci-sysfs.c
45325 @@ -1073,7 +1073,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45326 {
45327 /* allocate attribute structure, piggyback attribute name */
45328 int name_len = write_combine ? 13 : 10;
45329 - struct bin_attribute *res_attr;
45330 + bin_attribute_no_const *res_attr;
45331 int retval;
45332
45333 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45334 @@ -1258,7 +1258,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45335 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45336 {
45337 int retval;
45338 - struct bin_attribute *attr;
45339 + bin_attribute_no_const *attr;
45340
45341 /* If the device has VPD, try to expose it in sysfs. */
45342 if (dev->vpd) {
45343 @@ -1305,7 +1305,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45344 {
45345 int retval;
45346 int rom_size = 0;
45347 - struct bin_attribute *attr;
45348 + bin_attribute_no_const *attr;
45349
45350 if (!sysfs_initialized)
45351 return -EACCES;
45352 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45353 index d1182c4..2a138ec 100644
45354 --- a/drivers/pci/pci.h
45355 +++ b/drivers/pci/pci.h
45356 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
45357 struct pci_vpd {
45358 unsigned int len;
45359 const struct pci_vpd_ops *ops;
45360 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45361 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45362 };
45363
45364 int pci_vpd_pci22_init(struct pci_dev *dev);
45365 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45366 index 403a443..034e050 100644
45367 --- a/drivers/pci/pcie/aspm.c
45368 +++ b/drivers/pci/pcie/aspm.c
45369 @@ -27,9 +27,9 @@
45370 #define MODULE_PARAM_PREFIX "pcie_aspm."
45371
45372 /* Note: those are not register definitions */
45373 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45374 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45375 -#define ASPM_STATE_L1 (4) /* L1 state */
45376 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45377 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45378 +#define ASPM_STATE_L1 (4U) /* L1 state */
45379 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45380 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45381
45382 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45383 index 46ada5c..20da716 100644
45384 --- a/drivers/pci/probe.c
45385 +++ b/drivers/pci/probe.c
45386 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45387 struct pci_bus_region region, inverted_region;
45388 bool bar_too_big = false, bar_disabled = false;
45389
45390 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45391 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45392
45393 /* No printks while decoding is disabled! */
45394 if (!dev->mmio_always_on) {
45395 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45396 index cdc7836..528635c 100644
45397 --- a/drivers/pci/proc.c
45398 +++ b/drivers/pci/proc.c
45399 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45400 static int __init pci_proc_init(void)
45401 {
45402 struct pci_dev *dev = NULL;
45403 +
45404 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45405 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45406 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45407 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45408 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45409 +#endif
45410 +#else
45411 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45412 +#endif
45413 proc_create("devices", 0, proc_bus_pci_dir,
45414 &proc_bus_pci_dev_operations);
45415 proc_initialized = 1;
45416 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45417 index 3e5b4497..dcdfb70 100644
45418 --- a/drivers/platform/x86/chromeos_laptop.c
45419 +++ b/drivers/platform/x86/chromeos_laptop.c
45420 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45421 return 0;
45422 }
45423
45424 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45425 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45426 {
45427 .ident = "Samsung Series 5 550 - Touchpad",
45428 .matches = {
45429 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45430 index 62f8030..c7f2a45 100644
45431 --- a/drivers/platform/x86/msi-laptop.c
45432 +++ b/drivers/platform/x86/msi-laptop.c
45433 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45434
45435 if (!quirks->ec_read_only) {
45436 /* allow userland write sysfs file */
45437 - dev_attr_bluetooth.store = store_bluetooth;
45438 - dev_attr_wlan.store = store_wlan;
45439 - dev_attr_threeg.store = store_threeg;
45440 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45441 - dev_attr_wlan.attr.mode |= S_IWUSR;
45442 - dev_attr_threeg.attr.mode |= S_IWUSR;
45443 + pax_open_kernel();
45444 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45445 + *(void **)&dev_attr_wlan.store = store_wlan;
45446 + *(void **)&dev_attr_threeg.store = store_threeg;
45447 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45448 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45449 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45450 + pax_close_kernel();
45451 }
45452
45453 /* disable hardware control by fn key */
45454 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45455 index 3a1b6bf..b453930 100644
45456 --- a/drivers/platform/x86/sony-laptop.c
45457 +++ b/drivers/platform/x86/sony-laptop.c
45458 @@ -2486,7 +2486,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45459 }
45460
45461 /* High speed charging function */
45462 -static struct device_attribute *hsc_handle;
45463 +static device_attribute_no_const *hsc_handle;
45464
45465 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45466 struct device_attribute *attr,
45467 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45468 index 54d31c0..3f896d3 100644
45469 --- a/drivers/platform/x86/thinkpad_acpi.c
45470 +++ b/drivers/platform/x86/thinkpad_acpi.c
45471 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
45472 return 0;
45473 }
45474
45475 -void static hotkey_mask_warn_incomplete_mask(void)
45476 +static void hotkey_mask_warn_incomplete_mask(void)
45477 {
45478 /* log only what the user can fix... */
45479 const u32 wantedmask = hotkey_driver_mask &
45480 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45481 }
45482 }
45483
45484 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45485 - struct tp_nvram_state *newn,
45486 - const u32 event_mask)
45487 -{
45488 -
45489 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45490 do { \
45491 if ((event_mask & (1 << __scancode)) && \
45492 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45493 tpacpi_hotkey_send_key(__scancode); \
45494 } while (0)
45495
45496 - void issue_volchange(const unsigned int oldvol,
45497 - const unsigned int newvol)
45498 - {
45499 - unsigned int i = oldvol;
45500 +static void issue_volchange(const unsigned int oldvol,
45501 + const unsigned int newvol,
45502 + const u32 event_mask)
45503 +{
45504 + unsigned int i = oldvol;
45505
45506 - while (i > newvol) {
45507 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45508 - i--;
45509 - }
45510 - while (i < newvol) {
45511 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45512 - i++;
45513 - }
45514 + while (i > newvol) {
45515 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45516 + i--;
45517 }
45518 + while (i < newvol) {
45519 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45520 + i++;
45521 + }
45522 +}
45523
45524 - void issue_brightnesschange(const unsigned int oldbrt,
45525 - const unsigned int newbrt)
45526 - {
45527 - unsigned int i = oldbrt;
45528 +static void issue_brightnesschange(const unsigned int oldbrt,
45529 + const unsigned int newbrt,
45530 + const u32 event_mask)
45531 +{
45532 + unsigned int i = oldbrt;
45533
45534 - while (i > newbrt) {
45535 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45536 - i--;
45537 - }
45538 - while (i < newbrt) {
45539 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45540 - i++;
45541 - }
45542 + while (i > newbrt) {
45543 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45544 + i--;
45545 + }
45546 + while (i < newbrt) {
45547 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45548 + i++;
45549 }
45550 +}
45551
45552 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45553 + struct tp_nvram_state *newn,
45554 + const u32 event_mask)
45555 +{
45556 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45557 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45558 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45559 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45560 oldn->volume_level != newn->volume_level) {
45561 /* recently muted, or repeated mute keypress, or
45562 * multiple presses ending in mute */
45563 - issue_volchange(oldn->volume_level, newn->volume_level);
45564 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45565 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45566 }
45567 } else {
45568 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45569 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45570 }
45571 if (oldn->volume_level != newn->volume_level) {
45572 - issue_volchange(oldn->volume_level, newn->volume_level);
45573 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45574 } else if (oldn->volume_toggle != newn->volume_toggle) {
45575 /* repeated vol up/down keypress at end of scale ? */
45576 if (newn->volume_level == 0)
45577 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45578 /* handle brightness */
45579 if (oldn->brightness_level != newn->brightness_level) {
45580 issue_brightnesschange(oldn->brightness_level,
45581 - newn->brightness_level);
45582 + newn->brightness_level,
45583 + event_mask);
45584 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45585 /* repeated key presses that didn't change state */
45586 if (newn->brightness_level == 0)
45587 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45588 && !tp_features.bright_unkfw)
45589 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45590 }
45591 +}
45592
45593 #undef TPACPI_COMPARE_KEY
45594 #undef TPACPI_MAY_SEND_KEY
45595 -}
45596
45597 /*
45598 * Polling driver
45599 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45600 index 769d265..a3a05ca 100644
45601 --- a/drivers/pnp/pnpbios/bioscalls.c
45602 +++ b/drivers/pnp/pnpbios/bioscalls.c
45603 @@ -58,7 +58,7 @@ do { \
45604 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45605 } while(0)
45606
45607 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45608 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45609 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45610
45611 /*
45612 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45613
45614 cpu = get_cpu();
45615 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45616 +
45617 + pax_open_kernel();
45618 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45619 + pax_close_kernel();
45620
45621 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45622 spin_lock_irqsave(&pnp_bios_lock, flags);
45623 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45624 :"memory");
45625 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45626
45627 + pax_open_kernel();
45628 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45629 + pax_close_kernel();
45630 +
45631 put_cpu();
45632
45633 /* If we get here and this is set then the PnP BIOS faulted on us. */
45634 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45635 return status;
45636 }
45637
45638 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45639 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45640 {
45641 int i;
45642
45643 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45644 pnp_bios_callpoint.offset = header->fields.pm16offset;
45645 pnp_bios_callpoint.segment = PNP_CS16;
45646
45647 + pax_open_kernel();
45648 +
45649 for_each_possible_cpu(i) {
45650 struct desc_struct *gdt = get_cpu_gdt_table(i);
45651 if (!gdt)
45652 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45653 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45654 (unsigned long)__va(header->fields.pm16dseg));
45655 }
45656 +
45657 + pax_close_kernel();
45658 }
45659 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45660 index d95e101..67f0c3f 100644
45661 --- a/drivers/pnp/resource.c
45662 +++ b/drivers/pnp/resource.c
45663 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
45664 return 1;
45665
45666 /* check if the resource is valid */
45667 - if (*irq < 0 || *irq > 15)
45668 + if (*irq > 15)
45669 return 0;
45670
45671 /* check if the resource is reserved */
45672 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
45673 return 1;
45674
45675 /* check if the resource is valid */
45676 - if (*dma < 0 || *dma == 4 || *dma > 7)
45677 + if (*dma == 4 || *dma > 7)
45678 return 0;
45679
45680 /* check if the resource is reserved */
45681 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
45682 index 0c52e2a..3421ab7 100644
45683 --- a/drivers/power/pda_power.c
45684 +++ b/drivers/power/pda_power.c
45685 @@ -37,7 +37,11 @@ static int polling;
45686
45687 #if IS_ENABLED(CONFIG_USB_PHY)
45688 static struct usb_phy *transceiver;
45689 -static struct notifier_block otg_nb;
45690 +static int otg_handle_notification(struct notifier_block *nb,
45691 + unsigned long event, void *unused);
45692 +static struct notifier_block otg_nb = {
45693 + .notifier_call = otg_handle_notification
45694 +};
45695 #endif
45696
45697 static struct regulator *ac_draw;
45698 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
45699
45700 #if IS_ENABLED(CONFIG_USB_PHY)
45701 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
45702 - otg_nb.notifier_call = otg_handle_notification;
45703 ret = usb_register_notifier(transceiver, &otg_nb);
45704 if (ret) {
45705 dev_err(dev, "failure to register otg notifier\n");
45706 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
45707 index cc439fd..8fa30df 100644
45708 --- a/drivers/power/power_supply.h
45709 +++ b/drivers/power/power_supply.h
45710 @@ -16,12 +16,12 @@ struct power_supply;
45711
45712 #ifdef CONFIG_SYSFS
45713
45714 -extern void power_supply_init_attrs(struct device_type *dev_type);
45715 +extern void power_supply_init_attrs(void);
45716 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
45717
45718 #else
45719
45720 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
45721 +static inline void power_supply_init_attrs(void) {}
45722 #define power_supply_uevent NULL
45723
45724 #endif /* CONFIG_SYSFS */
45725 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
45726 index 3b2d5df..3207114 100644
45727 --- a/drivers/power/power_supply_core.c
45728 +++ b/drivers/power/power_supply_core.c
45729 @@ -24,7 +24,10 @@
45730 struct class *power_supply_class;
45731 EXPORT_SYMBOL_GPL(power_supply_class);
45732
45733 -static struct device_type power_supply_dev_type;
45734 +extern const struct attribute_group *power_supply_attr_groups[];
45735 +static struct device_type power_supply_dev_type = {
45736 + .groups = power_supply_attr_groups,
45737 +};
45738
45739 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
45740 struct power_supply *supply)
45741 @@ -558,7 +561,7 @@ static int __init power_supply_class_init(void)
45742 return PTR_ERR(power_supply_class);
45743
45744 power_supply_class->dev_uevent = power_supply_uevent;
45745 - power_supply_init_attrs(&power_supply_dev_type);
45746 + power_supply_init_attrs();
45747
45748 return 0;
45749 }
45750 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
45751 index 29178f7..c65f324 100644
45752 --- a/drivers/power/power_supply_sysfs.c
45753 +++ b/drivers/power/power_supply_sysfs.c
45754 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
45755 .is_visible = power_supply_attr_is_visible,
45756 };
45757
45758 -static const struct attribute_group *power_supply_attr_groups[] = {
45759 +const struct attribute_group *power_supply_attr_groups[] = {
45760 &power_supply_attr_group,
45761 NULL,
45762 };
45763
45764 -void power_supply_init_attrs(struct device_type *dev_type)
45765 +void power_supply_init_attrs(void)
45766 {
45767 int i;
45768
45769 - dev_type->groups = power_supply_attr_groups;
45770 -
45771 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
45772 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
45773 }
45774 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
45775 index 288c75a..065bc84 100644
45776 --- a/drivers/regulator/core.c
45777 +++ b/drivers/regulator/core.c
45778 @@ -3544,7 +3544,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45779 {
45780 const struct regulation_constraints *constraints = NULL;
45781 const struct regulator_init_data *init_data;
45782 - static atomic_t regulator_no = ATOMIC_INIT(0);
45783 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
45784 struct regulator_dev *rdev;
45785 struct device *dev;
45786 int ret, i;
45787 @@ -3614,7 +3614,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45788 rdev->dev.of_node = config->of_node;
45789 rdev->dev.parent = dev;
45790 dev_set_name(&rdev->dev, "regulator.%d",
45791 - atomic_inc_return(&regulator_no) - 1);
45792 + atomic_inc_return_unchecked(&regulator_no) - 1);
45793 ret = device_register(&rdev->dev);
45794 if (ret != 0) {
45795 put_device(&rdev->dev);
45796 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
45797 index d428ef9..fdc0357 100644
45798 --- a/drivers/regulator/max8660.c
45799 +++ b/drivers/regulator/max8660.c
45800 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
45801 max8660->shadow_regs[MAX8660_OVER1] = 5;
45802 } else {
45803 /* Otherwise devices can be toggled via software */
45804 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
45805 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
45806 + pax_open_kernel();
45807 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
45808 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
45809 + pax_close_kernel();
45810 }
45811
45812 /*
45813 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
45814 index 0c5195a..637a453d 100644
45815 --- a/drivers/regulator/max8973-regulator.c
45816 +++ b/drivers/regulator/max8973-regulator.c
45817 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
45818 if (!pdata || !pdata->enable_ext_control) {
45819 max->desc.enable_reg = MAX8973_VOUT;
45820 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
45821 - max->ops.enable = regulator_enable_regmap;
45822 - max->ops.disable = regulator_disable_regmap;
45823 - max->ops.is_enabled = regulator_is_enabled_regmap;
45824 + pax_open_kernel();
45825 + *(void **)&max->ops.enable = regulator_enable_regmap;
45826 + *(void **)&max->ops.disable = regulator_disable_regmap;
45827 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
45828 + pax_close_kernel();
45829 }
45830
45831 if (pdata) {
45832 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
45833 index 1037e07..e64dea1 100644
45834 --- a/drivers/regulator/mc13892-regulator.c
45835 +++ b/drivers/regulator/mc13892-regulator.c
45836 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
45837 }
45838 mc13xxx_unlock(mc13892);
45839
45840 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45841 + pax_open_kernel();
45842 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45843 = mc13892_vcam_set_mode;
45844 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
45845 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
45846 = mc13892_vcam_get_mode;
45847 + pax_close_kernel();
45848
45849 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
45850 ARRAY_SIZE(mc13892_regulators));
45851 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
45852 index be06d71..264aee9 100644
45853 --- a/drivers/rtc/rtc-cmos.c
45854 +++ b/drivers/rtc/rtc-cmos.c
45855 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
45856 hpet_rtc_timer_init();
45857
45858 /* export at least the first block of NVRAM */
45859 - nvram.size = address_space - NVRAM_OFFSET;
45860 + pax_open_kernel();
45861 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
45862 + pax_close_kernel();
45863 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
45864 if (retval < 0) {
45865 dev_dbg(dev, "can't create nvram file? %d\n", retval);
45866 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
45867 index d049393..bb20be0 100644
45868 --- a/drivers/rtc/rtc-dev.c
45869 +++ b/drivers/rtc/rtc-dev.c
45870 @@ -16,6 +16,7 @@
45871 #include <linux/module.h>
45872 #include <linux/rtc.h>
45873 #include <linux/sched.h>
45874 +#include <linux/grsecurity.h>
45875 #include "rtc-core.h"
45876
45877 static dev_t rtc_devt;
45878 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
45879 if (copy_from_user(&tm, uarg, sizeof(tm)))
45880 return -EFAULT;
45881
45882 + gr_log_timechange();
45883 +
45884 return rtc_set_time(rtc, &tm);
45885
45886 case RTC_PIE_ON:
45887 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
45888 index ca18fd1..055e42d 100644
45889 --- a/drivers/rtc/rtc-ds1307.c
45890 +++ b/drivers/rtc/rtc-ds1307.c
45891 @@ -107,7 +107,7 @@ struct ds1307 {
45892 u8 offset; /* register's offset */
45893 u8 regs[11];
45894 u16 nvram_offset;
45895 - struct bin_attribute *nvram;
45896 + bin_attribute_no_const *nvram;
45897 enum ds_type type;
45898 unsigned long flags;
45899 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
45900 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
45901 index fcb0329..d77b7f2 100644
45902 --- a/drivers/rtc/rtc-m48t59.c
45903 +++ b/drivers/rtc/rtc-m48t59.c
45904 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
45905 if (IS_ERR(m48t59->rtc))
45906 return PTR_ERR(m48t59->rtc);
45907
45908 - m48t59_nvram_attr.size = pdata->offset;
45909 + pax_open_kernel();
45910 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
45911 + pax_close_kernel();
45912
45913 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
45914 if (ret)
45915 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
45916 index e693af6..2e525b6 100644
45917 --- a/drivers/scsi/bfa/bfa_fcpim.h
45918 +++ b/drivers/scsi/bfa/bfa_fcpim.h
45919 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
45920
45921 struct bfa_itn_s {
45922 bfa_isr_func_t isr;
45923 -};
45924 +} __no_const;
45925
45926 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
45927 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
45928 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
45929 index 90814fe..4384138 100644
45930 --- a/drivers/scsi/bfa/bfa_ioc.h
45931 +++ b/drivers/scsi/bfa/bfa_ioc.h
45932 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
45933 bfa_ioc_disable_cbfn_t disable_cbfn;
45934 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
45935 bfa_ioc_reset_cbfn_t reset_cbfn;
45936 -};
45937 +} __no_const;
45938
45939 /*
45940 * IOC event notification mechanism.
45941 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
45942 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
45943 enum bfi_ioc_state fwstate);
45944 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
45945 -};
45946 +} __no_const;
45947
45948 /*
45949 * Queue element to wait for room in request queue. FIFO order is
45950 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
45951 index c9382d6..6619864 100644
45952 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
45953 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
45954 @@ -33,8 +33,8 @@
45955 */
45956 #include "libfcoe.h"
45957
45958 -static atomic_t ctlr_num;
45959 -static atomic_t fcf_num;
45960 +static atomic_unchecked_t ctlr_num;
45961 +static atomic_unchecked_t fcf_num;
45962
45963 /*
45964 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
45965 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
45966 if (!ctlr)
45967 goto out;
45968
45969 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
45970 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
45971 ctlr->f = f;
45972 ctlr->mode = FIP_CONN_TYPE_FABRIC;
45973 INIT_LIST_HEAD(&ctlr->fcfs);
45974 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
45975 fcf->dev.parent = &ctlr->dev;
45976 fcf->dev.bus = &fcoe_bus_type;
45977 fcf->dev.type = &fcoe_fcf_device_type;
45978 - fcf->id = atomic_inc_return(&fcf_num) - 1;
45979 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
45980 fcf->state = FCOE_FCF_STATE_UNKNOWN;
45981
45982 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
45983 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
45984 {
45985 int error;
45986
45987 - atomic_set(&ctlr_num, 0);
45988 - atomic_set(&fcf_num, 0);
45989 + atomic_set_unchecked(&ctlr_num, 0);
45990 + atomic_set_unchecked(&fcf_num, 0);
45991
45992 error = bus_register(&fcoe_bus_type);
45993 if (error)
45994 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
45995 index df0c3c7..b00e1d0 100644
45996 --- a/drivers/scsi/hosts.c
45997 +++ b/drivers/scsi/hosts.c
45998 @@ -42,7 +42,7 @@
45999 #include "scsi_logging.h"
46000
46001
46002 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46003 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46004
46005
46006 static void scsi_host_cls_release(struct device *dev)
46007 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46008 * subtract one because we increment first then return, but we need to
46009 * know what the next host number was before increment
46010 */
46011 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46012 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46013 shost->dma_channel = 0xff;
46014
46015 /* These three are default values which can be overridden */
46016 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46017 index 7f4f790..b75b92a 100644
46018 --- a/drivers/scsi/hpsa.c
46019 +++ b/drivers/scsi/hpsa.c
46020 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46021 unsigned long flags;
46022
46023 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46024 - return h->access.command_completed(h, q);
46025 + return h->access->command_completed(h, q);
46026
46027 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46028 a = rq->head[rq->current_entry];
46029 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
46030 while (!list_empty(&h->reqQ)) {
46031 c = list_entry(h->reqQ.next, struct CommandList, list);
46032 /* can't do anything if fifo is full */
46033 - if ((h->access.fifo_full(h))) {
46034 + if ((h->access->fifo_full(h))) {
46035 dev_warn(&h->pdev->dev, "fifo full\n");
46036 break;
46037 }
46038 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
46039
46040 /* Tell the controller execute command */
46041 spin_unlock_irqrestore(&h->lock, flags);
46042 - h->access.submit_command(h, c);
46043 + h->access->submit_command(h, c);
46044 spin_lock_irqsave(&h->lock, flags);
46045 }
46046 spin_unlock_irqrestore(&h->lock, flags);
46047 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
46048
46049 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46050 {
46051 - return h->access.command_completed(h, q);
46052 + return h->access->command_completed(h, q);
46053 }
46054
46055 static inline bool interrupt_pending(struct ctlr_info *h)
46056 {
46057 - return h->access.intr_pending(h);
46058 + return h->access->intr_pending(h);
46059 }
46060
46061 static inline long interrupt_not_for_us(struct ctlr_info *h)
46062 {
46063 - return (h->access.intr_pending(h) == 0) ||
46064 + return (h->access->intr_pending(h) == 0) ||
46065 (h->interrupts_enabled == 0);
46066 }
46067
46068 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46069 if (prod_index < 0)
46070 return -ENODEV;
46071 h->product_name = products[prod_index].product_name;
46072 - h->access = *(products[prod_index].access);
46073 + h->access = products[prod_index].access;
46074
46075 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46076 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46077 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46078
46079 assert_spin_locked(&lockup_detector_lock);
46080 remove_ctlr_from_lockup_detector_list(h);
46081 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46082 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46083 spin_lock_irqsave(&h->lock, flags);
46084 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46085 spin_unlock_irqrestore(&h->lock, flags);
46086 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
46087 }
46088
46089 /* make sure the board interrupts are off */
46090 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46091 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46092
46093 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46094 goto clean2;
46095 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
46096 * fake ones to scoop up any residual completions.
46097 */
46098 spin_lock_irqsave(&h->lock, flags);
46099 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46100 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46101 spin_unlock_irqrestore(&h->lock, flags);
46102 free_irqs(h);
46103 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46104 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
46105 dev_info(&h->pdev->dev, "Board READY.\n");
46106 dev_info(&h->pdev->dev,
46107 "Waiting for stale completions to drain.\n");
46108 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46109 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46110 msleep(10000);
46111 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46112 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46113
46114 rc = controller_reset_failed(h->cfgtable);
46115 if (rc)
46116 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
46117 }
46118
46119 /* Turn the interrupts on so we can service requests */
46120 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46121 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46122
46123 hpsa_hba_inquiry(h);
46124 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46125 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46126 * To write all data in the battery backed cache to disks
46127 */
46128 hpsa_flush_cache(h);
46129 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46130 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46131 hpsa_free_irqs_and_disable_msix(h);
46132 }
46133
46134 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46135 return;
46136 }
46137 /* Change the access methods to the performant access methods */
46138 - h->access = SA5_performant_access;
46139 + h->access = &SA5_performant_access;
46140 h->transMethod = CFGTBL_Trans_Performant;
46141 }
46142
46143 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46144 index 9816479..c5d4e97 100644
46145 --- a/drivers/scsi/hpsa.h
46146 +++ b/drivers/scsi/hpsa.h
46147 @@ -79,7 +79,7 @@ struct ctlr_info {
46148 unsigned int msix_vector;
46149 unsigned int msi_vector;
46150 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46151 - struct access_method access;
46152 + struct access_method *access;
46153
46154 /* queue and queue Info */
46155 struct list_head reqQ;
46156 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46157 index 5879929..32b241d 100644
46158 --- a/drivers/scsi/libfc/fc_exch.c
46159 +++ b/drivers/scsi/libfc/fc_exch.c
46160 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46161 u16 pool_max_index;
46162
46163 struct {
46164 - atomic_t no_free_exch;
46165 - atomic_t no_free_exch_xid;
46166 - atomic_t xid_not_found;
46167 - atomic_t xid_busy;
46168 - atomic_t seq_not_found;
46169 - atomic_t non_bls_resp;
46170 + atomic_unchecked_t no_free_exch;
46171 + atomic_unchecked_t no_free_exch_xid;
46172 + atomic_unchecked_t xid_not_found;
46173 + atomic_unchecked_t xid_busy;
46174 + atomic_unchecked_t seq_not_found;
46175 + atomic_unchecked_t non_bls_resp;
46176 } stats;
46177 };
46178
46179 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46180 /* allocate memory for exchange */
46181 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46182 if (!ep) {
46183 - atomic_inc(&mp->stats.no_free_exch);
46184 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46185 goto out;
46186 }
46187 memset(ep, 0, sizeof(*ep));
46188 @@ -797,7 +797,7 @@ out:
46189 return ep;
46190 err:
46191 spin_unlock_bh(&pool->lock);
46192 - atomic_inc(&mp->stats.no_free_exch_xid);
46193 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46194 mempool_free(ep, mp->ep_pool);
46195 return NULL;
46196 }
46197 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46198 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46199 ep = fc_exch_find(mp, xid);
46200 if (!ep) {
46201 - atomic_inc(&mp->stats.xid_not_found);
46202 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46203 reject = FC_RJT_OX_ID;
46204 goto out;
46205 }
46206 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46207 ep = fc_exch_find(mp, xid);
46208 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46209 if (ep) {
46210 - atomic_inc(&mp->stats.xid_busy);
46211 + atomic_inc_unchecked(&mp->stats.xid_busy);
46212 reject = FC_RJT_RX_ID;
46213 goto rel;
46214 }
46215 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46216 }
46217 xid = ep->xid; /* get our XID */
46218 } else if (!ep) {
46219 - atomic_inc(&mp->stats.xid_not_found);
46220 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46221 reject = FC_RJT_RX_ID; /* XID not found */
46222 goto out;
46223 }
46224 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46225 } else {
46226 sp = &ep->seq;
46227 if (sp->id != fh->fh_seq_id) {
46228 - atomic_inc(&mp->stats.seq_not_found);
46229 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46230 if (f_ctl & FC_FC_END_SEQ) {
46231 /*
46232 * Update sequence_id based on incoming last
46233 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46234
46235 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46236 if (!ep) {
46237 - atomic_inc(&mp->stats.xid_not_found);
46238 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46239 goto out;
46240 }
46241 if (ep->esb_stat & ESB_ST_COMPLETE) {
46242 - atomic_inc(&mp->stats.xid_not_found);
46243 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46244 goto rel;
46245 }
46246 if (ep->rxid == FC_XID_UNKNOWN)
46247 ep->rxid = ntohs(fh->fh_rx_id);
46248 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46249 - atomic_inc(&mp->stats.xid_not_found);
46250 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46251 goto rel;
46252 }
46253 if (ep->did != ntoh24(fh->fh_s_id) &&
46254 ep->did != FC_FID_FLOGI) {
46255 - atomic_inc(&mp->stats.xid_not_found);
46256 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46257 goto rel;
46258 }
46259 sof = fr_sof(fp);
46260 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46261 sp->ssb_stat |= SSB_ST_RESP;
46262 sp->id = fh->fh_seq_id;
46263 } else if (sp->id != fh->fh_seq_id) {
46264 - atomic_inc(&mp->stats.seq_not_found);
46265 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46266 goto rel;
46267 }
46268
46269 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46270 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46271
46272 if (!sp)
46273 - atomic_inc(&mp->stats.xid_not_found);
46274 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46275 else
46276 - atomic_inc(&mp->stats.non_bls_resp);
46277 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46278
46279 fc_frame_free(fp);
46280 }
46281 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46282
46283 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46284 mp = ema->mp;
46285 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46286 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46287 st->fc_no_free_exch_xid +=
46288 - atomic_read(&mp->stats.no_free_exch_xid);
46289 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46290 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46291 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46292 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46293 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46294 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46295 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46296 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46297 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46298 }
46299 }
46300 EXPORT_SYMBOL(fc_exch_update_stats);
46301 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46302 index 161c98e..6d563b3 100644
46303 --- a/drivers/scsi/libsas/sas_ata.c
46304 +++ b/drivers/scsi/libsas/sas_ata.c
46305 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46306 .postreset = ata_std_postreset,
46307 .error_handler = ata_std_error_handler,
46308 .post_internal_cmd = sas_ata_post_internal,
46309 - .qc_defer = ata_std_qc_defer,
46310 + .qc_defer = ata_std_qc_defer,
46311 .qc_prep = ata_noop_qc_prep,
46312 .qc_issue = sas_ata_qc_issue,
46313 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46314 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46315 index 93f222d..73e977b 100644
46316 --- a/drivers/scsi/lpfc/lpfc.h
46317 +++ b/drivers/scsi/lpfc/lpfc.h
46318 @@ -431,7 +431,7 @@ struct lpfc_vport {
46319 struct dentry *debug_nodelist;
46320 struct dentry *vport_debugfs_root;
46321 struct lpfc_debugfs_trc *disc_trc;
46322 - atomic_t disc_trc_cnt;
46323 + atomic_unchecked_t disc_trc_cnt;
46324 #endif
46325 uint8_t stat_data_enabled;
46326 uint8_t stat_data_blocked;
46327 @@ -865,8 +865,8 @@ struct lpfc_hba {
46328 struct timer_list fabric_block_timer;
46329 unsigned long bit_flags;
46330 #define FABRIC_COMANDS_BLOCKED 0
46331 - atomic_t num_rsrc_err;
46332 - atomic_t num_cmd_success;
46333 + atomic_unchecked_t num_rsrc_err;
46334 + atomic_unchecked_t num_cmd_success;
46335 unsigned long last_rsrc_error_time;
46336 unsigned long last_ramp_down_time;
46337 unsigned long last_ramp_up_time;
46338 @@ -902,7 +902,7 @@ struct lpfc_hba {
46339
46340 struct dentry *debug_slow_ring_trc;
46341 struct lpfc_debugfs_trc *slow_ring_trc;
46342 - atomic_t slow_ring_trc_cnt;
46343 + atomic_unchecked_t slow_ring_trc_cnt;
46344 /* iDiag debugfs sub-directory */
46345 struct dentry *idiag_root;
46346 struct dentry *idiag_pci_cfg;
46347 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46348 index 60084e6..0e2e700 100644
46349 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46350 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46351 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46352
46353 #include <linux/debugfs.h>
46354
46355 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46356 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46357 static unsigned long lpfc_debugfs_start_time = 0L;
46358
46359 /* iDiag */
46360 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46361 lpfc_debugfs_enable = 0;
46362
46363 len = 0;
46364 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46365 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46366 (lpfc_debugfs_max_disc_trc - 1);
46367 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46368 dtp = vport->disc_trc + i;
46369 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46370 lpfc_debugfs_enable = 0;
46371
46372 len = 0;
46373 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46374 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46375 (lpfc_debugfs_max_slow_ring_trc - 1);
46376 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46377 dtp = phba->slow_ring_trc + i;
46378 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46379 !vport || !vport->disc_trc)
46380 return;
46381
46382 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46383 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46384 (lpfc_debugfs_max_disc_trc - 1);
46385 dtp = vport->disc_trc + index;
46386 dtp->fmt = fmt;
46387 dtp->data1 = data1;
46388 dtp->data2 = data2;
46389 dtp->data3 = data3;
46390 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46391 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46392 dtp->jif = jiffies;
46393 #endif
46394 return;
46395 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46396 !phba || !phba->slow_ring_trc)
46397 return;
46398
46399 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46400 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46401 (lpfc_debugfs_max_slow_ring_trc - 1);
46402 dtp = phba->slow_ring_trc + index;
46403 dtp->fmt = fmt;
46404 dtp->data1 = data1;
46405 dtp->data2 = data2;
46406 dtp->data3 = data3;
46407 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46408 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46409 dtp->jif = jiffies;
46410 #endif
46411 return;
46412 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46413 "slow_ring buffer\n");
46414 goto debug_failed;
46415 }
46416 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46417 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46418 memset(phba->slow_ring_trc, 0,
46419 (sizeof(struct lpfc_debugfs_trc) *
46420 lpfc_debugfs_max_slow_ring_trc));
46421 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46422 "buffer\n");
46423 goto debug_failed;
46424 }
46425 - atomic_set(&vport->disc_trc_cnt, 0);
46426 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46427
46428 snprintf(name, sizeof(name), "discovery_trace");
46429 vport->debug_disc_trc =
46430 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46431 index e0b20fa..30c2c0d 100644
46432 --- a/drivers/scsi/lpfc/lpfc_init.c
46433 +++ b/drivers/scsi/lpfc/lpfc_init.c
46434 @@ -10936,8 +10936,10 @@ lpfc_init(void)
46435 "misc_register returned with status %d", error);
46436
46437 if (lpfc_enable_npiv) {
46438 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46439 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46440 + pax_open_kernel();
46441 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46442 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46443 + pax_close_kernel();
46444 }
46445 lpfc_transport_template =
46446 fc_attach_transport(&lpfc_transport_functions);
46447 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46448 index 243de1d..f40e3e5 100644
46449 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46450 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46451 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46452 uint32_t evt_posted;
46453
46454 spin_lock_irqsave(&phba->hbalock, flags);
46455 - atomic_inc(&phba->num_rsrc_err);
46456 + atomic_inc_unchecked(&phba->num_rsrc_err);
46457 phba->last_rsrc_error_time = jiffies;
46458
46459 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46460 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46461 unsigned long flags;
46462 struct lpfc_hba *phba = vport->phba;
46463 uint32_t evt_posted;
46464 - atomic_inc(&phba->num_cmd_success);
46465 + atomic_inc_unchecked(&phba->num_cmd_success);
46466
46467 if (vport->cfg_lun_queue_depth <= queue_depth)
46468 return;
46469 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46470 unsigned long num_rsrc_err, num_cmd_success;
46471 int i;
46472
46473 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46474 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46475 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46476 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46477
46478 /*
46479 * The error and success command counters are global per
46480 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46481 }
46482 }
46483 lpfc_destroy_vport_work_array(phba, vports);
46484 - atomic_set(&phba->num_rsrc_err, 0);
46485 - atomic_set(&phba->num_cmd_success, 0);
46486 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46487 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46488 }
46489
46490 /**
46491 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46492 }
46493 }
46494 lpfc_destroy_vport_work_array(phba, vports);
46495 - atomic_set(&phba->num_rsrc_err, 0);
46496 - atomic_set(&phba->num_cmd_success, 0);
46497 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46498 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46499 }
46500
46501 /**
46502 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46503 index 1eb7b028..b2a6080 100644
46504 --- a/drivers/scsi/pmcraid.c
46505 +++ b/drivers/scsi/pmcraid.c
46506 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46507 res->scsi_dev = scsi_dev;
46508 scsi_dev->hostdata = res;
46509 res->change_detected = 0;
46510 - atomic_set(&res->read_failures, 0);
46511 - atomic_set(&res->write_failures, 0);
46512 + atomic_set_unchecked(&res->read_failures, 0);
46513 + atomic_set_unchecked(&res->write_failures, 0);
46514 rc = 0;
46515 }
46516 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46517 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46518
46519 /* If this was a SCSI read/write command keep count of errors */
46520 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46521 - atomic_inc(&res->read_failures);
46522 + atomic_inc_unchecked(&res->read_failures);
46523 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46524 - atomic_inc(&res->write_failures);
46525 + atomic_inc_unchecked(&res->write_failures);
46526
46527 if (!RES_IS_GSCSI(res->cfg_entry) &&
46528 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46529 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46530 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46531 * hrrq_id assigned here in queuecommand
46532 */
46533 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46534 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46535 pinstance->num_hrrq;
46536 cmd->cmd_done = pmcraid_io_done;
46537
46538 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46539 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46540 * hrrq_id assigned here in queuecommand
46541 */
46542 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46543 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46544 pinstance->num_hrrq;
46545
46546 if (request_size) {
46547 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46548
46549 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46550 /* add resources only after host is added into system */
46551 - if (!atomic_read(&pinstance->expose_resources))
46552 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46553 return;
46554
46555 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46556 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46557 init_waitqueue_head(&pinstance->reset_wait_q);
46558
46559 atomic_set(&pinstance->outstanding_cmds, 0);
46560 - atomic_set(&pinstance->last_message_id, 0);
46561 - atomic_set(&pinstance->expose_resources, 0);
46562 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46563 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46564
46565 INIT_LIST_HEAD(&pinstance->free_res_q);
46566 INIT_LIST_HEAD(&pinstance->used_res_q);
46567 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46568 /* Schedule worker thread to handle CCN and take care of adding and
46569 * removing devices to OS
46570 */
46571 - atomic_set(&pinstance->expose_resources, 1);
46572 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46573 schedule_work(&pinstance->worker_q);
46574 return rc;
46575
46576 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46577 index e1d150f..6c6df44 100644
46578 --- a/drivers/scsi/pmcraid.h
46579 +++ b/drivers/scsi/pmcraid.h
46580 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46581 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46582
46583 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46584 - atomic_t last_message_id;
46585 + atomic_unchecked_t last_message_id;
46586
46587 /* configuration table */
46588 struct pmcraid_config_table *cfg_table;
46589 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46590 atomic_t outstanding_cmds;
46591
46592 /* should add/delete resources to mid-layer now ?*/
46593 - atomic_t expose_resources;
46594 + atomic_unchecked_t expose_resources;
46595
46596
46597
46598 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46599 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46600 };
46601 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46602 - atomic_t read_failures; /* count of failed READ commands */
46603 - atomic_t write_failures; /* count of failed WRITE commands */
46604 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46605 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46606
46607 /* To indicate add/delete/modify during CCN */
46608 u8 change_detected;
46609 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46610 index d7a99ae..801df70 100644
46611 --- a/drivers/scsi/qla2xxx/qla_attr.c
46612 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46613 @@ -2004,7 +2004,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46614 return 0;
46615 }
46616
46617 -struct fc_function_template qla2xxx_transport_functions = {
46618 +fc_function_template_no_const qla2xxx_transport_functions = {
46619
46620 .show_host_node_name = 1,
46621 .show_host_port_name = 1,
46622 @@ -2051,7 +2051,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46623 .bsg_timeout = qla24xx_bsg_timeout,
46624 };
46625
46626 -struct fc_function_template qla2xxx_transport_vport_functions = {
46627 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46628
46629 .show_host_node_name = 1,
46630 .show_host_port_name = 1,
46631 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46632 index 2d98232..a84298e 100644
46633 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46634 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46635 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46636 struct device_attribute;
46637 extern struct device_attribute *qla2x00_host_attrs[];
46638 struct fc_function_template;
46639 -extern struct fc_function_template qla2xxx_transport_functions;
46640 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46641 +extern fc_function_template_no_const qla2xxx_transport_functions;
46642 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46643 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46644 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46645 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
46646 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
46647 index 3e21e9f..426ba79 100644
46648 --- a/drivers/scsi/qla2xxx/qla_os.c
46649 +++ b/drivers/scsi/qla2xxx/qla_os.c
46650 @@ -1570,8 +1570,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
46651 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
46652 /* Ok, a 64bit DMA mask is applicable. */
46653 ha->flags.enable_64bit_addressing = 1;
46654 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46655 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46656 + pax_open_kernel();
46657 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46658 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46659 + pax_close_kernel();
46660 return;
46661 }
46662 }
46663 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
46664 index ddf16a8..80f4dd0 100644
46665 --- a/drivers/scsi/qla4xxx/ql4_def.h
46666 +++ b/drivers/scsi/qla4xxx/ql4_def.h
46667 @@ -291,7 +291,7 @@ struct ddb_entry {
46668 * (4000 only) */
46669 atomic_t relogin_timer; /* Max Time to wait for
46670 * relogin to complete */
46671 - atomic_t relogin_retry_count; /* Num of times relogin has been
46672 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
46673 * retried */
46674 uint32_t default_time2wait; /* Default Min time between
46675 * relogins (+aens) */
46676 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
46677 index b246b3c..897004d 100644
46678 --- a/drivers/scsi/qla4xxx/ql4_os.c
46679 +++ b/drivers/scsi/qla4xxx/ql4_os.c
46680 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
46681 */
46682 if (!iscsi_is_session_online(cls_sess)) {
46683 /* Reset retry relogin timer */
46684 - atomic_inc(&ddb_entry->relogin_retry_count);
46685 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
46686 DEBUG2(ql4_printk(KERN_INFO, ha,
46687 "%s: index[%d] relogin timed out-retrying"
46688 " relogin (%d), retry (%d)\n", __func__,
46689 ddb_entry->fw_ddb_index,
46690 - atomic_read(&ddb_entry->relogin_retry_count),
46691 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
46692 ddb_entry->default_time2wait + 4));
46693 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
46694 atomic_set(&ddb_entry->retry_relogin_timer,
46695 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
46696
46697 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
46698 atomic_set(&ddb_entry->relogin_timer, 0);
46699 - atomic_set(&ddb_entry->relogin_retry_count, 0);
46700 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
46701 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
46702 ddb_entry->default_relogin_timeout =
46703 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
46704 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
46705 index eaa808e..95f8841 100644
46706 --- a/drivers/scsi/scsi.c
46707 +++ b/drivers/scsi/scsi.c
46708 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
46709 unsigned long timeout;
46710 int rtn = 0;
46711
46712 - atomic_inc(&cmd->device->iorequest_cnt);
46713 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46714
46715 /* check if the device is still usable */
46716 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
46717 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
46718 index 124392f..75eb43e 100644
46719 --- a/drivers/scsi/scsi_lib.c
46720 +++ b/drivers/scsi/scsi_lib.c
46721 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
46722 shost = sdev->host;
46723 scsi_init_cmd_errh(cmd);
46724 cmd->result = DID_NO_CONNECT << 16;
46725 - atomic_inc(&cmd->device->iorequest_cnt);
46726 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46727
46728 /*
46729 * SCSI request completion path will do scsi_device_unbusy(),
46730 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
46731
46732 INIT_LIST_HEAD(&cmd->eh_entry);
46733
46734 - atomic_inc(&cmd->device->iodone_cnt);
46735 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
46736 if (cmd->result)
46737 - atomic_inc(&cmd->device->ioerr_cnt);
46738 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
46739
46740 disposition = scsi_decide_disposition(cmd);
46741 if (disposition != SUCCESS &&
46742 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
46743 index 7e50061..71db7a6 100644
46744 --- a/drivers/scsi/scsi_sysfs.c
46745 +++ b/drivers/scsi/scsi_sysfs.c
46746 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
46747 char *buf) \
46748 { \
46749 struct scsi_device *sdev = to_scsi_device(dev); \
46750 - unsigned long long count = atomic_read(&sdev->field); \
46751 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
46752 return snprintf(buf, 20, "0x%llx\n", count); \
46753 } \
46754 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
46755 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
46756 index 84a1fdf..693b0d6 100644
46757 --- a/drivers/scsi/scsi_tgt_lib.c
46758 +++ b/drivers/scsi/scsi_tgt_lib.c
46759 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
46760 int err;
46761
46762 dprintk("%lx %u\n", uaddr, len);
46763 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
46764 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
46765 if (err) {
46766 /*
46767 * TODO: need to fixup sg_tablesize, max_segment_size,
46768 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
46769 index 4628fd5..a94a1c2 100644
46770 --- a/drivers/scsi/scsi_transport_fc.c
46771 +++ b/drivers/scsi/scsi_transport_fc.c
46772 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
46773 * Netlink Infrastructure
46774 */
46775
46776 -static atomic_t fc_event_seq;
46777 +static atomic_unchecked_t fc_event_seq;
46778
46779 /**
46780 * fc_get_event_number - Obtain the next sequential FC event number
46781 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
46782 u32
46783 fc_get_event_number(void)
46784 {
46785 - return atomic_add_return(1, &fc_event_seq);
46786 + return atomic_add_return_unchecked(1, &fc_event_seq);
46787 }
46788 EXPORT_SYMBOL(fc_get_event_number);
46789
46790 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
46791 {
46792 int error;
46793
46794 - atomic_set(&fc_event_seq, 0);
46795 + atomic_set_unchecked(&fc_event_seq, 0);
46796
46797 error = transport_class_register(&fc_host_class);
46798 if (error)
46799 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
46800 char *cp;
46801
46802 *val = simple_strtoul(buf, &cp, 0);
46803 - if ((*cp && (*cp != '\n')) || (*val < 0))
46804 + if (*cp && (*cp != '\n'))
46805 return -EINVAL;
46806 /*
46807 * Check for overflow; dev_loss_tmo is u32
46808 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
46809 index abf7c40..c3240ed 100644
46810 --- a/drivers/scsi/scsi_transport_iscsi.c
46811 +++ b/drivers/scsi/scsi_transport_iscsi.c
46812 @@ -80,7 +80,7 @@ struct iscsi_internal {
46813 struct transport_container session_cont;
46814 };
46815
46816 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
46817 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
46818 static struct workqueue_struct *iscsi_eh_timer_workq;
46819
46820 static DEFINE_IDA(iscsi_sess_ida);
46821 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
46822 int err;
46823
46824 ihost = shost->shost_data;
46825 - session->sid = atomic_add_return(1, &iscsi_session_nr);
46826 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
46827
46828 if (target_id == ISCSI_MAX_TARGET) {
46829 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
46830 @@ -3956,7 +3956,7 @@ static __init int iscsi_transport_init(void)
46831 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
46832 ISCSI_TRANSPORT_VERSION);
46833
46834 - atomic_set(&iscsi_session_nr, 0);
46835 + atomic_set_unchecked(&iscsi_session_nr, 0);
46836
46837 err = class_register(&iscsi_transport_class);
46838 if (err)
46839 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
46840 index f379c7f..e8fc69c 100644
46841 --- a/drivers/scsi/scsi_transport_srp.c
46842 +++ b/drivers/scsi/scsi_transport_srp.c
46843 @@ -33,7 +33,7 @@
46844 #include "scsi_transport_srp_internal.h"
46845
46846 struct srp_host_attrs {
46847 - atomic_t next_port_id;
46848 + atomic_unchecked_t next_port_id;
46849 };
46850 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
46851
46852 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
46853 struct Scsi_Host *shost = dev_to_shost(dev);
46854 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
46855
46856 - atomic_set(&srp_host->next_port_id, 0);
46857 + atomic_set_unchecked(&srp_host->next_port_id, 0);
46858 return 0;
46859 }
46860
46861 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
46862 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
46863 rport->roles = ids->roles;
46864
46865 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
46866 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
46867 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
46868
46869 transport_setup_device(&rport->dev);
46870 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
46871 index 2783dd7..d20395b 100644
46872 --- a/drivers/scsi/sd.c
46873 +++ b/drivers/scsi/sd.c
46874 @@ -2933,7 +2933,7 @@ static int sd_probe(struct device *dev)
46875 sdkp->disk = gd;
46876 sdkp->index = index;
46877 atomic_set(&sdkp->openers, 0);
46878 - atomic_set(&sdkp->device->ioerr_cnt, 0);
46879 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
46880
46881 if (!sdp->request_queue->rq_timeout) {
46882 if (sdp->type != TYPE_MOD)
46883 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
46884 index df5e961..df6b97f 100644
46885 --- a/drivers/scsi/sg.c
46886 +++ b/drivers/scsi/sg.c
46887 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
46888 sdp->disk->disk_name,
46889 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
46890 NULL,
46891 - (char *)arg);
46892 + (char __user *)arg);
46893 case BLKTRACESTART:
46894 return blk_trace_startstop(sdp->device->request_queue, 1);
46895 case BLKTRACESTOP:
46896 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
46897 index 978dda2..cb19aa0 100644
46898 --- a/drivers/spi/spi.c
46899 +++ b/drivers/spi/spi.c
46900 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
46901 EXPORT_SYMBOL_GPL(spi_bus_unlock);
46902
46903 /* portable code must never pass more than 32 bytes */
46904 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
46905 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
46906
46907 static u8 *buf;
46908
46909 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
46910 index ee3a57f..18368c1 100644
46911 --- a/drivers/staging/android/timed_output.c
46912 +++ b/drivers/staging/android/timed_output.c
46913 @@ -25,7 +25,7 @@
46914 #include "timed_output.h"
46915
46916 static struct class *timed_output_class;
46917 -static atomic_t device_count;
46918 +static atomic_unchecked_t device_count;
46919
46920 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
46921 char *buf)
46922 @@ -59,7 +59,7 @@ static int create_timed_output_class(void)
46923 timed_output_class = class_create(THIS_MODULE, "timed_output");
46924 if (IS_ERR(timed_output_class))
46925 return PTR_ERR(timed_output_class);
46926 - atomic_set(&device_count, 0);
46927 + atomic_set_unchecked(&device_count, 0);
46928 }
46929
46930 return 0;
46931 @@ -76,7 +76,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
46932 if (ret < 0)
46933 return ret;
46934
46935 - tdev->index = atomic_inc_return(&device_count);
46936 + tdev->index = atomic_inc_return_unchecked(&device_count);
46937 tdev->dev = device_create(timed_output_class, NULL,
46938 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
46939 if (IS_ERR(tdev->dev))
46940 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
46941 index 3675020..e80d92c 100644
46942 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
46943 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
46944 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
46945
46946 static int solo_sysfs_init(struct solo_dev *solo_dev)
46947 {
46948 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
46949 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
46950 struct device *dev = &solo_dev->dev;
46951 const char *driver;
46952 int i;
46953 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
46954 index 3335941..2b26186 100644
46955 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
46956 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
46957 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
46958
46959 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
46960 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
46961 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
46962 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
46963 if (p2m_id < 0)
46964 p2m_id = -p2m_id;
46965 }
46966 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
46967 index 6f91d2e..3f011d2 100644
46968 --- a/drivers/staging/media/solo6x10/solo6x10.h
46969 +++ b/drivers/staging/media/solo6x10/solo6x10.h
46970 @@ -238,7 +238,7 @@ struct solo_dev {
46971
46972 /* P2M DMA Engine */
46973 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
46974 - atomic_t p2m_count;
46975 + atomic_unchecked_t p2m_count;
46976 int p2m_jiffies;
46977 unsigned int p2m_timeouts;
46978
46979 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
46980 index 34afc16..ffe44dd 100644
46981 --- a/drivers/staging/octeon/ethernet-rx.c
46982 +++ b/drivers/staging/octeon/ethernet-rx.c
46983 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
46984 /* Increment RX stats for virtual ports */
46985 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
46986 #ifdef CONFIG_64BIT
46987 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
46988 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
46989 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
46990 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
46991 #else
46992 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
46993 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
46994 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
46995 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
46996 #endif
46997 }
46998 netif_receive_skb(skb);
46999 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47000 dev->name);
47001 */
47002 #ifdef CONFIG_64BIT
47003 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47004 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47005 #else
47006 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47007 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47008 #endif
47009 dev_kfree_skb_irq(skb);
47010 }
47011 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47012 index c3a90e7..023619a 100644
47013 --- a/drivers/staging/octeon/ethernet.c
47014 +++ b/drivers/staging/octeon/ethernet.c
47015 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47016 * since the RX tasklet also increments it.
47017 */
47018 #ifdef CONFIG_64BIT
47019 - atomic64_add(rx_status.dropped_packets,
47020 - (atomic64_t *)&priv->stats.rx_dropped);
47021 + atomic64_add_unchecked(rx_status.dropped_packets,
47022 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47023 #else
47024 - atomic_add(rx_status.dropped_packets,
47025 - (atomic_t *)&priv->stats.rx_dropped);
47026 + atomic_add_unchecked(rx_status.dropped_packets,
47027 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47028 #endif
47029 }
47030
47031 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47032 index dc23395..cf7e9b1 100644
47033 --- a/drivers/staging/rtl8712/rtl871x_io.h
47034 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47035 @@ -108,7 +108,7 @@ struct _io_ops {
47036 u8 *pmem);
47037 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47038 u8 *pmem);
47039 -};
47040 +} __no_const;
47041
47042 struct io_req {
47043 struct list_head list;
47044 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47045 index 1f5088b..0e59820 100644
47046 --- a/drivers/staging/sbe-2t3e3/netdev.c
47047 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47048 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47049 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47050
47051 if (rlen)
47052 - if (copy_to_user(data, &resp, rlen))
47053 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47054 return -EFAULT;
47055
47056 return 0;
47057 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47058 index a863a98..d272795 100644
47059 --- a/drivers/staging/usbip/vhci.h
47060 +++ b/drivers/staging/usbip/vhci.h
47061 @@ -83,7 +83,7 @@ struct vhci_hcd {
47062 unsigned resuming:1;
47063 unsigned long re_timeout;
47064
47065 - atomic_t seqnum;
47066 + atomic_unchecked_t seqnum;
47067
47068 /*
47069 * NOTE:
47070 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47071 index d7974cb..d78076b 100644
47072 --- a/drivers/staging/usbip/vhci_hcd.c
47073 +++ b/drivers/staging/usbip/vhci_hcd.c
47074 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47075
47076 spin_lock(&vdev->priv_lock);
47077
47078 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47079 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47080 if (priv->seqnum == 0xffff)
47081 dev_info(&urb->dev->dev, "seqnum max\n");
47082
47083 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47084 return -ENOMEM;
47085 }
47086
47087 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47088 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47089 if (unlink->seqnum == 0xffff)
47090 pr_info("seqnum max\n");
47091
47092 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47093 vdev->rhport = rhport;
47094 }
47095
47096 - atomic_set(&vhci->seqnum, 0);
47097 + atomic_set_unchecked(&vhci->seqnum, 0);
47098 spin_lock_init(&vhci->lock);
47099
47100 hcd->power_budget = 0; /* no limit */
47101 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47102 index d07fcb5..358e1e1 100644
47103 --- a/drivers/staging/usbip/vhci_rx.c
47104 +++ b/drivers/staging/usbip/vhci_rx.c
47105 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47106 if (!urb) {
47107 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47108 pr_info("max seqnum %d\n",
47109 - atomic_read(&the_controller->seqnum));
47110 + atomic_read_unchecked(&the_controller->seqnum));
47111 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47112 return;
47113 }
47114 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47115 index 57a08c5..5b4bb7c 100644
47116 --- a/drivers/staging/vt6655/hostap.c
47117 +++ b/drivers/staging/vt6655/hostap.c
47118 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47119 *
47120 */
47121
47122 +static net_device_ops_no_const apdev_netdev_ops;
47123 +
47124 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47125 {
47126 PSDevice apdev_priv;
47127 struct net_device *dev = pDevice->dev;
47128 int ret;
47129 - const struct net_device_ops apdev_netdev_ops = {
47130 - .ndo_start_xmit = pDevice->tx_80211,
47131 - };
47132
47133 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47134
47135 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47136 *apdev_priv = *pDevice;
47137 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47138
47139 + /* only half broken now */
47140 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47141 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47142
47143 pDevice->apdev->type = ARPHRD_IEEE80211;
47144 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47145 index c699a30..b90a5fd 100644
47146 --- a/drivers/staging/vt6656/hostap.c
47147 +++ b/drivers/staging/vt6656/hostap.c
47148 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47149 *
47150 */
47151
47152 +static net_device_ops_no_const apdev_netdev_ops;
47153 +
47154 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47155 {
47156 struct vnt_private *apdev_priv;
47157 struct net_device *dev = pDevice->dev;
47158 int ret;
47159 - const struct net_device_ops apdev_netdev_ops = {
47160 - .ndo_start_xmit = pDevice->tx_80211,
47161 - };
47162
47163 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47164
47165 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47166 *apdev_priv = *pDevice;
47167 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47168
47169 + /* only half broken now */
47170 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47171 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47172
47173 pDevice->apdev->type = ARPHRD_IEEE80211;
47174 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
47175 index d128ce2..fc1f9a1 100644
47176 --- a/drivers/staging/zcache/tmem.h
47177 +++ b/drivers/staging/zcache/tmem.h
47178 @@ -225,7 +225,7 @@ struct tmem_pamops {
47179 bool (*is_remote)(void *);
47180 int (*replace_in_obj)(void *, struct tmem_obj *);
47181 #endif
47182 -};
47183 +} __no_const;
47184 extern void tmem_register_pamops(struct tmem_pamops *m);
47185
47186 /* memory allocation methods provided by the host implementation */
47187 @@ -234,7 +234,7 @@ struct tmem_hostops {
47188 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
47189 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
47190 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
47191 -};
47192 +} __no_const;
47193 extern void tmem_register_hostops(struct tmem_hostops *m);
47194
47195 /* core tmem accessor functions */
47196 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47197 index e51b09a..5ebac31 100644
47198 --- a/drivers/target/sbp/sbp_target.c
47199 +++ b/drivers/target/sbp/sbp_target.c
47200 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47201
47202 #define SESSION_MAINTENANCE_INTERVAL HZ
47203
47204 -static atomic_t login_id = ATOMIC_INIT(0);
47205 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47206
47207 static void session_maintenance_work(struct work_struct *);
47208 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47209 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47210 login->lun = se_lun;
47211 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47212 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47213 - login->login_id = atomic_inc_return(&login_id);
47214 + login->login_id = atomic_inc_return_unchecked(&login_id);
47215
47216 login->tgt_agt = sbp_target_agent_register(login);
47217 if (IS_ERR(login->tgt_agt)) {
47218 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47219 index 8f4142f..b127f7d 100644
47220 --- a/drivers/target/target_core_device.c
47221 +++ b/drivers/target/target_core_device.c
47222 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47223 spin_lock_init(&dev->se_port_lock);
47224 spin_lock_init(&dev->se_tmr_lock);
47225 spin_lock_init(&dev->qf_cmd_lock);
47226 - atomic_set(&dev->dev_ordered_id, 0);
47227 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47228 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47229 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47230 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47231 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47232 index d8e49d7..6fcfdec 100644
47233 --- a/drivers/target/target_core_transport.c
47234 +++ b/drivers/target/target_core_transport.c
47235 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47236 * Used to determine when ORDERED commands should go from
47237 * Dormant to Active status.
47238 */
47239 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47240 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47241 smp_mb__after_atomic_inc();
47242 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47243 cmd->se_ordered_id, cmd->sam_task_attr,
47244 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47245 index 33f83fe..d80f8e1 100644
47246 --- a/drivers/tty/cyclades.c
47247 +++ b/drivers/tty/cyclades.c
47248 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47249 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47250 info->port.count);
47251 #endif
47252 - info->port.count++;
47253 + atomic_inc(&info->port.count);
47254 #ifdef CY_DEBUG_COUNT
47255 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47256 - current->pid, info->port.count);
47257 + current->pid, atomic_read(&info->port.count));
47258 #endif
47259
47260 /*
47261 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47262 for (j = 0; j < cy_card[i].nports; j++) {
47263 info = &cy_card[i].ports[j];
47264
47265 - if (info->port.count) {
47266 + if (atomic_read(&info->port.count)) {
47267 /* XXX is the ldisc num worth this? */
47268 struct tty_struct *tty;
47269 struct tty_ldisc *ld;
47270 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47271 index eb255e8..f637a57 100644
47272 --- a/drivers/tty/hvc/hvc_console.c
47273 +++ b/drivers/tty/hvc/hvc_console.c
47274 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47275
47276 spin_lock_irqsave(&hp->port.lock, flags);
47277 /* Check and then increment for fast path open. */
47278 - if (hp->port.count++ > 0) {
47279 + if (atomic_inc_return(&hp->port.count) > 1) {
47280 spin_unlock_irqrestore(&hp->port.lock, flags);
47281 hvc_kick();
47282 return 0;
47283 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47284
47285 spin_lock_irqsave(&hp->port.lock, flags);
47286
47287 - if (--hp->port.count == 0) {
47288 + if (atomic_dec_return(&hp->port.count) == 0) {
47289 spin_unlock_irqrestore(&hp->port.lock, flags);
47290 /* We are done with the tty pointer now. */
47291 tty_port_tty_set(&hp->port, NULL);
47292 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47293 */
47294 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47295 } else {
47296 - if (hp->port.count < 0)
47297 + if (atomic_read(&hp->port.count) < 0)
47298 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47299 - hp->vtermno, hp->port.count);
47300 + hp->vtermno, atomic_read(&hp->port.count));
47301 spin_unlock_irqrestore(&hp->port.lock, flags);
47302 }
47303 }
47304 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
47305 * open->hangup case this can be called after the final close so prevent
47306 * that from happening for now.
47307 */
47308 - if (hp->port.count <= 0) {
47309 + if (atomic_read(&hp->port.count) <= 0) {
47310 spin_unlock_irqrestore(&hp->port.lock, flags);
47311 return;
47312 }
47313
47314 - hp->port.count = 0;
47315 + atomic_set(&hp->port.count, 0);
47316 spin_unlock_irqrestore(&hp->port.lock, flags);
47317 tty_port_tty_set(&hp->port, NULL);
47318
47319 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47320 return -EPIPE;
47321
47322 /* FIXME what's this (unprotected) check for? */
47323 - if (hp->port.count <= 0)
47324 + if (atomic_read(&hp->port.count) <= 0)
47325 return -EIO;
47326
47327 spin_lock_irqsave(&hp->lock, flags);
47328 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47329 index 81e939e..95ead10 100644
47330 --- a/drivers/tty/hvc/hvcs.c
47331 +++ b/drivers/tty/hvc/hvcs.c
47332 @@ -83,6 +83,7 @@
47333 #include <asm/hvcserver.h>
47334 #include <asm/uaccess.h>
47335 #include <asm/vio.h>
47336 +#include <asm/local.h>
47337
47338 /*
47339 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47340 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47341
47342 spin_lock_irqsave(&hvcsd->lock, flags);
47343
47344 - if (hvcsd->port.count > 0) {
47345 + if (atomic_read(&hvcsd->port.count) > 0) {
47346 spin_unlock_irqrestore(&hvcsd->lock, flags);
47347 printk(KERN_INFO "HVCS: vterm state unchanged. "
47348 "The hvcs device node is still in use.\n");
47349 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47350 }
47351 }
47352
47353 - hvcsd->port.count = 0;
47354 + atomic_set(&hvcsd->port.count, 0);
47355 hvcsd->port.tty = tty;
47356 tty->driver_data = hvcsd;
47357
47358 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47359 unsigned long flags;
47360
47361 spin_lock_irqsave(&hvcsd->lock, flags);
47362 - hvcsd->port.count++;
47363 + atomic_inc(&hvcsd->port.count);
47364 hvcsd->todo_mask |= HVCS_SCHED_READ;
47365 spin_unlock_irqrestore(&hvcsd->lock, flags);
47366
47367 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47368 hvcsd = tty->driver_data;
47369
47370 spin_lock_irqsave(&hvcsd->lock, flags);
47371 - if (--hvcsd->port.count == 0) {
47372 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47373
47374 vio_disable_interrupts(hvcsd->vdev);
47375
47376 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47377
47378 free_irq(irq, hvcsd);
47379 return;
47380 - } else if (hvcsd->port.count < 0) {
47381 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47382 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47383 " is missmanaged.\n",
47384 - hvcsd->vdev->unit_address, hvcsd->port.count);
47385 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47386 }
47387
47388 spin_unlock_irqrestore(&hvcsd->lock, flags);
47389 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47390
47391 spin_lock_irqsave(&hvcsd->lock, flags);
47392 /* Preserve this so that we know how many kref refs to put */
47393 - temp_open_count = hvcsd->port.count;
47394 + temp_open_count = atomic_read(&hvcsd->port.count);
47395
47396 /*
47397 * Don't kref put inside the spinlock because the destruction
47398 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47399 tty->driver_data = NULL;
47400 hvcsd->port.tty = NULL;
47401
47402 - hvcsd->port.count = 0;
47403 + atomic_set(&hvcsd->port.count, 0);
47404
47405 /* This will drop any buffered data on the floor which is OK in a hangup
47406 * scenario. */
47407 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47408 * the middle of a write operation? This is a crummy place to do this
47409 * but we want to keep it all in the spinlock.
47410 */
47411 - if (hvcsd->port.count <= 0) {
47412 + if (atomic_read(&hvcsd->port.count) <= 0) {
47413 spin_unlock_irqrestore(&hvcsd->lock, flags);
47414 return -ENODEV;
47415 }
47416 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47417 {
47418 struct hvcs_struct *hvcsd = tty->driver_data;
47419
47420 - if (!hvcsd || hvcsd->port.count <= 0)
47421 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47422 return 0;
47423
47424 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47425 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47426 index 4190199..48f2920 100644
47427 --- a/drivers/tty/hvc/hvsi.c
47428 +++ b/drivers/tty/hvc/hvsi.c
47429 @@ -85,7 +85,7 @@ struct hvsi_struct {
47430 int n_outbuf;
47431 uint32_t vtermno;
47432 uint32_t virq;
47433 - atomic_t seqno; /* HVSI packet sequence number */
47434 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47435 uint16_t mctrl;
47436 uint8_t state; /* HVSI protocol state */
47437 uint8_t flags;
47438 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47439
47440 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47441 packet.hdr.len = sizeof(struct hvsi_query_response);
47442 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47443 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47444 packet.verb = VSV_SEND_VERSION_NUMBER;
47445 packet.u.version = HVSI_VERSION;
47446 packet.query_seqno = query_seqno+1;
47447 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47448
47449 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47450 packet.hdr.len = sizeof(struct hvsi_query);
47451 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47452 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47453 packet.verb = verb;
47454
47455 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47456 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47457 int wrote;
47458
47459 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47460 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47461 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47462 packet.hdr.len = sizeof(struct hvsi_control);
47463 packet.verb = VSV_SET_MODEM_CTL;
47464 packet.mask = HVSI_TSDTR;
47465 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47466 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47467
47468 packet.hdr.type = VS_DATA_PACKET_HEADER;
47469 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47470 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47471 packet.hdr.len = count + sizeof(struct hvsi_header);
47472 memcpy(&packet.data, buf, count);
47473
47474 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47475 struct hvsi_control packet __ALIGNED__;
47476
47477 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47478 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47479 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47480 packet.hdr.len = 6;
47481 packet.verb = VSV_CLOSE_PROTOCOL;
47482
47483 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47484 index ac27671..0f627ee 100644
47485 --- a/drivers/tty/hvc/hvsi_lib.c
47486 +++ b/drivers/tty/hvc/hvsi_lib.c
47487 @@ -9,7 +9,7 @@
47488
47489 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47490 {
47491 - packet->seqno = atomic_inc_return(&pv->seqno);
47492 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47493
47494 /* Assumes that always succeeds, works in practice */
47495 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47496 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47497
47498 /* Reset state */
47499 pv->established = 0;
47500 - atomic_set(&pv->seqno, 0);
47501 + atomic_set_unchecked(&pv->seqno, 0);
47502
47503 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47504
47505 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47506 pv->mctrl_update = 0;
47507 q.hdr.type = VS_QUERY_PACKET_HEADER;
47508 q.hdr.len = sizeof(struct hvsi_query);
47509 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47510 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47511 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47512 rc = hvsi_send_packet(pv, &q.hdr);
47513 if (rc <= 0) {
47514 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47515 index 8fd72ff..34a0bed 100644
47516 --- a/drivers/tty/ipwireless/tty.c
47517 +++ b/drivers/tty/ipwireless/tty.c
47518 @@ -29,6 +29,7 @@
47519 #include <linux/tty_driver.h>
47520 #include <linux/tty_flip.h>
47521 #include <linux/uaccess.h>
47522 +#include <asm/local.h>
47523
47524 #include "tty.h"
47525 #include "network.h"
47526 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47527 mutex_unlock(&tty->ipw_tty_mutex);
47528 return -ENODEV;
47529 }
47530 - if (tty->port.count == 0)
47531 + if (atomic_read(&tty->port.count) == 0)
47532 tty->tx_bytes_queued = 0;
47533
47534 - tty->port.count++;
47535 + atomic_inc(&tty->port.count);
47536
47537 tty->port.tty = linux_tty;
47538 linux_tty->driver_data = tty;
47539 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47540
47541 static void do_ipw_close(struct ipw_tty *tty)
47542 {
47543 - tty->port.count--;
47544 -
47545 - if (tty->port.count == 0) {
47546 + if (atomic_dec_return(&tty->port.count) == 0) {
47547 struct tty_struct *linux_tty = tty->port.tty;
47548
47549 if (linux_tty != NULL) {
47550 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47551 return;
47552
47553 mutex_lock(&tty->ipw_tty_mutex);
47554 - if (tty->port.count == 0) {
47555 + if (atomic_read(&tty->port.count) == 0) {
47556 mutex_unlock(&tty->ipw_tty_mutex);
47557 return;
47558 }
47559 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47560
47561 mutex_lock(&tty->ipw_tty_mutex);
47562
47563 - if (!tty->port.count) {
47564 + if (!atomic_read(&tty->port.count)) {
47565 mutex_unlock(&tty->ipw_tty_mutex);
47566 return;
47567 }
47568 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47569 return -ENODEV;
47570
47571 mutex_lock(&tty->ipw_tty_mutex);
47572 - if (!tty->port.count) {
47573 + if (!atomic_read(&tty->port.count)) {
47574 mutex_unlock(&tty->ipw_tty_mutex);
47575 return -EINVAL;
47576 }
47577 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47578 if (!tty)
47579 return -ENODEV;
47580
47581 - if (!tty->port.count)
47582 + if (!atomic_read(&tty->port.count))
47583 return -EINVAL;
47584
47585 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47586 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47587 if (!tty)
47588 return 0;
47589
47590 - if (!tty->port.count)
47591 + if (!atomic_read(&tty->port.count))
47592 return 0;
47593
47594 return tty->tx_bytes_queued;
47595 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47596 if (!tty)
47597 return -ENODEV;
47598
47599 - if (!tty->port.count)
47600 + if (!atomic_read(&tty->port.count))
47601 return -EINVAL;
47602
47603 return get_control_lines(tty);
47604 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
47605 if (!tty)
47606 return -ENODEV;
47607
47608 - if (!tty->port.count)
47609 + if (!atomic_read(&tty->port.count))
47610 return -EINVAL;
47611
47612 return set_control_lines(tty, set, clear);
47613 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47614 if (!tty)
47615 return -ENODEV;
47616
47617 - if (!tty->port.count)
47618 + if (!atomic_read(&tty->port.count))
47619 return -EINVAL;
47620
47621 /* FIXME: Exactly how is the tty object locked here .. */
47622 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47623 * are gone */
47624 mutex_lock(&ttyj->ipw_tty_mutex);
47625 }
47626 - while (ttyj->port.count)
47627 + while (atomic_read(&ttyj->port.count))
47628 do_ipw_close(ttyj);
47629 ipwireless_disassociate_network_ttys(network,
47630 ttyj->channel_idx);
47631 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47632 index 1deaca4..c8582d4 100644
47633 --- a/drivers/tty/moxa.c
47634 +++ b/drivers/tty/moxa.c
47635 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47636 }
47637
47638 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47639 - ch->port.count++;
47640 + atomic_inc(&ch->port.count);
47641 tty->driver_data = ch;
47642 tty_port_tty_set(&ch->port, tty);
47643 mutex_lock(&ch->port.mutex);
47644 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47645 index 6422390..49003ac8 100644
47646 --- a/drivers/tty/n_gsm.c
47647 +++ b/drivers/tty/n_gsm.c
47648 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
47649 spin_lock_init(&dlci->lock);
47650 mutex_init(&dlci->mutex);
47651 dlci->fifo = &dlci->_fifo;
47652 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
47653 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
47654 kfree(dlci);
47655 return NULL;
47656 }
47657 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
47658 struct gsm_dlci *dlci = tty->driver_data;
47659 struct tty_port *port = &dlci->port;
47660
47661 - port->count++;
47662 + atomic_inc(&port->count);
47663 dlci_get(dlci);
47664 dlci_get(dlci->gsm->dlci[0]);
47665 mux_get(dlci->gsm);
47666 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
47667 index 4bf0fc0..433bd58 100644
47668 --- a/drivers/tty/n_tty.c
47669 +++ b/drivers/tty/n_tty.c
47670 @@ -2217,6 +2217,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
47671 {
47672 *ops = tty_ldisc_N_TTY;
47673 ops->owner = NULL;
47674 - ops->refcount = ops->flags = 0;
47675 + atomic_set(&ops->refcount, 0);
47676 + ops->flags = 0;
47677 }
47678 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
47679 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
47680 index abfd990..5ab5da9 100644
47681 --- a/drivers/tty/pty.c
47682 +++ b/drivers/tty/pty.c
47683 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
47684 panic("Couldn't register Unix98 pts driver");
47685
47686 /* Now create the /dev/ptmx special device */
47687 + pax_open_kernel();
47688 tty_default_fops(&ptmx_fops);
47689 - ptmx_fops.open = ptmx_open;
47690 + *(void **)&ptmx_fops.open = ptmx_open;
47691 + pax_close_kernel();
47692
47693 cdev_init(&ptmx_cdev, &ptmx_fops);
47694 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
47695 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
47696 index 354564e..fe50d9a 100644
47697 --- a/drivers/tty/rocket.c
47698 +++ b/drivers/tty/rocket.c
47699 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47700 tty->driver_data = info;
47701 tty_port_tty_set(port, tty);
47702
47703 - if (port->count++ == 0) {
47704 + if (atomic_inc_return(&port->count) == 1) {
47705 atomic_inc(&rp_num_ports_open);
47706
47707 #ifdef ROCKET_DEBUG_OPEN
47708 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47709 #endif
47710 }
47711 #ifdef ROCKET_DEBUG_OPEN
47712 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
47713 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
47714 #endif
47715
47716 /*
47717 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
47718 spin_unlock_irqrestore(&info->port.lock, flags);
47719 return;
47720 }
47721 - if (info->port.count)
47722 + if (atomic_read(&info->port.count))
47723 atomic_dec(&rp_num_ports_open);
47724 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
47725 spin_unlock_irqrestore(&info->port.lock, flags);
47726 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
47727 index e2520ab..034e20b 100644
47728 --- a/drivers/tty/serial/ioc4_serial.c
47729 +++ b/drivers/tty/serial/ioc4_serial.c
47730 @@ -437,7 +437,7 @@ struct ioc4_soft {
47731 } is_intr_info[MAX_IOC4_INTR_ENTS];
47732
47733 /* Number of entries active in the above array */
47734 - atomic_t is_num_intrs;
47735 + atomic_unchecked_t is_num_intrs;
47736 } is_intr_type[IOC4_NUM_INTR_TYPES];
47737
47738 /* is_ir_lock must be held while
47739 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
47740 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
47741 || (type == IOC4_OTHER_INTR_TYPE)));
47742
47743 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
47744 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
47745 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
47746
47747 /* Save off the lower level interrupt handler */
47748 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
47749
47750 soft = arg;
47751 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
47752 - num_intrs = (int)atomic_read(
47753 + num_intrs = (int)atomic_read_unchecked(
47754 &soft->is_intr_type[intr_type].is_num_intrs);
47755
47756 this_mir = this_ir = pending_intrs(soft, intr_type);
47757 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
47758 index 1002054..dd644a8 100644
47759 --- a/drivers/tty/serial/kgdboc.c
47760 +++ b/drivers/tty/serial/kgdboc.c
47761 @@ -24,8 +24,9 @@
47762 #define MAX_CONFIG_LEN 40
47763
47764 static struct kgdb_io kgdboc_io_ops;
47765 +static struct kgdb_io kgdboc_io_ops_console;
47766
47767 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
47768 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
47769 static int configured = -1;
47770
47771 static char config[MAX_CONFIG_LEN];
47772 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
47773 kgdboc_unregister_kbd();
47774 if (configured == 1)
47775 kgdb_unregister_io_module(&kgdboc_io_ops);
47776 + else if (configured == 2)
47777 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
47778 }
47779
47780 static int configure_kgdboc(void)
47781 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
47782 int err;
47783 char *cptr = config;
47784 struct console *cons;
47785 + int is_console = 0;
47786
47787 err = kgdboc_option_setup(config);
47788 if (err || !strlen(config) || isspace(config[0]))
47789 goto noconfig;
47790
47791 err = -ENODEV;
47792 - kgdboc_io_ops.is_console = 0;
47793 kgdb_tty_driver = NULL;
47794
47795 kgdboc_use_kms = 0;
47796 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
47797 int idx;
47798 if (cons->device && cons->device(cons, &idx) == p &&
47799 idx == tty_line) {
47800 - kgdboc_io_ops.is_console = 1;
47801 + is_console = 1;
47802 break;
47803 }
47804 cons = cons->next;
47805 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
47806 kgdb_tty_line = tty_line;
47807
47808 do_register:
47809 - err = kgdb_register_io_module(&kgdboc_io_ops);
47810 + if (is_console) {
47811 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
47812 + configured = 2;
47813 + } else {
47814 + err = kgdb_register_io_module(&kgdboc_io_ops);
47815 + configured = 1;
47816 + }
47817 if (err)
47818 goto noconfig;
47819
47820 @@ -205,8 +214,6 @@ do_register:
47821 if (err)
47822 goto nmi_con_failed;
47823
47824 - configured = 1;
47825 -
47826 return 0;
47827
47828 nmi_con_failed:
47829 @@ -223,7 +230,7 @@ noconfig:
47830 static int __init init_kgdboc(void)
47831 {
47832 /* Already configured? */
47833 - if (configured == 1)
47834 + if (configured >= 1)
47835 return 0;
47836
47837 return configure_kgdboc();
47838 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
47839 if (config[len - 1] == '\n')
47840 config[len - 1] = '\0';
47841
47842 - if (configured == 1)
47843 + if (configured >= 1)
47844 cleanup_kgdboc();
47845
47846 /* Go and configure with the new params. */
47847 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
47848 .post_exception = kgdboc_post_exp_handler,
47849 };
47850
47851 +static struct kgdb_io kgdboc_io_ops_console = {
47852 + .name = "kgdboc",
47853 + .read_char = kgdboc_get_char,
47854 + .write_char = kgdboc_put_char,
47855 + .pre_exception = kgdboc_pre_exp_handler,
47856 + .post_exception = kgdboc_post_exp_handler,
47857 + .is_console = 1
47858 +};
47859 +
47860 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
47861 /* This is only available if kgdboc is a built in for early debugging */
47862 static int __init kgdboc_early_init(char *opt)
47863 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
47864 index 2c6cfb3..048274e 100644
47865 --- a/drivers/tty/serial/msm_serial.c
47866 +++ b/drivers/tty/serial/msm_serial.c
47867 @@ -857,7 +857,7 @@ static struct uart_driver msm_uart_driver = {
47868 .cons = MSM_CONSOLE,
47869 };
47870
47871 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
47872 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
47873
47874 static int __init msm_serial_probe(struct platform_device *pdev)
47875 {
47876 @@ -867,7 +867,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
47877 int irq;
47878
47879 if (pdev->id == -1)
47880 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
47881 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
47882
47883 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
47884 return -ENXIO;
47885 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
47886 index 376079b..d8de7aa 100644
47887 --- a/drivers/tty/serial/samsung.c
47888 +++ b/drivers/tty/serial/samsung.c
47889 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
47890 }
47891 }
47892
47893 +static int s3c64xx_serial_startup(struct uart_port *port);
47894 static int s3c24xx_serial_startup(struct uart_port *port)
47895 {
47896 struct s3c24xx_uart_port *ourport = to_ourport(port);
47897 int ret;
47898
47899 + /* Startup sequence is different for s3c64xx and higher SoC's */
47900 + if (s3c24xx_serial_has_interrupt_mask(port))
47901 + return s3c64xx_serial_startup(port);
47902 +
47903 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
47904 port->mapbase, port->membase);
47905
47906 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
47907 /* setup info for port */
47908 port->dev = &platdev->dev;
47909
47910 - /* Startup sequence is different for s3c64xx and higher SoC's */
47911 - if (s3c24xx_serial_has_interrupt_mask(port))
47912 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
47913 -
47914 port->uartclk = 1;
47915
47916 if (cfg->uart_flags & UPF_CONS_FLOW) {
47917 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
47918 index 28cdd28..56f1d60 100644
47919 --- a/drivers/tty/serial/serial_core.c
47920 +++ b/drivers/tty/serial/serial_core.c
47921 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
47922 uart_flush_buffer(tty);
47923 uart_shutdown(tty, state);
47924 spin_lock_irqsave(&port->lock, flags);
47925 - port->count = 0;
47926 + atomic_set(&port->count, 0);
47927 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
47928 spin_unlock_irqrestore(&port->lock, flags);
47929 tty_port_tty_set(port, NULL);
47930 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47931 goto end;
47932 }
47933
47934 - port->count++;
47935 + atomic_inc(&port->count);
47936 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
47937 retval = -ENXIO;
47938 goto err_dec_count;
47939 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47940 /*
47941 * Make sure the device is in D0 state.
47942 */
47943 - if (port->count == 1)
47944 + if (atomic_read(&port->count) == 1)
47945 uart_change_pm(state, UART_PM_STATE_ON);
47946
47947 /*
47948 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47949 end:
47950 return retval;
47951 err_dec_count:
47952 - port->count--;
47953 + atomic_inc(&port->count);
47954 mutex_unlock(&port->mutex);
47955 goto end;
47956 }
47957 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
47958 index 8eaf1ab..85c030d 100644
47959 --- a/drivers/tty/synclink.c
47960 +++ b/drivers/tty/synclink.c
47961 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
47962
47963 if (debug_level >= DEBUG_LEVEL_INFO)
47964 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
47965 - __FILE__,__LINE__, info->device_name, info->port.count);
47966 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
47967
47968 if (tty_port_close_start(&info->port, tty, filp) == 0)
47969 goto cleanup;
47970 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
47971 cleanup:
47972 if (debug_level >= DEBUG_LEVEL_INFO)
47973 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
47974 - tty->driver->name, info->port.count);
47975 + tty->driver->name, atomic_read(&info->port.count));
47976
47977 } /* end of mgsl_close() */
47978
47979 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
47980
47981 mgsl_flush_buffer(tty);
47982 shutdown(info);
47983 -
47984 - info->port.count = 0;
47985 +
47986 + atomic_set(&info->port.count, 0);
47987 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
47988 info->port.tty = NULL;
47989
47990 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
47991
47992 if (debug_level >= DEBUG_LEVEL_INFO)
47993 printk("%s(%d):block_til_ready before block on %s count=%d\n",
47994 - __FILE__,__LINE__, tty->driver->name, port->count );
47995 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
47996
47997 spin_lock_irqsave(&info->irq_spinlock, flags);
47998 if (!tty_hung_up_p(filp)) {
47999 extra_count = true;
48000 - port->count--;
48001 + atomic_dec(&port->count);
48002 }
48003 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48004 port->blocked_open++;
48005 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48006
48007 if (debug_level >= DEBUG_LEVEL_INFO)
48008 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48009 - __FILE__,__LINE__, tty->driver->name, port->count );
48010 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48011
48012 tty_unlock(tty);
48013 schedule();
48014 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48015
48016 /* FIXME: Racy on hangup during close wait */
48017 if (extra_count)
48018 - port->count++;
48019 + atomic_inc(&port->count);
48020 port->blocked_open--;
48021
48022 if (debug_level >= DEBUG_LEVEL_INFO)
48023 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48024 - __FILE__,__LINE__, tty->driver->name, port->count );
48025 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48026
48027 if (!retval)
48028 port->flags |= ASYNC_NORMAL_ACTIVE;
48029 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48030
48031 if (debug_level >= DEBUG_LEVEL_INFO)
48032 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48033 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48034 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48035
48036 /* If port is closing, signal caller to try again */
48037 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48038 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48039 spin_unlock_irqrestore(&info->netlock, flags);
48040 goto cleanup;
48041 }
48042 - info->port.count++;
48043 + atomic_inc(&info->port.count);
48044 spin_unlock_irqrestore(&info->netlock, flags);
48045
48046 - if (info->port.count == 1) {
48047 + if (atomic_read(&info->port.count) == 1) {
48048 /* 1st open on this device, init hardware */
48049 retval = startup(info);
48050 if (retval < 0)
48051 @@ -3446,8 +3446,8 @@ cleanup:
48052 if (retval) {
48053 if (tty->count == 1)
48054 info->port.tty = NULL; /* tty layer will release tty struct */
48055 - if(info->port.count)
48056 - info->port.count--;
48057 + if (atomic_read(&info->port.count))
48058 + atomic_dec(&info->port.count);
48059 }
48060
48061 return retval;
48062 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48063 unsigned short new_crctype;
48064
48065 /* return error if TTY interface open */
48066 - if (info->port.count)
48067 + if (atomic_read(&info->port.count))
48068 return -EBUSY;
48069
48070 switch (encoding)
48071 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48072
48073 /* arbitrate between network and tty opens */
48074 spin_lock_irqsave(&info->netlock, flags);
48075 - if (info->port.count != 0 || info->netcount != 0) {
48076 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48077 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48078 spin_unlock_irqrestore(&info->netlock, flags);
48079 return -EBUSY;
48080 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48081 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48082
48083 /* return error if TTY interface open */
48084 - if (info->port.count)
48085 + if (atomic_read(&info->port.count))
48086 return -EBUSY;
48087
48088 if (cmd != SIOCWANDEV)
48089 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48090 index 1abf946..1ee34fc 100644
48091 --- a/drivers/tty/synclink_gt.c
48092 +++ b/drivers/tty/synclink_gt.c
48093 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48094 tty->driver_data = info;
48095 info->port.tty = tty;
48096
48097 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48098 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48099
48100 /* If port is closing, signal caller to try again */
48101 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48102 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48103 mutex_unlock(&info->port.mutex);
48104 goto cleanup;
48105 }
48106 - info->port.count++;
48107 + atomic_inc(&info->port.count);
48108 spin_unlock_irqrestore(&info->netlock, flags);
48109
48110 - if (info->port.count == 1) {
48111 + if (atomic_read(&info->port.count) == 1) {
48112 /* 1st open on this device, init hardware */
48113 retval = startup(info);
48114 if (retval < 0) {
48115 @@ -715,8 +715,8 @@ cleanup:
48116 if (retval) {
48117 if (tty->count == 1)
48118 info->port.tty = NULL; /* tty layer will release tty struct */
48119 - if(info->port.count)
48120 - info->port.count--;
48121 + if(atomic_read(&info->port.count))
48122 + atomic_dec(&info->port.count);
48123 }
48124
48125 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48126 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48127
48128 if (sanity_check(info, tty->name, "close"))
48129 return;
48130 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48131 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48132
48133 if (tty_port_close_start(&info->port, tty, filp) == 0)
48134 goto cleanup;
48135 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48136 tty_port_close_end(&info->port, tty);
48137 info->port.tty = NULL;
48138 cleanup:
48139 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48140 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48141 }
48142
48143 static void hangup(struct tty_struct *tty)
48144 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48145 shutdown(info);
48146
48147 spin_lock_irqsave(&info->port.lock, flags);
48148 - info->port.count = 0;
48149 + atomic_set(&info->port.count, 0);
48150 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48151 info->port.tty = NULL;
48152 spin_unlock_irqrestore(&info->port.lock, flags);
48153 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48154 unsigned short new_crctype;
48155
48156 /* return error if TTY interface open */
48157 - if (info->port.count)
48158 + if (atomic_read(&info->port.count))
48159 return -EBUSY;
48160
48161 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48162 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48163
48164 /* arbitrate between network and tty opens */
48165 spin_lock_irqsave(&info->netlock, flags);
48166 - if (info->port.count != 0 || info->netcount != 0) {
48167 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48168 DBGINFO(("%s hdlc_open busy\n", dev->name));
48169 spin_unlock_irqrestore(&info->netlock, flags);
48170 return -EBUSY;
48171 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48172 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48173
48174 /* return error if TTY interface open */
48175 - if (info->port.count)
48176 + if (atomic_read(&info->port.count))
48177 return -EBUSY;
48178
48179 if (cmd != SIOCWANDEV)
48180 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48181 if (port == NULL)
48182 continue;
48183 spin_lock(&port->lock);
48184 - if ((port->port.count || port->netcount) &&
48185 + if ((atomic_read(&port->port.count) || port->netcount) &&
48186 port->pending_bh && !port->bh_running &&
48187 !port->bh_requested) {
48188 DBGISR(("%s bh queued\n", port->device_name));
48189 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48190 spin_lock_irqsave(&info->lock, flags);
48191 if (!tty_hung_up_p(filp)) {
48192 extra_count = true;
48193 - port->count--;
48194 + atomic_dec(&port->count);
48195 }
48196 spin_unlock_irqrestore(&info->lock, flags);
48197 port->blocked_open++;
48198 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48199 remove_wait_queue(&port->open_wait, &wait);
48200
48201 if (extra_count)
48202 - port->count++;
48203 + atomic_inc(&port->count);
48204 port->blocked_open--;
48205
48206 if (!retval)
48207 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48208 index dc6e969..5dc8786 100644
48209 --- a/drivers/tty/synclinkmp.c
48210 +++ b/drivers/tty/synclinkmp.c
48211 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48212
48213 if (debug_level >= DEBUG_LEVEL_INFO)
48214 printk("%s(%d):%s open(), old ref count = %d\n",
48215 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48216 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48217
48218 /* If port is closing, signal caller to try again */
48219 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48220 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48221 spin_unlock_irqrestore(&info->netlock, flags);
48222 goto cleanup;
48223 }
48224 - info->port.count++;
48225 + atomic_inc(&info->port.count);
48226 spin_unlock_irqrestore(&info->netlock, flags);
48227
48228 - if (info->port.count == 1) {
48229 + if (atomic_read(&info->port.count) == 1) {
48230 /* 1st open on this device, init hardware */
48231 retval = startup(info);
48232 if (retval < 0)
48233 @@ -796,8 +796,8 @@ cleanup:
48234 if (retval) {
48235 if (tty->count == 1)
48236 info->port.tty = NULL; /* tty layer will release tty struct */
48237 - if(info->port.count)
48238 - info->port.count--;
48239 + if(atomic_read(&info->port.count))
48240 + atomic_dec(&info->port.count);
48241 }
48242
48243 return retval;
48244 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48245
48246 if (debug_level >= DEBUG_LEVEL_INFO)
48247 printk("%s(%d):%s close() entry, count=%d\n",
48248 - __FILE__,__LINE__, info->device_name, info->port.count);
48249 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48250
48251 if (tty_port_close_start(&info->port, tty, filp) == 0)
48252 goto cleanup;
48253 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48254 cleanup:
48255 if (debug_level >= DEBUG_LEVEL_INFO)
48256 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48257 - tty->driver->name, info->port.count);
48258 + tty->driver->name, atomic_read(&info->port.count));
48259 }
48260
48261 /* Called by tty_hangup() when a hangup is signaled.
48262 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48263 shutdown(info);
48264
48265 spin_lock_irqsave(&info->port.lock, flags);
48266 - info->port.count = 0;
48267 + atomic_set(&info->port.count, 0);
48268 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48269 info->port.tty = NULL;
48270 spin_unlock_irqrestore(&info->port.lock, flags);
48271 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48272 unsigned short new_crctype;
48273
48274 /* return error if TTY interface open */
48275 - if (info->port.count)
48276 + if (atomic_read(&info->port.count))
48277 return -EBUSY;
48278
48279 switch (encoding)
48280 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48281
48282 /* arbitrate between network and tty opens */
48283 spin_lock_irqsave(&info->netlock, flags);
48284 - if (info->port.count != 0 || info->netcount != 0) {
48285 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48286 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48287 spin_unlock_irqrestore(&info->netlock, flags);
48288 return -EBUSY;
48289 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48290 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48291
48292 /* return error if TTY interface open */
48293 - if (info->port.count)
48294 + if (atomic_read(&info->port.count))
48295 return -EBUSY;
48296
48297 if (cmd != SIOCWANDEV)
48298 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48299 * do not request bottom half processing if the
48300 * device is not open in a normal mode.
48301 */
48302 - if ( port && (port->port.count || port->netcount) &&
48303 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48304 port->pending_bh && !port->bh_running &&
48305 !port->bh_requested ) {
48306 if ( debug_level >= DEBUG_LEVEL_ISR )
48307 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48308
48309 if (debug_level >= DEBUG_LEVEL_INFO)
48310 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48311 - __FILE__,__LINE__, tty->driver->name, port->count );
48312 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48313
48314 spin_lock_irqsave(&info->lock, flags);
48315 if (!tty_hung_up_p(filp)) {
48316 extra_count = true;
48317 - port->count--;
48318 + atomic_dec(&port->count);
48319 }
48320 spin_unlock_irqrestore(&info->lock, flags);
48321 port->blocked_open++;
48322 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48323
48324 if (debug_level >= DEBUG_LEVEL_INFO)
48325 printk("%s(%d):%s block_til_ready() count=%d\n",
48326 - __FILE__,__LINE__, tty->driver->name, port->count );
48327 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48328
48329 tty_unlock(tty);
48330 schedule();
48331 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48332 remove_wait_queue(&port->open_wait, &wait);
48333
48334 if (extra_count)
48335 - port->count++;
48336 + atomic_inc(&port->count);
48337 port->blocked_open--;
48338
48339 if (debug_level >= DEBUG_LEVEL_INFO)
48340 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48341 - __FILE__,__LINE__, tty->driver->name, port->count );
48342 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48343
48344 if (!retval)
48345 port->flags |= ASYNC_NORMAL_ACTIVE;
48346 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48347 index d5cc3ac..3263411 100644
48348 --- a/drivers/tty/sysrq.c
48349 +++ b/drivers/tty/sysrq.c
48350 @@ -1033,7 +1033,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48351 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48352 size_t count, loff_t *ppos)
48353 {
48354 - if (count) {
48355 + if (count && capable(CAP_SYS_ADMIN)) {
48356 char c;
48357
48358 if (get_user(c, buf))
48359 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48360 index 20689b9..7fd3a31 100644
48361 --- a/drivers/tty/tty_io.c
48362 +++ b/drivers/tty/tty_io.c
48363 @@ -3468,7 +3468,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48364
48365 void tty_default_fops(struct file_operations *fops)
48366 {
48367 - *fops = tty_fops;
48368 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48369 }
48370
48371 /*
48372 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48373 index 1afe192..73d2c20 100644
48374 --- a/drivers/tty/tty_ldisc.c
48375 +++ b/drivers/tty/tty_ldisc.c
48376 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48377 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48378 tty_ldiscs[disc] = new_ldisc;
48379 new_ldisc->num = disc;
48380 - new_ldisc->refcount = 0;
48381 + atomic_set(&new_ldisc->refcount, 0);
48382 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48383
48384 return ret;
48385 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
48386 return -EINVAL;
48387
48388 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48389 - if (tty_ldiscs[disc]->refcount)
48390 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48391 ret = -EBUSY;
48392 else
48393 tty_ldiscs[disc] = NULL;
48394 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48395 if (ldops) {
48396 ret = ERR_PTR(-EAGAIN);
48397 if (try_module_get(ldops->owner)) {
48398 - ldops->refcount++;
48399 + atomic_inc(&ldops->refcount);
48400 ret = ldops;
48401 }
48402 }
48403 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48404 unsigned long flags;
48405
48406 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48407 - ldops->refcount--;
48408 + atomic_dec(&ldops->refcount);
48409 module_put(ldops->owner);
48410 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48411 }
48412 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
48413 /* unreleased reader reference(s) will cause this WARN */
48414 WARN_ON(!atomic_dec_and_test(&ld->users));
48415
48416 - ld->ops->refcount--;
48417 + atomic_dec(&ld->ops->refcount);
48418 module_put(ld->ops->owner);
48419 kfree(ld);
48420 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48421 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48422 index f597e88..b7f68ed 100644
48423 --- a/drivers/tty/tty_port.c
48424 +++ b/drivers/tty/tty_port.c
48425 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48426 unsigned long flags;
48427
48428 spin_lock_irqsave(&port->lock, flags);
48429 - port->count = 0;
48430 + atomic_set(&port->count, 0);
48431 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48432 tty = port->tty;
48433 if (tty)
48434 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48435 /* The port lock protects the port counts */
48436 spin_lock_irqsave(&port->lock, flags);
48437 if (!tty_hung_up_p(filp))
48438 - port->count--;
48439 + atomic_dec(&port->count);
48440 port->blocked_open++;
48441 spin_unlock_irqrestore(&port->lock, flags);
48442
48443 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48444 we must not mess that up further */
48445 spin_lock_irqsave(&port->lock, flags);
48446 if (!tty_hung_up_p(filp))
48447 - port->count++;
48448 + atomic_inc(&port->count);
48449 port->blocked_open--;
48450 if (retval == 0)
48451 port->flags |= ASYNC_NORMAL_ACTIVE;
48452 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48453 return 0;
48454 }
48455
48456 - if (tty->count == 1 && port->count != 1) {
48457 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48458 printk(KERN_WARNING
48459 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48460 - port->count);
48461 - port->count = 1;
48462 + atomic_read(&port->count));
48463 + atomic_set(&port->count, 1);
48464 }
48465 - if (--port->count < 0) {
48466 + if (atomic_dec_return(&port->count) < 0) {
48467 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48468 - port->count);
48469 - port->count = 0;
48470 + atomic_read(&port->count));
48471 + atomic_set(&port->count, 0);
48472 }
48473
48474 - if (port->count) {
48475 + if (atomic_read(&port->count)) {
48476 spin_unlock_irqrestore(&port->lock, flags);
48477 if (port->ops->drop)
48478 port->ops->drop(port);
48479 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48480 {
48481 spin_lock_irq(&port->lock);
48482 if (!tty_hung_up_p(filp))
48483 - ++port->count;
48484 + atomic_inc(&port->count);
48485 spin_unlock_irq(&port->lock);
48486 tty_port_tty_set(port, tty);
48487
48488 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48489 index a9af1b9a..1e08e7f 100644
48490 --- a/drivers/tty/vt/keyboard.c
48491 +++ b/drivers/tty/vt/keyboard.c
48492 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48493 kbd->kbdmode == VC_OFF) &&
48494 value != KVAL(K_SAK))
48495 return; /* SAK is allowed even in raw mode */
48496 +
48497 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48498 + {
48499 + void *func = fn_handler[value];
48500 + if (func == fn_show_state || func == fn_show_ptregs ||
48501 + func == fn_show_mem)
48502 + return;
48503 + }
48504 +#endif
48505 +
48506 fn_handler[value](vc);
48507 }
48508
48509 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48510 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48511 return -EFAULT;
48512
48513 - if (!capable(CAP_SYS_TTY_CONFIG))
48514 - perm = 0;
48515 -
48516 switch (cmd) {
48517 case KDGKBENT:
48518 /* Ensure another thread doesn't free it under us */
48519 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48520 spin_unlock_irqrestore(&kbd_event_lock, flags);
48521 return put_user(val, &user_kbe->kb_value);
48522 case KDSKBENT:
48523 + if (!capable(CAP_SYS_TTY_CONFIG))
48524 + perm = 0;
48525 +
48526 if (!perm)
48527 return -EPERM;
48528 if (!i && v == K_NOSUCHMAP) {
48529 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48530 int i, j, k;
48531 int ret;
48532
48533 - if (!capable(CAP_SYS_TTY_CONFIG))
48534 - perm = 0;
48535 -
48536 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48537 if (!kbs) {
48538 ret = -ENOMEM;
48539 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48540 kfree(kbs);
48541 return ((p && *p) ? -EOVERFLOW : 0);
48542 case KDSKBSENT:
48543 + if (!capable(CAP_SYS_TTY_CONFIG))
48544 + perm = 0;
48545 +
48546 if (!perm) {
48547 ret = -EPERM;
48548 goto reterr;
48549 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48550 index 3b96f18..026a9bf 100644
48551 --- a/drivers/uio/uio.c
48552 +++ b/drivers/uio/uio.c
48553 @@ -25,6 +25,7 @@
48554 #include <linux/kobject.h>
48555 #include <linux/cdev.h>
48556 #include <linux/uio_driver.h>
48557 +#include <asm/local.h>
48558
48559 #define UIO_MAX_DEVICES (1U << MINORBITS)
48560
48561 @@ -32,10 +33,10 @@ struct uio_device {
48562 struct module *owner;
48563 struct device *dev;
48564 int minor;
48565 - atomic_t event;
48566 + atomic_unchecked_t event;
48567 struct fasync_struct *async_queue;
48568 wait_queue_head_t wait;
48569 - int vma_count;
48570 + local_t vma_count;
48571 struct uio_info *info;
48572 struct kobject *map_dir;
48573 struct kobject *portio_dir;
48574 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
48575 struct device_attribute *attr, char *buf)
48576 {
48577 struct uio_device *idev = dev_get_drvdata(dev);
48578 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48579 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48580 }
48581
48582 static struct device_attribute uio_class_attributes[] = {
48583 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
48584 {
48585 struct uio_device *idev = info->uio_dev;
48586
48587 - atomic_inc(&idev->event);
48588 + atomic_inc_unchecked(&idev->event);
48589 wake_up_interruptible(&idev->wait);
48590 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48591 }
48592 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48593 }
48594
48595 listener->dev = idev;
48596 - listener->event_count = atomic_read(&idev->event);
48597 + listener->event_count = atomic_read_unchecked(&idev->event);
48598 filep->private_data = listener;
48599
48600 if (idev->info->open) {
48601 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48602 return -EIO;
48603
48604 poll_wait(filep, &idev->wait, wait);
48605 - if (listener->event_count != atomic_read(&idev->event))
48606 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48607 return POLLIN | POLLRDNORM;
48608 return 0;
48609 }
48610 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48611 do {
48612 set_current_state(TASK_INTERRUPTIBLE);
48613
48614 - event_count = atomic_read(&idev->event);
48615 + event_count = atomic_read_unchecked(&idev->event);
48616 if (event_count != listener->event_count) {
48617 if (copy_to_user(buf, &event_count, count))
48618 retval = -EFAULT;
48619 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
48620 static void uio_vma_open(struct vm_area_struct *vma)
48621 {
48622 struct uio_device *idev = vma->vm_private_data;
48623 - idev->vma_count++;
48624 + local_inc(&idev->vma_count);
48625 }
48626
48627 static void uio_vma_close(struct vm_area_struct *vma)
48628 {
48629 struct uio_device *idev = vma->vm_private_data;
48630 - idev->vma_count--;
48631 + local_dec(&idev->vma_count);
48632 }
48633
48634 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
48635 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
48636 idev->owner = owner;
48637 idev->info = info;
48638 init_waitqueue_head(&idev->wait);
48639 - atomic_set(&idev->event, 0);
48640 + atomic_set_unchecked(&idev->event, 0);
48641
48642 ret = uio_get_minor(idev);
48643 if (ret)
48644 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48645 index 8a7eb77..c00402f 100644
48646 --- a/drivers/usb/atm/cxacru.c
48647 +++ b/drivers/usb/atm/cxacru.c
48648 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
48649 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
48650 if (ret < 2)
48651 return -EINVAL;
48652 - if (index < 0 || index > 0x7f)
48653 + if (index > 0x7f)
48654 return -EINVAL;
48655 pos += tmp;
48656
48657 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
48658 index 5e0d33a..cc10579 100644
48659 --- a/drivers/usb/atm/usbatm.c
48660 +++ b/drivers/usb/atm/usbatm.c
48661 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48662 if (printk_ratelimit())
48663 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
48664 __func__, vpi, vci);
48665 - atomic_inc(&vcc->stats->rx_err);
48666 + atomic_inc_unchecked(&vcc->stats->rx_err);
48667 return;
48668 }
48669
48670 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48671 if (length > ATM_MAX_AAL5_PDU) {
48672 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
48673 __func__, length, vcc);
48674 - atomic_inc(&vcc->stats->rx_err);
48675 + atomic_inc_unchecked(&vcc->stats->rx_err);
48676 goto out;
48677 }
48678
48679 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48680 if (sarb->len < pdu_length) {
48681 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
48682 __func__, pdu_length, sarb->len, vcc);
48683 - atomic_inc(&vcc->stats->rx_err);
48684 + atomic_inc_unchecked(&vcc->stats->rx_err);
48685 goto out;
48686 }
48687
48688 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
48689 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
48690 __func__, vcc);
48691 - atomic_inc(&vcc->stats->rx_err);
48692 + atomic_inc_unchecked(&vcc->stats->rx_err);
48693 goto out;
48694 }
48695
48696 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48697 if (printk_ratelimit())
48698 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
48699 __func__, length);
48700 - atomic_inc(&vcc->stats->rx_drop);
48701 + atomic_inc_unchecked(&vcc->stats->rx_drop);
48702 goto out;
48703 }
48704
48705 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48706
48707 vcc->push(vcc, skb);
48708
48709 - atomic_inc(&vcc->stats->rx);
48710 + atomic_inc_unchecked(&vcc->stats->rx);
48711 out:
48712 skb_trim(sarb, 0);
48713 }
48714 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
48715 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
48716
48717 usbatm_pop(vcc, skb);
48718 - atomic_inc(&vcc->stats->tx);
48719 + atomic_inc_unchecked(&vcc->stats->tx);
48720
48721 skb = skb_dequeue(&instance->sndqueue);
48722 }
48723 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
48724 if (!left--)
48725 return sprintf(page,
48726 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
48727 - atomic_read(&atm_dev->stats.aal5.tx),
48728 - atomic_read(&atm_dev->stats.aal5.tx_err),
48729 - atomic_read(&atm_dev->stats.aal5.rx),
48730 - atomic_read(&atm_dev->stats.aal5.rx_err),
48731 - atomic_read(&atm_dev->stats.aal5.rx_drop));
48732 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
48733 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
48734 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
48735 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
48736 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
48737
48738 if (!left--) {
48739 if (instance->disconnected)
48740 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
48741 index 2a3bbdf..91d72cf 100644
48742 --- a/drivers/usb/core/devices.c
48743 +++ b/drivers/usb/core/devices.c
48744 @@ -126,7 +126,7 @@ static const char format_endpt[] =
48745 * time it gets called.
48746 */
48747 static struct device_connect_event {
48748 - atomic_t count;
48749 + atomic_unchecked_t count;
48750 wait_queue_head_t wait;
48751 } device_event = {
48752 .count = ATOMIC_INIT(1),
48753 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
48754
48755 void usbfs_conn_disc_event(void)
48756 {
48757 - atomic_add(2, &device_event.count);
48758 + atomic_add_unchecked(2, &device_event.count);
48759 wake_up(&device_event.wait);
48760 }
48761
48762 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
48763
48764 poll_wait(file, &device_event.wait, wait);
48765
48766 - event_count = atomic_read(&device_event.count);
48767 + event_count = atomic_read_unchecked(&device_event.count);
48768 if (file->f_version != event_count) {
48769 file->f_version = event_count;
48770 return POLLIN | POLLRDNORM;
48771 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
48772 index 014dc99..4d25fd7 100644
48773 --- a/drivers/usb/core/hcd.c
48774 +++ b/drivers/usb/core/hcd.c
48775 @@ -1551,7 +1551,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48776 */
48777 usb_get_urb(urb);
48778 atomic_inc(&urb->use_count);
48779 - atomic_inc(&urb->dev->urbnum);
48780 + atomic_inc_unchecked(&urb->dev->urbnum);
48781 usbmon_urb_submit(&hcd->self, urb);
48782
48783 /* NOTE requirements on root-hub callers (usbfs and the hub
48784 @@ -1578,7 +1578,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48785 urb->hcpriv = NULL;
48786 INIT_LIST_HEAD(&urb->urb_list);
48787 atomic_dec(&urb->use_count);
48788 - atomic_dec(&urb->dev->urbnum);
48789 + atomic_dec_unchecked(&urb->dev->urbnum);
48790 if (atomic_read(&urb->reject))
48791 wake_up(&usb_kill_urb_queue);
48792 usb_put_urb(urb);
48793 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
48794 index 17c3785..deffb11 100644
48795 --- a/drivers/usb/core/hub.c
48796 +++ b/drivers/usb/core/hub.c
48797 @@ -27,6 +27,7 @@
48798 #include <linux/freezer.h>
48799 #include <linux/random.h>
48800 #include <linux/pm_qos.h>
48801 +#include <linux/grsecurity.h>
48802
48803 #include <asm/uaccess.h>
48804 #include <asm/byteorder.h>
48805 @@ -4421,6 +4422,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
48806 goto done;
48807 return;
48808 }
48809 +
48810 + if (gr_handle_new_usb())
48811 + goto done;
48812 +
48813 if (hub_is_superspeed(hub->hdev))
48814 unit_load = 150;
48815 else
48816 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
48817 index e7ee1e4..1dfc9ea4 100644
48818 --- a/drivers/usb/core/message.c
48819 +++ b/drivers/usb/core/message.c
48820 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
48821 * method can wait for it to complete. Since you don't have a handle on the
48822 * URB used, you can't cancel the request.
48823 */
48824 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
48825 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
48826 __u8 requesttype, __u16 value, __u16 index, void *data,
48827 __u16 size, int timeout)
48828 {
48829 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
48830 index d9284b9..17023c7 100644
48831 --- a/drivers/usb/core/sysfs.c
48832 +++ b/drivers/usb/core/sysfs.c
48833 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
48834 struct usb_device *udev;
48835
48836 udev = to_usb_device(dev);
48837 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
48838 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
48839 }
48840 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
48841
48842 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
48843 index 7dad603..350f7a9 100644
48844 --- a/drivers/usb/core/usb.c
48845 +++ b/drivers/usb/core/usb.c
48846 @@ -422,7 +422,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
48847 set_dev_node(&dev->dev, dev_to_node(bus->controller));
48848 dev->state = USB_STATE_ATTACHED;
48849 dev->lpm_disable_count = 1;
48850 - atomic_set(&dev->urbnum, 0);
48851 + atomic_set_unchecked(&dev->urbnum, 0);
48852
48853 INIT_LIST_HEAD(&dev->ep0.urb_list);
48854 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
48855 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
48856 index 14d28d6..5f511ac 100644
48857 --- a/drivers/usb/dwc3/gadget.c
48858 +++ b/drivers/usb/dwc3/gadget.c
48859 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
48860 if (!usb_endpoint_xfer_isoc(desc))
48861 return 0;
48862
48863 - memset(&trb_link, 0, sizeof(trb_link));
48864 -
48865 /* Link TRB for ISOC. The HWO bit is never reset */
48866 trb_st_hw = &dep->trb_pool[0];
48867
48868 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
48869 index 5e29dde..eca992f 100644
48870 --- a/drivers/usb/early/ehci-dbgp.c
48871 +++ b/drivers/usb/early/ehci-dbgp.c
48872 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
48873
48874 #ifdef CONFIG_KGDB
48875 static struct kgdb_io kgdbdbgp_io_ops;
48876 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
48877 +static struct kgdb_io kgdbdbgp_io_ops_console;
48878 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
48879 #else
48880 #define dbgp_kgdb_mode (0)
48881 #endif
48882 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
48883 .write_char = kgdbdbgp_write_char,
48884 };
48885
48886 +static struct kgdb_io kgdbdbgp_io_ops_console = {
48887 + .name = "kgdbdbgp",
48888 + .read_char = kgdbdbgp_read_char,
48889 + .write_char = kgdbdbgp_write_char,
48890 + .is_console = 1
48891 +};
48892 +
48893 static int kgdbdbgp_wait_time;
48894
48895 static int __init kgdbdbgp_parse_config(char *str)
48896 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
48897 ptr++;
48898 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
48899 }
48900 - kgdb_register_io_module(&kgdbdbgp_io_ops);
48901 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
48902 + if (early_dbgp_console.index != -1)
48903 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
48904 + else
48905 + kgdb_register_io_module(&kgdbdbgp_io_ops);
48906
48907 return 0;
48908 }
48909 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
48910 index b369292..9f3ba40 100644
48911 --- a/drivers/usb/gadget/u_serial.c
48912 +++ b/drivers/usb/gadget/u_serial.c
48913 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
48914 spin_lock_irq(&port->port_lock);
48915
48916 /* already open? Great. */
48917 - if (port->port.count) {
48918 + if (atomic_read(&port->port.count)) {
48919 status = 0;
48920 - port->port.count++;
48921 + atomic_inc(&port->port.count);
48922
48923 /* currently opening/closing? wait ... */
48924 } else if (port->openclose) {
48925 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
48926 tty->driver_data = port;
48927 port->port.tty = tty;
48928
48929 - port->port.count = 1;
48930 + atomic_set(&port->port.count, 1);
48931 port->openclose = false;
48932
48933 /* if connected, start the I/O stream */
48934 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
48935
48936 spin_lock_irq(&port->port_lock);
48937
48938 - if (port->port.count != 1) {
48939 - if (port->port.count == 0)
48940 + if (atomic_read(&port->port.count) != 1) {
48941 + if (atomic_read(&port->port.count) == 0)
48942 WARN_ON(1);
48943 else
48944 - --port->port.count;
48945 + atomic_dec(&port->port.count);
48946 goto exit;
48947 }
48948
48949 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
48950 * and sleep if necessary
48951 */
48952 port->openclose = true;
48953 - port->port.count = 0;
48954 + atomic_set(&port->port.count, 0);
48955
48956 gser = port->port_usb;
48957 if (gser && gser->disconnect)
48958 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
48959 int cond;
48960
48961 spin_lock_irq(&port->port_lock);
48962 - cond = (port->port.count == 0) && !port->openclose;
48963 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
48964 spin_unlock_irq(&port->port_lock);
48965 return cond;
48966 }
48967 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
48968 /* if it's already open, start I/O ... and notify the serial
48969 * protocol about open/close status (connect/disconnect).
48970 */
48971 - if (port->port.count) {
48972 + if (atomic_read(&port->port.count)) {
48973 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
48974 gs_start_io(port);
48975 if (gser->connect)
48976 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
48977
48978 port->port_usb = NULL;
48979 gser->ioport = NULL;
48980 - if (port->port.count > 0 || port->openclose) {
48981 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
48982 wake_up_interruptible(&port->drain_wait);
48983 if (port->port.tty)
48984 tty_hangup(port->port.tty);
48985 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
48986
48987 /* finally, free any unused/unusable I/O buffers */
48988 spin_lock_irqsave(&port->port_lock, flags);
48989 - if (port->port.count == 0 && !port->openclose)
48990 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
48991 gs_buf_free(&port->port_write_buf);
48992 gs_free_requests(gser->out, &port->read_pool, NULL);
48993 gs_free_requests(gser->out, &port->read_queue, NULL);
48994 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
48995 index ba6a5d6..f88f7f3 100644
48996 --- a/drivers/usb/misc/appledisplay.c
48997 +++ b/drivers/usb/misc/appledisplay.c
48998 @@ -83,7 +83,7 @@ struct appledisplay {
48999 spinlock_t lock;
49000 };
49001
49002 -static atomic_t count_displays = ATOMIC_INIT(0);
49003 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49004 static struct workqueue_struct *wq;
49005
49006 static void appledisplay_complete(struct urb *urb)
49007 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49008
49009 /* Register backlight device */
49010 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49011 - atomic_inc_return(&count_displays) - 1);
49012 + atomic_inc_return_unchecked(&count_displays) - 1);
49013 memset(&props, 0, sizeof(struct backlight_properties));
49014 props.type = BACKLIGHT_RAW;
49015 props.max_brightness = 0xff;
49016 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49017 index afb50ea..7b0b1cf 100644
49018 --- a/drivers/usb/serial/console.c
49019 +++ b/drivers/usb/serial/console.c
49020 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49021
49022 info->port = port;
49023
49024 - ++port->port.count;
49025 + atomic_inc(&port->port.count);
49026 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49027 if (serial->type->set_termios) {
49028 /*
49029 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
49030 }
49031 /* Now that any required fake tty operations are completed restore
49032 * the tty port count */
49033 - --port->port.count;
49034 + atomic_dec(&port->port.count);
49035 /* The console is special in terms of closing the device so
49036 * indicate this port is now acting as a system console. */
49037 port->port.console = 1;
49038 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
49039 free_tty:
49040 kfree(tty);
49041 reset_open_count:
49042 - port->port.count = 0;
49043 + atomic_set(&port->port.count, 0);
49044 usb_autopm_put_interface(serial->interface);
49045 error_get_interface:
49046 usb_serial_put(serial);
49047 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49048 index 75f70f0..d467e1a 100644
49049 --- a/drivers/usb/storage/usb.h
49050 +++ b/drivers/usb/storage/usb.h
49051 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49052 __u8 useProtocol;
49053 __u8 useTransport;
49054 int (*initFunction)(struct us_data *);
49055 -};
49056 +} __do_const;
49057
49058
49059 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49060 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49061 index d6bea3e..60b250e 100644
49062 --- a/drivers/usb/wusbcore/wa-hc.h
49063 +++ b/drivers/usb/wusbcore/wa-hc.h
49064 @@ -192,7 +192,7 @@ struct wahc {
49065 struct list_head xfer_delayed_list;
49066 spinlock_t xfer_list_lock;
49067 struct work_struct xfer_work;
49068 - atomic_t xfer_id_count;
49069 + atomic_unchecked_t xfer_id_count;
49070 };
49071
49072
49073 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
49074 INIT_LIST_HEAD(&wa->xfer_delayed_list);
49075 spin_lock_init(&wa->xfer_list_lock);
49076 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
49077 - atomic_set(&wa->xfer_id_count, 1);
49078 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49079 }
49080
49081 /**
49082 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49083 index d3493ca..0c33b7e 100644
49084 --- a/drivers/usb/wusbcore/wa-xfer.c
49085 +++ b/drivers/usb/wusbcore/wa-xfer.c
49086 @@ -297,7 +297,7 @@ out:
49087 */
49088 static void wa_xfer_id_init(struct wa_xfer *xfer)
49089 {
49090 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49091 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49092 }
49093
49094 /*
49095 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49096 index 842f450..d1d7409 100644
49097 --- a/drivers/vfio/vfio.c
49098 +++ b/drivers/vfio/vfio.c
49099 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49100 return 0;
49101
49102 /* TODO Prevent device auto probing */
49103 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49104 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49105 iommu_group_id(group->iommu_group));
49106
49107 return 0;
49108 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49109 index 5174eba..86e764a 100644
49110 --- a/drivers/vhost/vringh.c
49111 +++ b/drivers/vhost/vringh.c
49112 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49113
49114 static inline int putu16_kern(u16 *p, u16 val)
49115 {
49116 - ACCESS_ONCE(*p) = val;
49117 + ACCESS_ONCE_RW(*p) = val;
49118 return 0;
49119 }
49120
49121 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49122 index a4dfe8c..297ddd9 100644
49123 --- a/drivers/video/aty/aty128fb.c
49124 +++ b/drivers/video/aty/aty128fb.c
49125 @@ -149,7 +149,7 @@ enum {
49126 };
49127
49128 /* Must match above enum */
49129 -static char * const r128_family[] = {
49130 +static const char * const r128_family[] = {
49131 "AGP",
49132 "PCI",
49133 "PRO AGP",
49134 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49135 index 9b0f12c..024673d 100644
49136 --- a/drivers/video/aty/atyfb_base.c
49137 +++ b/drivers/video/aty/atyfb_base.c
49138 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49139 par->accel_flags = var->accel_flags; /* hack */
49140
49141 if (var->accel_flags) {
49142 - info->fbops->fb_sync = atyfb_sync;
49143 + pax_open_kernel();
49144 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49145 + pax_close_kernel();
49146 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49147 } else {
49148 - info->fbops->fb_sync = NULL;
49149 + pax_open_kernel();
49150 + *(void **)&info->fbops->fb_sync = NULL;
49151 + pax_close_kernel();
49152 info->flags |= FBINFO_HWACCEL_DISABLED;
49153 }
49154
49155 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49156 index 95ec042..e6affdd 100644
49157 --- a/drivers/video/aty/mach64_cursor.c
49158 +++ b/drivers/video/aty/mach64_cursor.c
49159 @@ -7,6 +7,7 @@
49160 #include <linux/string.h>
49161
49162 #include <asm/io.h>
49163 +#include <asm/pgtable.h>
49164
49165 #ifdef __sparc__
49166 #include <asm/fbio.h>
49167 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49168 info->sprite.buf_align = 16; /* and 64 lines tall. */
49169 info->sprite.flags = FB_PIXMAP_IO;
49170
49171 - info->fbops->fb_cursor = atyfb_cursor;
49172 + pax_open_kernel();
49173 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49174 + pax_close_kernel();
49175
49176 return 0;
49177 }
49178 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49179 index bca6ccc..252107e 100644
49180 --- a/drivers/video/backlight/kb3886_bl.c
49181 +++ b/drivers/video/backlight/kb3886_bl.c
49182 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49183 static unsigned long kb3886bl_flags;
49184 #define KB3886BL_SUSPENDED 0x01
49185
49186 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49187 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49188 {
49189 .ident = "Sahara Touch-iT",
49190 .matches = {
49191 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49192 index 900aa4e..6d49418 100644
49193 --- a/drivers/video/fb_defio.c
49194 +++ b/drivers/video/fb_defio.c
49195 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49196
49197 BUG_ON(!fbdefio);
49198 mutex_init(&fbdefio->lock);
49199 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49200 + pax_open_kernel();
49201 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49202 + pax_close_kernel();
49203 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49204 INIT_LIST_HEAD(&fbdefio->pagelist);
49205 if (fbdefio->delay == 0) /* set a default of 1 s */
49206 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49207 page->mapping = NULL;
49208 }
49209
49210 - info->fbops->fb_mmap = NULL;
49211 + *(void **)&info->fbops->fb_mmap = NULL;
49212 mutex_destroy(&fbdefio->lock);
49213 }
49214 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49215 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
49216 index 5c3960d..15cf8fc 100644
49217 --- a/drivers/video/fbcmap.c
49218 +++ b/drivers/video/fbcmap.c
49219 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
49220 rc = -ENODEV;
49221 goto out;
49222 }
49223 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
49224 - !info->fbops->fb_setcmap)) {
49225 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
49226 rc = -EINVAL;
49227 goto out1;
49228 }
49229 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49230 index 36e1fe2..c744820 100644
49231 --- a/drivers/video/fbmem.c
49232 +++ b/drivers/video/fbmem.c
49233 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49234 image->dx += image->width + 8;
49235 }
49236 } else if (rotate == FB_ROTATE_UD) {
49237 - for (x = 0; x < num && image->dx >= 0; x++) {
49238 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49239 info->fbops->fb_imageblit(info, image);
49240 image->dx -= image->width + 8;
49241 }
49242 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49243 image->dy += image->height + 8;
49244 }
49245 } else if (rotate == FB_ROTATE_CCW) {
49246 - for (x = 0; x < num && image->dy >= 0; x++) {
49247 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49248 info->fbops->fb_imageblit(info, image);
49249 image->dy -= image->height + 8;
49250 }
49251 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49252 return -EFAULT;
49253 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49254 return -EINVAL;
49255 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49256 + if (con2fb.framebuffer >= FB_MAX)
49257 return -EINVAL;
49258 if (!registered_fb[con2fb.framebuffer])
49259 request_module("fb%d", con2fb.framebuffer);
49260 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49261 index d4d2c5f..ebbd113 100644
49262 --- a/drivers/video/hyperv_fb.c
49263 +++ b/drivers/video/hyperv_fb.c
49264 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49265 static inline int synthvid_send(struct hv_device *hdev,
49266 struct synthvid_msg *msg)
49267 {
49268 - static atomic64_t request_id = ATOMIC64_INIT(0);
49269 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49270 int ret;
49271
49272 msg->pipe_hdr.type = PIPE_MSG_DATA;
49273 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49274
49275 ret = vmbus_sendpacket(hdev->channel, msg,
49276 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49277 - atomic64_inc_return(&request_id),
49278 + atomic64_inc_return_unchecked(&request_id),
49279 VM_PKT_DATA_INBAND, 0);
49280
49281 if (ret)
49282 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49283 index 7672d2e..b56437f 100644
49284 --- a/drivers/video/i810/i810_accel.c
49285 +++ b/drivers/video/i810/i810_accel.c
49286 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49287 }
49288 }
49289 printk("ringbuffer lockup!!!\n");
49290 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49291 i810_report_error(mmio);
49292 par->dev_flags |= LOCKUP;
49293 info->pixmap.scan_align = 1;
49294 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49295 index 285d552..eafa544 100644
49296 --- a/drivers/video/logo/logo_linux_clut224.ppm
49297 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49298 @@ -1,883 +1,1123 @@
49299 P3
49300 80 80
49301 255
49302 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49303 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 33 49 54 59 85 92 73 97 106
49304 -83 116 129 105 131 142 115 114 122 74 88 93 20 29 31 0 0 0 0 0 0 0 0 0
49305 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49306 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10 10 10 10
49307 -10 10 10 6 6 6 6 6 6 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49308 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49309 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49310 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49311 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49312 -
49313 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49314 -0 0 0 0 0 0 2 3 3 17 23 26 50 67 72 73 97 106 59 85 92 73 97 106
49315 -105 131 142 124 127 131 105 131 142 105 131 142 53 75 83 6 8 8 0 0 0 0 0 0
49316 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49317 -0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 26 26 26 30 30 30 34 34 34
49318 -30 30 30 30 30 30 26 26 26 18 18 18 14 14 14 10 10 10 6 6 6 0 0 0
49319 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49320 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49321 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49322 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49323 -
49324 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0
49325 -0 0 0 1 1 1 26 35 39 59 85 92 59 85 92 59 85 92 29 43 47 53 75 83
49326 -108 122 132 132 98 104 108 122 132 105 131 142 101 101 101 43 45 48 6 8 8 0 0 0
49327 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49328 -6 6 6 14 14 14 26 26 26 42 42 42 54 54 54 66 66 66 78 78 78 78 78 78
49329 -78 78 78 74 74 74 66 66 66 54 54 54 42 42 42 26 26 26 18 18 18 10 10 10
49330 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49331 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49332 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49333 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49334 -
49335 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0
49336 -11 15 17 27 40 45 59 85 92 59 85 92 27 40 45 31 45 49 73 97 106 93 121 133
49337 -108 122 132 108 122 132 105 131 142 108 122 132 105 131 142 73 97 106 26 35 39 0 0 0
49338 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49339 -22 22 22 42 42 42 66 66 66 86 86 86 66 66 66 38 38 38 38 38 38 22 22 22
49340 -26 26 26 34 34 34 54 54 54 66 66 66 86 86 86 70 70 70 46 46 46 26 26 26
49341 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49342 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49343 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49344 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49345 -
49346 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 7 12 13 21 31 35 42 59 64
49347 -53 75 83 53 75 83 50 67 72 42 59 64 32 40 45 42 59 64 73 97 106 116 116 116
49348 -132 98 104 116 116 116 108 122 132 117 104 110 105 131 142 83 116 129 50 67 72 7 12 13
49349 -1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49350 -50 50 50 82 82 82 58 58 58 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49351 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 54 54 54 86 86 86 66 66 66
49352 -38 38 38 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49353 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49354 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49355 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49356 -
49357 -0 0 0 1 1 1 6 8 8 15 22 25 26 35 39 36 54 60 53 75 83 59 85 92
49358 -59 85 92 48 63 69 15 22 25 12 17 20 52 67 79 94 94 94 132 98 104 132 98 104
49359 -117 104 110 108 122 132 108 122 132 115 114 122 105 131 142 77 105 114 59 85 92 36 54 60
49360 -7 12 13 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49361 -78 78 78 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49362 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 70 70 70
49363 -78 78 78 46 46 46 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49364 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49365 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49366 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49367 -
49368 -0 0 0 15 22 25 29 43 47 36 54 60 42 59 64 42 59 64 48 63 69 21 31 35
49369 -6 8 8 29 43 47 36 50 56 43 45 48 79 78 84 132 98 104 165 78 79 132 98 104
49370 -108 122 132 117 104 110 117 104 110 108 122 132 77 105 114 73 97 106 95 131 149 78 102 129
49371 -36 50 56 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 42 42 42 82 82 82
49372 -26 26 26 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49373 -2 2 6 2 2 6 2 2 6 14 14 14 46 46 46 34 34 34 6 6 6 2 2 6
49374 -42 42 42 78 78 78 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49375 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49376 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49377 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49378 -
49379 -27 40 45 53 75 83 48 63 69 24 31 37 6 8 12 0 0 0 18 25 28 26 35 39
49380 -12 17 20 26 35 39 65 78 84 112 81 86 152 81 83 137 83 86 132 98 104 117 104 110
49381 -117 104 110 132 98 104 132 98 104 115 114 122 73 97 106 53 75 83 95 131 149 93 124 152
49382 -68 78 128 15 22 25 0 0 0 0 0 0 10 10 10 30 30 30 66 66 66 58 58 58
49383 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49384 -2 2 6 2 2 6 2 2 6 26 26 26 86 86 86 101 101 101 46 46 46 10 10 10
49385 -2 2 6 58 58 58 70 70 70 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
49386 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49387 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49388 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49389 -
49390 -36 50 56 21 30 33 4 7 7 0 0 0 1 1 1 17 12 12 69 31 31 68 59 64
49391 -57 59 63 21 31 35 32 40 45 86 73 69 152 81 83 152 81 83 117 104 110 132 98 104
49392 -152 81 83 132 98 104 108 122 132 77 105 114 77 105 114 93 121 133 95 131 149 93 124 152
49393 -95 131 149 53 75 83 11 15 17 0 0 0 14 14 14 42 42 42 86 86 86 10 10 10
49394 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49395 -2 2 6 2 2 6 2 2 6 30 30 30 94 94 94 94 94 94 58 58 58 26 26 26
49396 -2 2 6 6 6 6 78 78 78 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0
49397 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49398 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49399 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49400 -
49401 -17 23 26 2 3 3 0 0 0 17 12 12 69 31 31 123 55 55 123 55 55 152 81 83
49402 -86 73 69 17 23 26 7 12 13 45 54 57 101 101 101 137 83 86 132 98 104 132 98 104
49403 -137 83 86 117 104 110 77 105 114 42 59 64 50 67 72 78 102 129 91 117 157 91 117 157
49404 -95 131 149 83 116 129 40 48 73 6 6 6 22 22 22 62 62 62 62 62 62 2 2 6
49405 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49406 -2 2 6 2 2 6 2 2 6 26 26 26 54 54 54 38 38 38 18 18 18 10 10 10
49407 -2 2 6 2 2 6 34 34 34 82 82 82 38 38 38 14 14 14 0 0 0 0 0 0
49408 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49409 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49410 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49411 -
49412 -1 1 1 1 2 2 2 3 3 28 12 12 123 55 55 174 79 79 174 79 79 174 79 79
49413 -152 81 83 68 59 64 26 35 39 27 40 45 79 78 84 137 83 86 165 78 79 137 83 86
49414 -94 94 94 48 63 69 36 50 56 50 67 72 73 97 106 93 121 133 93 124 152 93 124 152
49415 -95 131 149 91 118 149 78 102 129 27 40 45 30 30 30 78 78 78 30 30 30 2 2 6
49416 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49417 -2 2 6 2 2 6 2 2 6 10 10 10 10 10 10 2 2 6 2 2 6 2 2 6
49418 -2 2 6 2 2 6 2 2 6 78 78 78 50 50 50 18 18 18 6 6 6 0 0 0
49419 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49420 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49421 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49422 -
49423 -4 5 3 24 53 24 19 31 15 8 7 3 90 61 47 165 78 79 174 79 79 174 79 79
49424 -174 79 79 137 83 86 60 52 57 7 12 13 17 23 26 70 70 70 132 98 104 112 81 86
49425 -79 78 84 31 45 49 15 22 25 53 75 83 91 118 149 86 106 160 91 117 157 93 124 152
49426 -91 117 157 93 124 152 95 131 149 53 75 83 50 50 50 86 86 86 14 14 14 2 2 6
49427 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49428 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49429 -2 2 6 2 2 6 2 2 6 54 54 54 66 66 66 26 26 26 6 6 6 0 0 0
49430 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49431 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49432 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49433 -
49434 -19 31 15 34 76 34 34 76 34 19 31 15 28 12 12 123 55 55 174 79 79 174 79 79
49435 -174 79 79 165 78 79 112 81 86 32 40 45 15 22 25 38 53 58 65 78 84 29 31 32
49436 -21 30 33 42 59 64 60 80 103 78 102 129 87 112 149 84 96 162 91 117 157 93 124 152
49437 -91 117 157 93 124 152 93 121 133 59 85 92 57 68 71 82 85 86 2 2 6 2 2 6
49438 -2 2 6 6 6 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49439 -2 2 6 2 2 6 2 2 6 6 6 6 14 14 14 10 10 10 2 2 6 2 2 6
49440 -2 2 6 2 2 6 2 2 6 18 18 18 82 82 82 34 34 34 10 10 10 0 0 0
49441 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49442 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49443 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49444 -
49445 -34 76 34 40 89 40 40 89 40 34 76 34 8 15 6 48 26 18 123 55 55 174 79 79
49446 -174 79 79 174 79 79 137 83 86 68 59 64 32 40 45 21 30 33 31 45 49 21 31 35
49447 -12 17 20 48 63 69 78 102 129 81 88 166 84 96 162 91 117 157 93 124 152 91 117 157
49448 -93 124 152 95 131 149 83 116 129 59 85 92 57 68 71 86 86 86 2 2 6 2 2 6
49449 -6 6 6 6 6 6 22 22 22 34 34 34 6 6 6 2 2 6 2 2 6 2 2 6
49450 -2 2 6 2 2 6 18 18 18 34 34 34 10 10 10 50 50 50 22 22 22 2 2 6
49451 -2 2 6 2 2 6 2 2 6 10 10 10 86 86 86 42 42 42 14 14 14 0 0 0
49452 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49453 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49454 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49455 -
49456 -40 89 40 40 89 40 40 89 40 40 89 40 24 53 24 6 6 6 69 31 31 123 55 55
49457 -123 55 55 90 61 47 69 31 31 36 32 33 21 31 35 7 12 13 18 25 28 48 63 69
49458 -60 80 103 68 78 128 84 101 153 84 96 162 84 96 162 91 117 157 91 117 157 84 96 162
49459 -91 117 157 73 97 106 48 63 69 50 67 72 57 59 63 86 86 86 2 2 6 2 2 6
49460 -38 38 38 116 116 116 94 94 94 22 22 22 22 22 22 2 2 6 2 2 6 2 2 6
49461 -14 14 14 86 86 86 124 131 137 170 170 170 151 151 151 38 38 38 26 26 26 6 6 6
49462 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 46 46 46 14 14 14 0 0 0
49463 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49464 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49465 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49466 -
49467 -34 76 34 40 89 40 40 89 40 40 89 40 34 76 34 19 31 15 17 12 12 48 26 18
49468 -48 26 18 8 7 3 10 10 22 23 29 47 51 61 92 42 59 64 21 30 33 34 45 54
49469 -68 78 128 81 88 166 81 82 173 86 106 160 86 106 160 84 96 162 86 106 160 87 112 149
49470 -91 118 149 77 105 114 52 67 79 32 40 45 50 50 50 86 86 86 2 2 6 14 14 14
49471 -124 131 137 198 198 198 195 195 195 116 116 116 10 10 10 2 2 6 2 2 6 6 6 6
49472 -101 98 89 187 187 187 210 210 210 218 218 218 214 214 214 124 131 137 14 14 14 6 6 6
49473 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 50 50 50 18 18 18 6 6 6
49474 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49475 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49476 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49477 -
49478 -19 31 15 34 76 34 40 89 40 40 89 40 40 89 40 24 53 24 8 7 3 0 0 0
49479 -6 8 12 28 32 52 51 61 92 54 54 122 74 77 160 68 78 128 26 35 39 6 8 8
49480 -34 45 54 68 78 128 84 96 162 86 106 160 86 106 160 81 88 166 84 96 162 87 112 149
49481 -73 97 106 36 50 56 33 49 54 18 18 18 46 46 46 86 86 86 2 2 6 54 54 54
49482 -218 218 218 195 195 195 226 226 226 246 246 246 58 58 58 2 2 6 2 2 6 30 30 30
49483 -210 210 210 253 253 253 170 170 170 124 127 131 221 221 221 234 234 234 74 74 74 2 2 6
49484 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49485 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49486 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49487 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49488 -
49489 -4 5 3 24 53 24 40 89 40 40 89 40 34 76 34 12 22 15 4 5 3 4 5 3
49490 -13 17 26 54 54 122 78 78 174 78 78 174 78 78 174 74 77 160 51 61 92 21 31 35
49491 -26 35 39 53 75 83 84 101 153 81 82 173 81 88 166 84 101 153 60 80 103 60 80 103
49492 -53 75 83 38 53 58 42 59 64 22 22 22 46 46 46 82 82 82 2 2 6 106 106 106
49493 -170 170 170 26 26 26 86 86 86 226 226 226 124 127 131 10 10 10 14 14 14 46 46 46
49494 -231 231 231 190 190 190 6 6 6 70 70 70 90 90 90 238 238 238 151 151 151 2 2 6
49495 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49496 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49497 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49498 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49499 -
49500 -1 2 2 8 15 6 24 53 24 34 76 34 19 31 15 8 15 6 63 55 20 63 55 20
49501 -18 18 18 40 48 73 74 77 160 78 78 174 78 78 174 81 82 173 74 77 160 52 67 79
49502 -17 23 26 21 31 35 60 80 103 81 88 166 74 77 160 78 102 129 36 54 60 12 17 20
49503 -42 59 64 48 63 69 21 31 35 18 18 18 42 42 42 86 86 86 6 6 6 116 116 116
49504 -106 106 106 6 6 6 70 70 70 151 151 151 124 127 131 18 18 18 38 38 38 54 54 54
49505 -221 221 221 106 106 106 2 2 6 14 14 14 46 46 46 190 190 190 198 198 198 2 2 6
49506 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49507 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49508 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49509 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49510 -
49511 -11 15 17 0 0 0 12 22 15 19 31 15 8 15 6 63 55 20 149 139 69 149 139 69
49512 -63 55 20 10 10 22 54 54 122 78 78 174 78 78 174 78 78 174 81 82 173 68 78 128
49513 -24 31 37 6 6 6 36 50 56 60 80 103 51 61 92 42 59 64 36 50 56 31 45 49
49514 -29 43 47 27 40 45 6 8 8 14 14 14 42 42 42 94 94 94 14 14 14 101 101 101
49515 -124 127 131 2 2 6 18 18 18 116 116 116 106 107 48 121 92 8 121 92 8 98 70 6
49516 -170 170 170 106 106 106 2 2 6 2 2 6 2 2 6 195 195 195 195 195 195 6 6 6
49517 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49518 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49519 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49520 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49521 -
49522 -26 35 39 3 5 6 1 1 1 2 3 3 35 31 12 133 118 54 175 176 80 175 176 80
49523 -133 118 54 35 31 12 23 29 47 54 54 122 78 78 174 78 78 174 74 77 160 68 78 128
49524 -51 61 92 31 45 49 26 35 39 36 50 56 29 43 47 7 12 13 21 30 33 42 59 64
49525 -18 25 28 7 12 13 1 1 1 10 10 10 38 38 38 90 90 90 14 14 14 58 58 58
49526 -210 210 210 26 26 26 62 42 6 154 114 10 226 170 11 237 188 10 220 174 15 184 138 11
49527 -220 174 15 174 140 55 35 31 12 2 2 6 70 70 70 246 246 246 124 131 137 2 2 6
49528 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 66 66 66 26 26 26 6 6 6
49529 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49530 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49531 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49532 -
49533 -27 40 45 17 23 26 2 3 3 1 1 1 56 77 35 165 152 80 175 176 80 175 176 80
49534 -175 176 80 106 107 48 22 22 22 28 32 52 54 54 122 54 54 122 51 61 92 28 32 52
49535 -20 27 34 31 45 49 11 15 17 7 12 13 36 50 56 31 45 49 29 43 47 36 50 56
49536 -6 8 8 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 14 14 14 10 10 10
49537 -195 195 195 198 179 130 192 133 9 220 174 15 239 182 13 237 188 10 232 195 16 239 207 25
49538 -237 201 50 241 208 19 232 195 16 184 138 11 198 179 130 208 206 196 42 42 42 2 2 6
49539 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 74 74 74 30 30 30 6 6 6
49540 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49541 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49542 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49543 -
49544 -15 22 25 26 35 39 15 22 25 0 0 0 35 31 12 133 118 54 175 176 80 175 176 80
49545 -175 176 80 165 152 80 56 77 35 6 8 12 23 29 47 13 17 26 2 2 6 0 0 0
49546 -1 2 2 26 35 39 26 35 39 26 35 39 42 59 64 42 59 64 20 29 31 6 8 8
49547 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 86 86 86 14 14 14 2 2 6
49548 -121 92 8 192 133 9 219 162 10 239 182 13 237 188 10 232 195 16 241 208 19 237 201 50
49549 -237 201 50 239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 121 92 8 2 2 6
49550 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 82 82 82 34 34 34 10 10 10
49551 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49552 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49553 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49554 -
49555 -1 2 2 15 22 25 31 45 49 6 8 12 4 5 3 63 55 20 149 139 69 175 176 80
49556 -175 176 80 175 176 80 106 107 48 20 16 6 1 1 1 0 0 0 2 3 3 11 15 17
49557 -21 30 33 36 50 56 36 50 56 24 31 37 15 22 25 6 8 8 0 0 0 0 0 0
49558 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 82 82 82 30 30 30 62 42 6
49559 -180 123 7 206 145 10 230 174 11 239 182 13 237 188 10 238 202 15 241 208 19 237 201 50
49560 -239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 220 174 15 184 138 11 6 6 6
49561 -2 2 6 2 2 6 2 2 6 2 2 6 26 26 26 94 94 94 42 42 42 14 14 14
49562 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49563 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49564 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49565 -
49566 -0 0 0 1 2 2 29 43 47 26 35 39 3 5 6 8 7 3 106 107 48 165 152 80
49567 -175 176 80 149 139 69 63 55 20 4 5 3 2 3 3 12 17 20 26 35 39 26 35 39
49568 -17 23 26 7 12 13 6 8 8 3 5 6 1 2 2 0 0 0 0 0 0 0 0 0
49569 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 50 50 50 104 69 6
49570 -192 133 9 216 158 10 236 178 12 237 188 10 232 195 16 241 208 19 237 201 50 237 201 50
49571 -241 208 19 241 208 19 241 208 19 204 160 10 200 144 11 216 158 10 156 118 10 2 2 6
49572 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 90 90 90 54 54 54 18 18 18
49573 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49574 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49575 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49576 -
49577 -0 0 0 0 0 0 12 17 20 27 40 45 18 25 28 1 1 1 35 31 12 106 107 48
49578 -149 139 69 56 77 35 8 7 3 1 2 2 12 17 20 26 35 39 21 31 35 11 15 17
49579 -3 5 6 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49580 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 46 46 46 22 22 22
49581 -137 92 6 204 160 10 239 182 13 237 188 10 238 202 15 241 208 19 241 208 19 241 208 19
49582 -241 208 19 204 160 10 184 138 11 210 150 10 216 158 10 210 150 10 98 70 6 2 2 6
49583 -6 6 6 54 54 54 14 14 14 2 2 6 2 2 6 62 62 62 74 74 74 30 30 30
49584 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49585 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49586 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49587 -
49588 -0 0 0 0 0 0 1 1 1 15 22 25 33 49 54 12 17 20 2 3 3 35 31 12
49589 -56 77 35 20 16 6 1 1 1 18 25 28 21 31 35 11 15 17 1 1 1 0 0 0
49590 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49591 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 78 78 78 50 50 50 6 6 6
49592 -88 55 22 139 102 15 190 146 13 230 187 11 239 207 25 232 195 16 220 174 15 190 146 13
49593 -171 120 8 192 133 9 210 150 10 213 154 11 185 146 40 165 152 80 101 98 89 2 2 6
49594 -2 2 6 78 78 78 116 116 116 58 58 58 2 2 6 22 22 22 90 90 90 46 46 46
49595 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49596 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49597 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49598 -
49599 -0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 29 43 47 3 5 6 2 3 3
49600 -8 7 3 1 1 1 17 23 26 31 45 49 15 22 25 0 0 0 0 0 0 0 0 0
49601 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49602 -0 0 0 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 50 50 50 6 6 6
49603 -124 127 131 168 158 138 156 107 11 171 120 8 204 160 10 184 138 11 197 138 11 200 144 11
49604 -206 145 10 206 145 10 197 138 11 198 179 130 195 195 195 198 198 198 170 170 170 14 14 14
49605 -2 2 6 22 22 22 116 116 116 116 116 116 22 22 22 2 2 6 74 74 74 70 70 70
49606 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49607 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49608 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49609 -
49610 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 31 45 49 26 35 39 3 5 6
49611 -0 0 0 7 12 13 27 40 45 18 25 28 0 0 0 0 0 0 0 0 0 0 0 0
49612 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49613 -0 0 0 0 0 0 6 6 6 18 18 18 50 50 50 101 101 101 26 26 26 10 10 10
49614 -124 131 137 190 190 190 168 158 138 156 107 11 197 138 11 200 144 11 197 138 11 192 133 9
49615 -180 123 7 185 146 40 198 179 130 187 187 187 202 202 202 221 221 221 214 214 214 66 66 66
49616 -2 2 6 2 2 6 50 50 50 62 62 62 6 6 6 2 2 6 10 10 10 90 90 90
49617 -50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49618 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49619 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49620 -
49621 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 15 22 25 36 54 60 18 25 28
49622 -0 0 0 21 30 33 27 40 45 2 3 3 0 0 0 0 0 0 0 0 0 0 0 0
49623 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49624 -0 0 0 0 0 0 10 10 10 34 34 34 74 74 74 74 74 74 2 2 6 6 6 6
49625 -151 151 151 198 198 198 190 190 190 168 158 138 148 132 55 156 107 11 156 107 11 169 125 40
49626 -168 158 138 187 187 187 190 190 190 210 210 210 246 246 246 253 253 253 253 253 253 180 180 180
49627 -6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62
49628 -74 74 74 34 34 34 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49629 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49630 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49631 -
49632 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 35 52 58
49633 -18 25 28 35 52 58 17 23 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49634 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49635 -0 0 0 10 10 10 22 22 22 54 54 54 94 94 94 18 18 18 2 2 6 46 46 46
49636 -234 234 234 221 221 221 190 190 190 190 190 190 190 190 190 187 187 187 187 187 187 190 190 190
49637 -190 190 190 195 195 195 214 214 214 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49638 -82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 14 14 14
49639 -86 86 86 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49640 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49641 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49642 -
49643 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 12 13 33 49 54
49644 -52 72 81 36 54 60 6 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49645 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49646 -6 6 6 18 18 18 46 46 46 90 90 90 46 46 46 18 18 18 6 6 6 180 180 180
49647 -253 253 253 246 246 246 202 202 202 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190
49648 -202 202 202 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49649 -202 202 202 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49650 -42 42 42 86 86 86 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49651 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49652 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49653 -
49654 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20
49655 -36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49656 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
49657 -14 14 14 38 38 38 74 74 74 66 66 66 2 2 6 6 6 6 90 90 90 250 250 250
49658 -253 253 253 253 253 253 238 238 238 198 198 198 190 190 190 190 190 190 195 195 195 221 221 221
49659 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49660 -253 253 253 82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49661 -2 2 6 78 78 78 70 70 70 34 34 34 14 14 14 6 6 6 0 0 0 0 0 0
49662 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49663 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49664 -
49665 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49666 -21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49667 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
49668 -34 34 34 66 66 66 78 78 78 6 6 6 2 2 6 18 18 18 218 218 218 253 253 253
49669 -253 253 253 253 253 253 253 253 253 246 246 246 226 226 226 231 231 231 246 246 246 253 253 253
49670 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49671 -253 253 253 180 180 180 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49672 -2 2 6 18 18 18 90 90 90 62 62 62 30 30 30 10 10 10 0 0 0 0 0 0
49673 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49674 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49675 -
49676 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49677 -12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49678 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49679 -58 58 58 90 90 90 18 18 18 2 2 6 2 2 6 106 106 106 253 253 253 253 253 253
49680 -253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253
49681 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49682 -253 253 253 231 231 231 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49683 -2 2 6 2 2 6 18 18 18 94 94 94 54 54 54 26 26 26 10 10 10 0 0 0
49684 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49685 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49686 -
49687 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49688 -0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0
49689 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49690 -90 90 90 26 26 26 2 2 6 2 2 6 14 14 14 195 195 195 250 250 250 253 253 253
49691 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49692 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49693 -250 250 250 242 242 242 54 54 54 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49694 -2 2 6 2 2 6 2 2 6 38 38 38 86 86 86 50 50 50 22 22 22 6 6 6
49695 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49696 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49697 -
49698 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49699 -0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0
49700 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 38 38 38 82 82 82
49701 -34 34 34 2 2 6 2 2 6 2 2 6 42 42 42 195 195 195 246 246 246 253 253 253
49702 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 242 242 242 250 250 250 253 253 253
49703 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 246 246 246 238 238 238
49704 -226 226 226 231 231 231 101 101 101 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49705 -2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 82 82 82 42 42 42 14 14 14
49706 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49707 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49708 -
49709 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49710 -0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0
49711 -0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 62 62 62 66 66 66
49712 -2 2 6 2 2 6 2 2 6 6 6 6 70 70 70 170 170 170 202 202 202 234 234 234
49713 -246 246 246 250 250 250 250 250 250 238 238 238 226 226 226 231 231 231 238 238 238 250 250 250
49714 -250 250 250 250 250 250 246 246 246 231 231 231 214 214 214 202 202 202 202 202 202 202 202 202
49715 -198 198 198 202 202 202 180 180 180 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6
49716 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66 30 30 30
49717 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49718 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49719 -
49720 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49721 -0 0 0 0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0
49722 -0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 82 82 82 18 18 18
49723 -2 2 6 2 2 6 2 2 6 10 10 10 94 94 94 180 180 180 218 218 218 242 242 242
49724 -250 250 250 253 253 253 253 253 253 250 250 250 234 234 234 253 253 253 253 253 253 253 253 253
49725 -253 253 253 253 253 253 253 253 253 246 246 246 238 238 238 226 226 226 210 210 210 202 202 202
49726 -195 195 195 195 195 195 210 210 210 151 151 151 6 6 6 14 14 14 50 50 50 14 14 14
49727 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 86 86 86 46 46 46
49728 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49729 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49730 -
49731 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49732 -0 0 0 0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0
49733 -0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 54 54 54 70 70 70 2 2 6
49734 -2 2 6 10 10 10 2 2 6 22 22 22 170 170 170 231 231 231 250 250 250 253 253 253
49735 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 253 253 253 253 253 253 253 253 253
49736 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246
49737 -231 231 231 202 202 202 198 198 198 226 226 226 94 94 94 2 2 6 6 6 6 38 38 38
49738 -30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66
49739 -26 26 26 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49740 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49741 -
49742 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49743 -0 0 0 0 0 0 0 0 0 0 0 0 6 8 8 33 49 54 29 43 47 6 8 12
49744 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 74 74 74 50 50 50 2 2 6
49745 -26 26 26 26 26 26 2 2 6 106 106 106 238 238 238 253 253 253 253 253 253 253 253 253
49746 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49747 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49748 -253 253 253 246 246 246 218 218 218 202 202 202 210 210 210 14 14 14 2 2 6 2 2 6
49749 -30 30 30 22 22 22 2 2 6 2 2 6 2 2 6 2 2 6 18 18 18 86 86 86
49750 -42 42 42 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49751 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49752 -
49753 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49754 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20 33 49 54 17 23 26
49755 -0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 90 90 90 22 22 22 2 2 6
49756 -42 42 42 2 2 6 18 18 18 218 218 218 253 253 253 253 253 253 253 253 253 253 253 253
49757 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49758 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49759 -253 253 253 253 253 253 250 250 250 221 221 221 218 218 218 101 101 101 2 2 6 14 14 14
49760 -18 18 18 38 38 38 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 78 78 78
49761 -58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49762 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49763 -
49764 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49765 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 22 25 36 54 60
49766 -0 0 0 0 0 0 0 0 0 18 18 18 54 54 54 82 82 82 2 2 6 26 26 26
49767 -22 22 22 2 2 6 124 127 131 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49768 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49769 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49770 -253 253 253 253 253 253 253 253 253 250 250 250 238 238 238 198 198 198 6 6 6 38 38 38
49771 -58 58 58 26 26 26 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6 46 46 46
49772 -78 78 78 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49773 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49774 -
49775 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49776 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 30 33
49777 -36 54 60 0 0 0 0 0 0 30 30 30 74 74 74 58 58 58 2 2 6 42 42 42
49778 -2 2 6 22 22 22 231 231 231 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49779 -253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
49780 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49781 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246 46 46 46 38 38 38
49782 -42 42 42 14 14 14 38 38 38 14 14 14 2 2 6 2 2 6 2 2 6 6 6 6
49783 -86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49784 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49785 -
49786 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49787 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49788 -36 54 60 0 0 0 0 0 0 42 42 42 90 90 90 18 18 18 18 18 18 26 26 26
49789 -2 2 6 116 116 116 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49790 -253 253 253 253 253 253 250 250 250 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
49791 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49792 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 94 94 94 6 6 6
49793 -2 2 6 2 2 6 10 10 10 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6
49794 -74 74 74 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49795 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49796 -
49797 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49798 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49799 -0 0 0 36 54 60 26 26 26 66 66 66 82 82 82 2 2 6 38 38 38 6 6 6
49800 -14 14 14 210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49801 -253 253 253 253 253 253 246 246 246 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49802 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49803 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 2 2 6
49804 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
49805 -42 42 42 74 74 74 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
49806 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49807 -
49808 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49809 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49810 -6 6 6 36 54 60 21 30 33 90 90 90 26 26 26 6 6 6 42 42 42 2 2 6
49811 -74 74 74 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49812 -253 253 253 253 253 253 242 242 242 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49813 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49814 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 180 180 180 2 2 6
49815 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
49816 -10 10 10 86 86 86 38 38 38 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
49817 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49818 -
49819 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49820 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49821 -10 10 10 26 26 26 36 54 60 82 82 82 2 2 6 22 22 22 18 18 18 2 2 6
49822 -151 151 151 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49823 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49824 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49825 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
49826 -2 2 6 2 2 6 2 2 6 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6
49827 -6 6 6 86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0
49828 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49829 -
49830 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49831 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
49832 -18 18 18 46 46 46 86 86 86 36 54 60 2 2 6 34 34 34 10 10 10 6 6 6
49833 -210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49834 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49835 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49836 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 221 221 221 6 6 6
49837 -2 2 6 2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
49838 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49839 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49840 -
49841 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49842 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49843 -26 26 26 66 66 66 62 62 62 2 2 6 2 2 6 38 38 38 10 10 10 26 26 26
49844 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49845 -253 253 253 253 253 253 231 231 231 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
49846 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49847 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 231 231 231 6 6 6
49848 -2 2 6 2 2 6 10 10 10 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
49849 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
49850 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49851 -
49852 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49853 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49854 -38 38 38 78 78 78 6 6 6 2 2 6 2 2 6 46 46 46 14 14 14 42 42 42
49855 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49856 -253 253 253 253 253 253 231 231 231 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49857 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49858 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 10 10 10
49859 -2 2 6 2 2 6 22 22 22 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6
49860 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
49861 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49862 -
49863 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49864 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
49865 -50 50 50 74 74 74 2 2 6 2 2 6 14 14 14 70 70 70 34 34 34 62 62 62
49866 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49867 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
49868 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49869 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 14 14 14
49870 -2 2 6 2 2 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49871 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
49872 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49873 -
49874 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49875 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
49876 -54 54 54 62 62 62 2 2 6 2 2 6 2 2 6 30 30 30 46 46 46 70 70 70
49877 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49878 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
49879 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49880 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 226 226 226 10 10 10
49881 -2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49882 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
49883 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49884 -
49885 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49886 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
49887 -58 58 58 62 62 62 2 2 6 2 2 6 2 2 6 2 2 6 30 30 30 78 78 78
49888 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49889 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
49890 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49891 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
49892 -22 22 22 34 34 34 20 16 6 22 22 22 26 26 26 18 18 18 6 6 6 2 2 6
49893 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49894 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49895 -
49896 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49897 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 26 26 26
49898 -62 62 62 106 106 106 63 55 20 184 138 11 204 160 10 121 92 8 6 6 6 62 62 62
49899 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49900 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
49901 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49902 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 18 18 18
49903 -14 14 14 2 2 6 2 2 6 2 2 6 6 6 6 18 18 18 66 66 66 38 38 38
49904 -6 6 6 94 94 94 50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49905 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49906 -
49907 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49908 -0 0 0 0 0 0 0 0 0 6 6 6 10 10 10 10 10 10 18 18 18 38 38 38
49909 -78 78 78 138 132 106 216 158 10 242 186 14 246 190 14 246 190 14 156 118 10 10 10 10
49910 -90 90 90 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49911 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
49912 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49913 -253 253 253 253 253 253 253 253 253 246 230 190 214 187 87 214 187 87 185 146 40 35 31 12
49914 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 46 46 46
49915 -26 26 26 106 106 106 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49916 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49917 -
49918 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49919 -0 0 0 6 6 6 14 14 14 22 22 22 30 30 30 38 38 38 50 50 50 70 70 70
49920 -106 106 106 185 146 40 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 154 114 10
49921 -6 6 6 74 74 74 226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49922 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
49923 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49924 -253 253 253 253 253 253 253 253 253 237 201 50 241 196 14 241 208 19 232 195 16 35 31 12
49925 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 30 30 30 26 26 26
49926 -204 160 10 165 152 80 66 66 66 26 26 26 6 6 6 0 0 0 0 0 0 0 0 0
49927 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49928 -
49929 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49930 -6 6 6 18 18 18 38 38 38 58 58 58 78 78 78 86 86 86 101 101 101 124 127 131
49931 -174 140 55 210 150 10 234 174 13 246 186 14 246 190 14 246 190 14 246 190 14 237 188 10
49932 -98 70 6 2 2 6 46 46 46 198 198 198 253 253 253 253 253 253 253 253 253 253 253 253
49933 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
49934 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49935 -253 253 253 253 253 253 253 253 253 214 187 87 242 186 14 241 196 14 204 160 10 20 16 6
49936 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 121 92 8
49937 -238 202 15 232 195 16 82 82 82 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
49938 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49939 -
49940 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49941 -14 14 14 38 38 38 70 70 70 148 132 55 185 146 40 200 144 11 197 138 11 197 138 11
49942 -213 154 11 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
49943 -220 174 15 35 31 12 2 2 6 22 22 22 151 151 151 250 250 250 253 253 253 253 253 253
49944 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49945 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49946 -253 253 253 250 250 250 242 242 242 214 187 87 239 182 13 237 188 10 213 154 11 35 31 12
49947 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 42 6 220 174 15
49948 -237 188 10 237 188 10 113 101 86 42 42 42 14 14 14 0 0 0 0 0 0 0 0 0
49949 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49950 -
49951 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
49952 -22 22 22 54 54 54 148 132 55 213 154 11 226 170 11 230 174 11 226 170 11 226 170 11
49953 -236 178 12 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
49954 -241 196 14 184 138 11 10 10 10 2 2 6 6 6 6 116 116 116 242 242 242 253 253 253
49955 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49956 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49957 -253 253 253 231 231 231 198 198 198 213 164 39 236 178 12 236 178 12 210 150 10 137 92 6
49958 -20 16 6 2 2 6 2 2 6 2 2 6 6 6 6 62 42 6 200 144 11 236 178 12
49959 -239 182 13 239 182 13 124 112 88 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0
49960 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49961 -
49962 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49963 -30 30 30 70 70 70 169 125 40 226 170 11 239 182 13 242 186 14 242 186 14 246 186 14
49964 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
49965 -246 190 14 232 195 16 98 70 6 2 2 6 2 2 6 2 2 6 66 66 66 221 221 221
49966 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49967 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49968 -253 253 253 202 202 202 198 198 198 213 164 39 230 174 11 230 174 11 216 158 10 192 133 9
49969 -163 110 8 120 80 7 98 70 6 120 80 7 167 114 7 197 138 11 226 170 11 239 182 13
49970 -242 186 14 242 186 14 165 152 80 78 78 78 34 34 34 14 14 14 6 6 6 0 0 0
49971 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49972 -
49973 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
49974 -30 30 30 78 78 78 185 146 40 226 170 11 239 182 13 246 190 14 246 190 14 246 190 14
49975 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
49976 -246 190 14 241 196 14 204 160 10 20 16 6 2 2 6 2 2 6 2 2 6 38 38 38
49977 -218 218 218 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49978 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49979 -250 250 250 202 202 202 198 198 198 213 164 39 226 170 11 236 178 12 224 166 10 210 150 10
49980 -200 144 11 197 138 11 192 133 9 197 138 11 210 150 10 226 170 11 242 186 14 246 190 14
49981 -246 190 14 246 186 14 220 174 15 124 112 88 62 62 62 30 30 30 14 14 14 6 6 6
49982 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49983 -
49984 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49985 -30 30 30 78 78 78 174 140 55 224 166 10 239 182 13 246 190 14 246 190 14 246 190 14
49986 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
49987 -246 190 14 246 190 14 241 196 14 139 102 15 2 2 6 2 2 6 2 2 6 2 2 6
49988 -78 78 78 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49989 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
49990 -250 250 250 214 214 214 198 198 198 185 146 40 219 162 10 236 178 12 234 174 13 224 166 10
49991 -216 158 10 213 154 11 213 154 11 216 158 10 226 170 11 239 182 13 246 190 14 246 190 14
49992 -246 190 14 246 190 14 242 186 14 213 164 39 101 101 101 58 58 58 30 30 30 14 14 14
49993 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49994 -
49995 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49996 -30 30 30 74 74 74 174 140 55 216 158 10 236 178 12 246 190 14 246 190 14 246 190 14
49997 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
49998 -246 190 14 246 190 14 241 196 14 230 187 11 62 42 6 2 2 6 2 2 6 2 2 6
49999 -22 22 22 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50000 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50001 -253 253 253 226 226 226 187 187 187 169 125 40 216 158 10 236 178 12 239 182 13 236 178 12
50002 -230 174 11 226 170 11 226 170 11 230 174 11 236 178 12 242 186 14 246 190 14 246 190 14
50003 -246 190 14 246 190 14 246 186 14 239 182 13 213 164 39 106 106 106 66 66 66 34 34 34
50004 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50005 -
50006 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50007 -26 26 26 70 70 70 149 139 69 213 154 11 236 178 12 246 190 14 246 190 14 246 190 14
50008 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50009 -246 190 14 246 190 14 246 190 14 241 196 14 190 146 13 20 16 6 2 2 6 2 2 6
50010 -46 46 46 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50011 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50012 -253 253 253 221 221 221 86 86 86 156 107 11 216 158 10 236 178 12 242 186 14 246 186 14
50013 -242 186 14 239 182 13 239 182 13 242 186 14 242 186 14 246 186 14 246 190 14 246 190 14
50014 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 220 174 15 149 139 69 66 66 66
50015 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50016 -
50017 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50018 -26 26 26 70 70 70 149 139 69 210 150 10 236 178 12 246 190 14 246 190 14 246 190 14
50019 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50020 -246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 121 92 8 34 34 34 106 106 106
50021 -221 221 221 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50022 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50023 -242 242 242 82 82 82 20 16 6 163 110 8 216 158 10 236 178 12 242 186 14 246 190 14
50024 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50025 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 149 139 69
50026 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50027 -
50028 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50029 -30 30 30 78 78 78 149 139 69 210 150 10 236 178 12 246 186 14 246 190 14 246 190 14
50030 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50031 -246 190 14 246 190 14 246 190 14 246 190 14 241 196 14 220 174 15 198 179 130 253 253 253
50032 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50033 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 218 218 218
50034 -58 58 58 2 2 6 20 16 6 167 114 7 216 158 10 236 178 12 246 186 14 246 190 14
50035 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50036 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 242 186 14 185 146 40
50037 -54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50038 -
50039 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50040 -38 38 38 86 86 86 169 125 40 213 154 11 236 178 12 246 186 14 246 190 14 246 190 14
50041 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50042 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 190 146 13 214 214 214
50043 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50044 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 170 170 170 26 26 26
50045 -2 2 6 2 2 6 35 31 12 163 110 8 219 162 10 239 182 13 246 186 14 246 190 14
50046 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50047 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 224 166 10 149 139 69
50048 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50049 -
50050 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50051 -50 50 50 113 101 86 192 133 9 224 166 10 242 186 14 246 190 14 246 190 14 246 190 14
50052 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50053 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 230 187 11 204 160 10 133 118 54
50054 -226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50055 -253 253 253 253 253 253 253 253 253 253 253 253 198 198 198 66 66 66 2 2 6 2 2 6
50056 -2 2 6 2 2 6 62 42 6 156 107 11 219 162 10 239 182 13 246 186 14 246 190 14
50057 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50058 -246 190 14 246 190 14 246 190 14 242 186 14 234 174 13 213 154 11 148 132 55 66 66 66
50059 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50060 -
50061 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50062 -58 58 58 148 132 55 206 145 10 234 174 13 242 186 14 246 186 14 246 190 14 246 190 14
50063 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50064 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 204 160 10 163 110 8
50065 -62 42 6 124 131 137 218 218 218 250 250 250 253 253 253 253 253 253 253 253 253 250 250 250
50066 -242 242 242 210 210 210 151 151 151 66 66 66 6 6 6 2 2 6 2 2 6 2 2 6
50067 -2 2 6 2 2 6 62 42 6 163 110 8 216 158 10 236 178 12 246 190 14 246 190 14
50068 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50069 -246 190 14 239 182 13 230 174 11 216 158 10 185 146 40 124 112 88 70 70 70 38 38 38
50070 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50071 -
50072 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50073 -62 62 62 169 125 40 206 145 10 224 166 10 236 178 12 239 182 13 242 186 14 242 186 14
50074 -246 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50075 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 236 178 12 216 158 10 171 120 8
50076 -85 57 6 2 2 6 6 6 6 30 30 30 54 54 54 62 62 62 50 50 50 38 38 38
50077 -14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50078 -2 2 6 6 6 6 85 57 6 167 114 7 213 154 11 236 178 12 246 190 14 246 190 14
50079 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 239 182 13 239 182 13
50080 -230 174 11 210 150 10 174 140 55 124 112 88 82 82 82 54 54 54 34 34 34 18 18 18
50081 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50082 -
50083 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50084 -50 50 50 169 125 40 192 133 9 200 144 11 216 158 10 219 162 10 224 166 10 226 170 11
50085 -230 174 11 236 178 12 239 182 13 239 182 13 242 186 14 246 186 14 246 190 14 246 190 14
50086 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 230 174 11 210 150 10 163 110 8
50087 -104 69 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50088 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50089 -2 2 6 6 6 6 85 57 6 167 114 7 206 145 10 230 174 11 242 186 14 246 190 14
50090 -246 190 14 246 190 14 246 186 14 242 186 14 239 182 13 230 174 11 224 166 10 213 154 11
50091 -169 125 40 124 112 88 86 86 86 58 58 58 38 38 38 22 22 22 10 10 10 6 6 6
50092 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50093 -
50094 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50095 -34 34 34 70 70 70 133 118 54 169 125 40 167 114 7 180 123 7 192 133 9 197 138 11
50096 -200 144 11 206 145 10 213 154 11 219 162 10 224 166 10 230 174 11 239 182 13 242 186 14
50097 -246 186 14 246 186 14 246 186 14 246 186 14 239 182 13 216 158 10 184 138 11 152 99 6
50098 -104 69 6 20 16 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50099 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50100 -2 2 6 6 6 6 85 57 6 152 99 6 192 133 9 219 162 10 236 178 12 239 182 13
50101 -246 186 14 242 186 14 239 182 13 236 178 12 224 166 10 206 145 10 192 133 9 148 132 55
50102 -94 94 94 62 62 62 42 42 42 22 22 22 14 14 14 6 6 6 0 0 0 0 0 0
50103 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50104 -
50105 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50106 -18 18 18 34 34 34 58 58 58 78 78 78 101 98 89 124 112 88 133 118 54 156 107 11
50107 -163 110 8 167 114 7 171 120 8 180 123 7 184 138 11 197 138 11 210 150 10 219 162 10
50108 -226 170 11 236 178 12 236 178 12 234 174 13 219 162 10 197 138 11 163 110 8 134 84 6
50109 -85 57 6 10 10 10 2 2 6 2 2 6 18 18 18 38 38 38 38 38 38 38 38 38
50110 -38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 26 26 26 2 2 6
50111 -2 2 6 6 6 6 62 42 6 137 92 6 171 120 8 200 144 11 219 162 10 230 174 11
50112 -234 174 13 230 174 11 219 162 10 210 150 10 192 133 9 163 110 8 124 112 88 82 82 82
50113 -50 50 50 30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50114 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50115 -
50116 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50117 -6 6 6 14 14 14 22 22 22 34 34 34 42 42 42 58 58 58 74 74 74 86 86 86
50118 -101 98 89 113 101 86 133 118 54 121 92 8 137 92 6 152 99 6 163 110 8 180 123 7
50119 -184 138 11 197 138 11 206 145 10 200 144 11 180 123 7 156 107 11 134 84 6 104 69 6
50120 -62 42 6 54 54 54 106 106 106 101 98 89 86 86 86 82 82 82 78 78 78 78 78 78
50121 -78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 82 82 82 86 86 86 94 94 94
50122 -106 106 106 101 101 101 90 61 47 120 80 7 156 107 11 180 123 7 192 133 9 200 144 11
50123 -206 145 10 200 144 11 192 133 9 171 120 8 139 102 15 113 101 86 70 70 70 42 42 42
50124 -22 22 22 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50125 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50126 -
50127 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50128 -0 0 0 0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 30 30 30 38 38 38
50129 -50 50 50 62 62 62 74 74 74 90 90 90 101 98 89 113 101 86 121 92 8 120 80 7
50130 -137 92 6 152 99 6 152 99 6 152 99 6 134 84 6 120 80 7 98 70 6 88 55 22
50131 -101 98 89 82 82 82 58 58 58 46 46 46 38 38 38 34 34 34 34 34 34 34 34 34
50132 -34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 38 38 38 42 42 42
50133 -54 54 54 82 82 82 94 86 71 85 57 6 134 84 6 156 107 11 167 114 7 171 120 8
50134 -171 120 8 167 114 7 152 99 6 121 92 8 101 98 89 62 62 62 34 34 34 18 18 18
50135 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50136 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50137 -
50138 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50139 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10
50140 -18 18 18 22 22 22 30 30 30 42 42 42 50 50 50 66 66 66 86 86 86 101 98 89
50141 -94 86 71 98 70 6 104 69 6 104 69 6 104 69 6 85 57 6 88 55 22 90 90 90
50142 -62 62 62 38 38 38 22 22 22 14 14 14 10 10 10 10 10 10 10 10 10 10 10 10
50143 -10 10 10 10 10 10 6 6 6 10 10 10 10 10 10 10 10 10 10 10 10 14 14 14
50144 -22 22 22 42 42 42 70 70 70 94 86 71 85 57 6 104 69 6 120 80 7 137 92 6
50145 -134 84 6 120 80 7 94 86 71 86 86 86 58 58 58 30 30 30 14 14 14 6 6 6
50146 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50147 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50148 -
50149 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50150 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50151 -0 0 0 6 6 6 10 10 10 14 14 14 18 18 18 26 26 26 38 38 38 54 54 54
50152 -70 70 70 86 86 86 94 86 71 94 86 71 94 86 71 86 86 86 74 74 74 50 50 50
50153 -30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50154 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50155 -6 6 6 18 18 18 34 34 34 58 58 58 82 82 82 94 86 71 94 86 71 94 86 71
50156 -94 86 71 94 86 71 74 74 74 50 50 50 26 26 26 14 14 14 6 6 6 0 0 0
50157 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50158 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50159 -
50160 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50161 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50162 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 14 14 14 18 18 18
50163 -30 30 30 38 38 38 46 46 46 54 54 54 50 50 50 42 42 42 30 30 30 18 18 18
50164 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50165 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50166 -0 0 0 6 6 6 14 14 14 26 26 26 38 38 38 50 50 50 58 58 58 58 58 58
50167 -54 54 54 42 42 42 30 30 30 18 18 18 10 10 10 0 0 0 0 0 0 0 0 0
50168 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50169 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50170 -
50171 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50172 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50173 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50174 -6 6 6 10 10 10 14 14 14 18 18 18 18 18 18 14 14 14 10 10 10 6 6 6
50175 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50176 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50177 -0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 18 18 18 22 22 22 22 22 22
50178 -18 18 18 14 14 14 10 10 10 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50179 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50180 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50181 -
50182 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50183 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50184 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50185 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50186 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50187 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50188 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50189 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50190 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50191 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50192 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50193 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50194 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50195 +4 4 4 4 4 4
50196 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50197 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50198 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50199 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50200 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50201 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50202 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50203 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50204 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50205 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50206 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50207 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50208 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50209 +4 4 4 4 4 4
50210 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50211 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50212 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50213 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50214 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50215 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50216 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50217 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50218 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50219 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50220 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50221 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50222 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50223 +4 4 4 4 4 4
50224 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50225 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50226 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50227 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50228 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50229 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50230 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50231 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50232 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50233 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50234 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50235 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50236 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50237 +4 4 4 4 4 4
50238 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50239 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50240 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50241 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50242 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50243 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50244 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50245 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50246 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50248 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50249 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50250 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50251 +4 4 4 4 4 4
50252 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50253 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50254 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50255 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50256 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50257 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50258 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50259 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50260 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50263 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50264 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50265 +4 4 4 4 4 4
50266 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50267 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50269 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50270 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
50271 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
50272 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50273 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50274 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50275 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
50276 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50277 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
50278 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50279 +4 4 4 4 4 4
50280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50281 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50282 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50283 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50284 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
50285 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
50286 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50287 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50288 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50289 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
50290 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
50291 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
50292 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50293 +4 4 4 4 4 4
50294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50295 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50296 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50297 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50298 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
50299 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
50300 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50301 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50302 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50303 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
50304 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
50305 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
50306 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
50307 +4 4 4 4 4 4
50308 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50309 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50310 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50311 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
50312 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
50313 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
50314 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
50315 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50316 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50317 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
50318 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
50319 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
50320 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
50321 +4 4 4 4 4 4
50322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50323 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50325 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
50326 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
50327 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
50328 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
50329 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
50330 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
50331 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
50332 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
50333 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
50334 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
50335 +4 4 4 4 4 4
50336 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50338 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
50339 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
50340 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
50341 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
50342 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
50343 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
50344 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
50345 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
50346 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
50347 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
50348 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
50349 +4 4 4 4 4 4
50350 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50351 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50352 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
50353 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
50354 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
50355 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
50356 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
50357 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
50358 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
50359 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
50360 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
50361 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
50362 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
50363 +4 4 4 4 4 4
50364 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50366 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
50367 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
50368 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
50369 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
50370 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
50371 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
50372 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
50373 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
50374 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
50375 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
50376 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
50377 +4 4 4 4 4 4
50378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50380 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
50381 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
50382 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
50383 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
50384 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
50385 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
50386 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
50387 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
50388 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
50389 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
50390 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50391 +4 4 4 4 4 4
50392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50394 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
50395 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
50396 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
50397 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
50398 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
50399 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
50400 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
50401 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
50402 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
50403 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
50404 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
50405 +4 4 4 4 4 4
50406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50407 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
50408 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
50409 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
50410 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
50411 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
50412 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
50413 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
50414 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
50415 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
50416 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
50417 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
50418 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
50419 +4 4 4 4 4 4
50420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50421 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
50422 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
50423 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
50424 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
50425 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
50426 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
50427 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
50428 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
50429 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
50430 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
50431 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
50432 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
50433 +0 0 0 4 4 4
50434 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50435 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
50436 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
50437 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
50438 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
50439 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
50440 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
50441 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
50442 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
50443 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
50444 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
50445 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
50446 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
50447 +2 0 0 0 0 0
50448 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
50449 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
50450 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
50451 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
50452 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
50453 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
50454 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
50455 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
50456 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
50457 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
50458 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
50459 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
50460 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
50461 +37 38 37 0 0 0
50462 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50463 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
50464 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
50465 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
50466 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
50467 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
50468 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
50469 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
50470 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
50471 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
50472 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
50473 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
50474 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
50475 +85 115 134 4 0 0
50476 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
50477 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
50478 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
50479 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
50480 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
50481 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
50482 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
50483 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
50484 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
50485 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
50486 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
50487 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
50488 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
50489 +60 73 81 4 0 0
50490 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
50491 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
50492 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
50493 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
50494 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
50495 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
50496 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
50497 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
50498 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
50499 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
50500 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
50501 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
50502 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
50503 +16 19 21 4 0 0
50504 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
50505 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
50506 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
50507 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
50508 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
50509 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
50510 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
50511 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
50512 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
50513 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
50514 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
50515 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
50516 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
50517 +4 0 0 4 3 3
50518 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
50519 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
50520 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
50521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
50522 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
50523 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
50524 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
50525 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
50526 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
50527 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
50528 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
50529 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
50530 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
50531 +3 2 2 4 4 4
50532 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
50533 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
50534 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
50535 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50536 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
50537 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
50538 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50539 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
50540 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
50541 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
50542 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
50543 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
50544 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
50545 +4 4 4 4 4 4
50546 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
50547 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
50548 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
50549 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
50550 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
50551 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
50552 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
50553 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
50554 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
50555 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
50556 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
50557 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
50558 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
50559 +4 4 4 4 4 4
50560 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
50561 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
50562 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
50563 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
50564 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
50565 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50566 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
50567 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
50568 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
50569 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
50570 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
50571 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
50572 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
50573 +5 5 5 5 5 5
50574 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
50575 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
50576 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
50577 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
50578 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
50579 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50580 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
50581 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
50582 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
50583 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
50584 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
50585 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
50586 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
50587 +5 5 5 4 4 4
50588 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
50589 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
50590 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
50591 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
50592 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50593 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
50594 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
50595 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
50596 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
50597 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
50598 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
50599 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
50600 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50601 +4 4 4 4 4 4
50602 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
50603 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
50604 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
50605 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
50606 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
50607 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50608 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50609 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
50610 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
50611 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
50612 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
50613 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
50614 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50615 +4 4 4 4 4 4
50616 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
50617 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
50618 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
50619 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
50620 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50621 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
50622 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
50623 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
50624 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
50625 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
50626 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
50627 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50628 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50629 +4 4 4 4 4 4
50630 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
50631 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
50632 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
50633 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
50634 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50635 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50636 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50637 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
50638 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
50639 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
50640 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
50641 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50642 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50643 +4 4 4 4 4 4
50644 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
50645 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
50646 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
50647 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
50648 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50649 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
50650 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50651 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
50652 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
50653 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
50654 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50657 +4 4 4 4 4 4
50658 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
50659 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
50660 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
50661 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
50662 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
50663 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
50664 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
50665 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
50666 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
50667 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
50668 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
50669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50671 +4 4 4 4 4 4
50672 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
50673 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
50674 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
50675 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
50676 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50677 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
50678 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
50679 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
50680 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
50681 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
50682 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
50683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50685 +4 4 4 4 4 4
50686 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
50687 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
50688 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
50689 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50690 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
50691 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
50692 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
50693 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
50694 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
50695 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
50696 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50699 +4 4 4 4 4 4
50700 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
50701 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
50702 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
50703 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
50704 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50705 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
50706 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
50707 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
50708 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
50709 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
50710 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50713 +4 4 4 4 4 4
50714 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
50715 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
50716 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
50717 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
50718 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50719 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
50720 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
50721 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
50722 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
50723 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
50724 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50727 +4 4 4 4 4 4
50728 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
50729 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
50730 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
50731 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
50732 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50733 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
50734 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
50735 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
50736 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
50737 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50738 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50741 +4 4 4 4 4 4
50742 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
50743 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
50744 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
50745 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
50746 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
50747 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
50748 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
50749 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
50750 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
50751 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50752 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50755 +4 4 4 4 4 4
50756 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
50757 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
50758 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
50759 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
50760 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50761 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
50762 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
50763 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
50764 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
50765 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50766 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50769 +4 4 4 4 4 4
50770 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
50771 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
50772 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
50773 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
50774 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
50775 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
50776 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
50777 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
50778 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
50779 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50780 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50783 +4 4 4 4 4 4
50784 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
50785 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
50786 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
50787 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
50788 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
50789 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
50790 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
50791 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
50792 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
50793 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50794 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50797 +4 4 4 4 4 4
50798 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
50799 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
50800 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
50801 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
50802 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
50803 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
50804 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
50805 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
50806 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
50807 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50808 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50811 +4 4 4 4 4 4
50812 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
50813 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
50814 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
50815 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
50816 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
50817 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
50818 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
50819 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
50820 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
50821 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50822 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50825 +4 4 4 4 4 4
50826 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
50827 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
50828 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
50829 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
50830 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
50831 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
50832 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
50833 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
50834 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
50835 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50836 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50839 +4 4 4 4 4 4
50840 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
50841 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
50842 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
50843 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
50844 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
50845 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
50846 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
50847 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
50848 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
50849 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50850 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50853 +4 4 4 4 4 4
50854 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
50855 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
50856 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
50857 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
50858 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
50859 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
50860 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50861 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
50862 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
50863 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50864 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50867 +4 4 4 4 4 4
50868 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
50869 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
50870 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
50871 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
50872 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
50873 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
50874 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
50875 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
50876 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
50877 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50878 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50881 +4 4 4 4 4 4
50882 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
50883 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
50884 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
50885 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
50886 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
50887 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
50888 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
50889 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
50890 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
50891 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50892 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50895 +4 4 4 4 4 4
50896 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
50897 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
50898 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
50899 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
50900 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
50901 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
50902 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
50903 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
50904 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
50905 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50906 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50909 +4 4 4 4 4 4
50910 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
50911 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
50912 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
50913 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
50914 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
50915 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
50916 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
50917 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
50918 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
50919 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50920 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50923 +4 4 4 4 4 4
50924 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
50925 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
50926 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
50927 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
50928 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
50929 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
50930 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
50931 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
50932 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
50933 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
50934 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50937 +4 4 4 4 4 4
50938 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
50939 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
50940 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
50941 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
50942 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
50943 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
50944 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
50945 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
50946 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
50947 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
50948 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
50949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50951 +4 4 4 4 4 4
50952 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
50953 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
50954 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
50955 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
50956 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
50957 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
50958 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
50959 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
50960 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
50961 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
50962 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50964 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50965 +4 4 4 4 4 4
50966 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
50967 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
50968 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
50969 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
50970 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
50971 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
50972 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50973 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
50974 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
50975 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
50976 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
50977 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50978 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50979 +4 4 4 4 4 4
50980 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
50981 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
50982 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
50983 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
50984 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
50985 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
50986 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
50987 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
50988 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
50989 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
50990 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50991 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50992 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50993 +4 4 4 4 4 4
50994 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
50995 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
50996 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
50997 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
50998 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
50999 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51000 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51001 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51002 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51003 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51005 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51006 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51007 +4 4 4 4 4 4
51008 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51009 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51010 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51011 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51012 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51013 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51014 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51015 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51016 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51017 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51020 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51021 +4 4 4 4 4 4
51022 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51023 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51024 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51025 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51026 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51027 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51028 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51029 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51030 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51031 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51033 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51034 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51035 +4 4 4 4 4 4
51036 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51037 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51038 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51039 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51040 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51041 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51042 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51043 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51044 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51045 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51047 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51048 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51049 +4 4 4 4 4 4
51050 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51051 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51052 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51053 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51054 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51055 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51056 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51057 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51058 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51059 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51061 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51062 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51063 +4 4 4 4 4 4
51064 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51065 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51066 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51067 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51068 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51069 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51070 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51071 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51072 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51073 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51075 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51076 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51077 +4 4 4 4 4 4
51078 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51079 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51080 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51081 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51082 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51083 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51084 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51085 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51086 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51089 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51090 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51091 +4 4 4 4 4 4
51092 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51093 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51094 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51095 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51096 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51097 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51098 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51099 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51100 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51103 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51104 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51105 +4 4 4 4 4 4
51106 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51107 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51108 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51109 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51110 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51111 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51112 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51113 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51114 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51117 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51118 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51119 +4 4 4 4 4 4
51120 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51121 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51122 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51123 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51124 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51125 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51126 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51127 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
51128 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51129 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51130 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51131 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51132 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51133 +4 4 4 4 4 4
51134 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51135 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51136 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51137 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51138 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51139 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51140 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51141 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
51142 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51143 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51144 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51145 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51146 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51147 +4 4 4 4 4 4
51148 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51149 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51150 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51151 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51152 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51153 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51154 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51155 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51156 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51157 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51158 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51159 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51160 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51161 +4 4 4 4 4 4
51162 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51163 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51164 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51165 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51166 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51167 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51168 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51169 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51170 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51171 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51172 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51173 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51174 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51175 +4 4 4 4 4 4
51176 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51177 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51178 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51179 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51180 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51181 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51182 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
51183 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51184 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51185 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51186 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51187 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51188 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51189 +4 4 4 4 4 4
51190 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51191 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51192 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51193 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51194 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51195 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51196 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
51197 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51198 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51199 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51200 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51201 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51202 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51203 +4 4 4 4 4 4
51204 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51205 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51206 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51207 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51208 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51209 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51210 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
51211 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51212 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51213 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51214 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51215 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51216 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51217 +4 4 4 4 4 4
51218 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51219 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51220 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51221 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
51222 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51223 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51224 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
51225 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51226 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51227 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51228 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51229 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51230 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51231 +4 4 4 4 4 4
51232 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51233 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51234 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51235 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51236 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51237 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51238 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51239 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51240 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51241 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51242 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51243 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51244 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51245 +4 4 4 4 4 4
51246 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51248 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51249 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51250 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
51251 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51252 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51253 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51254 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51255 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51256 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51257 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51258 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51259 +4 4 4 4 4 4
51260 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51263 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51264 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
51265 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
51266 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51267 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51269 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51270 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51271 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51272 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51273 +4 4 4 4 4 4
51274 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51277 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51278 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
51279 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
51280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51281 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51282 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51283 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51284 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51285 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51286 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51287 +4 4 4 4 4 4
51288 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51291 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51292 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51293 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
51294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51295 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51296 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51297 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51298 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51299 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51300 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51301 +4 4 4 4 4 4
51302 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
51303 index fe92eed..106e085 100644
51304 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
51305 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
51306 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
51307 struct mb862xxfb_par *par = info->par;
51308
51309 if (info->var.bits_per_pixel == 32) {
51310 - info->fbops->fb_fillrect = cfb_fillrect;
51311 - info->fbops->fb_copyarea = cfb_copyarea;
51312 - info->fbops->fb_imageblit = cfb_imageblit;
51313 + pax_open_kernel();
51314 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51315 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51316 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51317 + pax_close_kernel();
51318 } else {
51319 outreg(disp, GC_L0EM, 3);
51320 - info->fbops->fb_fillrect = mb86290fb_fillrect;
51321 - info->fbops->fb_copyarea = mb86290fb_copyarea;
51322 - info->fbops->fb_imageblit = mb86290fb_imageblit;
51323 + pax_open_kernel();
51324 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
51325 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
51326 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
51327 + pax_close_kernel();
51328 }
51329 outreg(draw, GDC_REG_DRAW_BASE, 0);
51330 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
51331 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
51332 index ff22871..b129bed 100644
51333 --- a/drivers/video/nvidia/nvidia.c
51334 +++ b/drivers/video/nvidia/nvidia.c
51335 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
51336 info->fix.line_length = (info->var.xres_virtual *
51337 info->var.bits_per_pixel) >> 3;
51338 if (info->var.accel_flags) {
51339 - info->fbops->fb_imageblit = nvidiafb_imageblit;
51340 - info->fbops->fb_fillrect = nvidiafb_fillrect;
51341 - info->fbops->fb_copyarea = nvidiafb_copyarea;
51342 - info->fbops->fb_sync = nvidiafb_sync;
51343 + pax_open_kernel();
51344 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
51345 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
51346 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
51347 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
51348 + pax_close_kernel();
51349 info->pixmap.scan_align = 4;
51350 info->flags &= ~FBINFO_HWACCEL_DISABLED;
51351 info->flags |= FBINFO_READS_FAST;
51352 NVResetGraphics(info);
51353 } else {
51354 - info->fbops->fb_imageblit = cfb_imageblit;
51355 - info->fbops->fb_fillrect = cfb_fillrect;
51356 - info->fbops->fb_copyarea = cfb_copyarea;
51357 - info->fbops->fb_sync = NULL;
51358 + pax_open_kernel();
51359 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51360 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51361 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51362 + *(void **)&info->fbops->fb_sync = NULL;
51363 + pax_close_kernel();
51364 info->pixmap.scan_align = 1;
51365 info->flags |= FBINFO_HWACCEL_DISABLED;
51366 info->flags &= ~FBINFO_READS_FAST;
51367 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
51368 info->pixmap.size = 8 * 1024;
51369 info->pixmap.flags = FB_PIXMAP_SYSTEM;
51370
51371 - if (!hwcur)
51372 - info->fbops->fb_cursor = NULL;
51373 + if (!hwcur) {
51374 + pax_open_kernel();
51375 + *(void **)&info->fbops->fb_cursor = NULL;
51376 + pax_close_kernel();
51377 + }
51378
51379 info->var.accel_flags = (!noaccel);
51380
51381 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
51382 index 05c2dc3..ea1f391 100644
51383 --- a/drivers/video/s1d13xxxfb.c
51384 +++ b/drivers/video/s1d13xxxfb.c
51385 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
51386
51387 switch(prod_id) {
51388 case S1D13506_PROD_ID: /* activate acceleration */
51389 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51390 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51391 + pax_open_kernel();
51392 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51393 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51394 + pax_close_kernel();
51395 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
51396 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
51397 break;
51398 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
51399 index e188ada..aac63c8 100644
51400 --- a/drivers/video/smscufx.c
51401 +++ b/drivers/video/smscufx.c
51402 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
51403 fb_deferred_io_cleanup(info);
51404 kfree(info->fbdefio);
51405 info->fbdefio = NULL;
51406 - info->fbops->fb_mmap = ufx_ops_mmap;
51407 + pax_open_kernel();
51408 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
51409 + pax_close_kernel();
51410 }
51411
51412 pr_debug("released /dev/fb%d user=%d count=%d",
51413 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
51414 index d2e5bc3..4cb05d1 100644
51415 --- a/drivers/video/udlfb.c
51416 +++ b/drivers/video/udlfb.c
51417 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
51418 dlfb_urb_completion(urb);
51419
51420 error:
51421 - atomic_add(bytes_sent, &dev->bytes_sent);
51422 - atomic_add(bytes_identical, &dev->bytes_identical);
51423 - atomic_add(width*height*2, &dev->bytes_rendered);
51424 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51425 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51426 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
51427 end_cycles = get_cycles();
51428 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51429 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51430 >> 10)), /* Kcycles */
51431 &dev->cpu_kcycles_used);
51432
51433 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
51434 dlfb_urb_completion(urb);
51435
51436 error:
51437 - atomic_add(bytes_sent, &dev->bytes_sent);
51438 - atomic_add(bytes_identical, &dev->bytes_identical);
51439 - atomic_add(bytes_rendered, &dev->bytes_rendered);
51440 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51441 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51442 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
51443 end_cycles = get_cycles();
51444 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51445 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51446 >> 10)), /* Kcycles */
51447 &dev->cpu_kcycles_used);
51448 }
51449 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
51450 fb_deferred_io_cleanup(info);
51451 kfree(info->fbdefio);
51452 info->fbdefio = NULL;
51453 - info->fbops->fb_mmap = dlfb_ops_mmap;
51454 + pax_open_kernel();
51455 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
51456 + pax_close_kernel();
51457 }
51458
51459 pr_warn("released /dev/fb%d user=%d count=%d\n",
51460 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
51461 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51462 struct dlfb_data *dev = fb_info->par;
51463 return snprintf(buf, PAGE_SIZE, "%u\n",
51464 - atomic_read(&dev->bytes_rendered));
51465 + atomic_read_unchecked(&dev->bytes_rendered));
51466 }
51467
51468 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51469 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51470 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51471 struct dlfb_data *dev = fb_info->par;
51472 return snprintf(buf, PAGE_SIZE, "%u\n",
51473 - atomic_read(&dev->bytes_identical));
51474 + atomic_read_unchecked(&dev->bytes_identical));
51475 }
51476
51477 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51478 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51479 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51480 struct dlfb_data *dev = fb_info->par;
51481 return snprintf(buf, PAGE_SIZE, "%u\n",
51482 - atomic_read(&dev->bytes_sent));
51483 + atomic_read_unchecked(&dev->bytes_sent));
51484 }
51485
51486 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51487 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51488 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51489 struct dlfb_data *dev = fb_info->par;
51490 return snprintf(buf, PAGE_SIZE, "%u\n",
51491 - atomic_read(&dev->cpu_kcycles_used));
51492 + atomic_read_unchecked(&dev->cpu_kcycles_used));
51493 }
51494
51495 static ssize_t edid_show(
51496 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
51497 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51498 struct dlfb_data *dev = fb_info->par;
51499
51500 - atomic_set(&dev->bytes_rendered, 0);
51501 - atomic_set(&dev->bytes_identical, 0);
51502 - atomic_set(&dev->bytes_sent, 0);
51503 - atomic_set(&dev->cpu_kcycles_used, 0);
51504 + atomic_set_unchecked(&dev->bytes_rendered, 0);
51505 + atomic_set_unchecked(&dev->bytes_identical, 0);
51506 + atomic_set_unchecked(&dev->bytes_sent, 0);
51507 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
51508
51509 return count;
51510 }
51511 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
51512 index 7aec6f3..e3b2d55 100644
51513 --- a/drivers/video/uvesafb.c
51514 +++ b/drivers/video/uvesafb.c
51515 @@ -19,6 +19,7 @@
51516 #include <linux/io.h>
51517 #include <linux/mutex.h>
51518 #include <linux/slab.h>
51519 +#include <linux/moduleloader.h>
51520 #include <video/edid.h>
51521 #include <video/uvesafb.h>
51522 #ifdef CONFIG_X86
51523 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
51524 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
51525 par->pmi_setpal = par->ypan = 0;
51526 } else {
51527 +
51528 +#ifdef CONFIG_PAX_KERNEXEC
51529 +#ifdef CONFIG_MODULES
51530 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
51531 +#endif
51532 + if (!par->pmi_code) {
51533 + par->pmi_setpal = par->ypan = 0;
51534 + return 0;
51535 + }
51536 +#endif
51537 +
51538 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
51539 + task->t.regs.edi);
51540 +
51541 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51542 + pax_open_kernel();
51543 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
51544 + pax_close_kernel();
51545 +
51546 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
51547 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
51548 +#else
51549 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
51550 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
51551 +#endif
51552 +
51553 printk(KERN_INFO "uvesafb: protected mode interface info at "
51554 "%04x:%04x\n",
51555 (u16)task->t.regs.es, (u16)task->t.regs.edi);
51556 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
51557 par->ypan = ypan;
51558
51559 if (par->pmi_setpal || par->ypan) {
51560 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
51561 if (__supported_pte_mask & _PAGE_NX) {
51562 par->pmi_setpal = par->ypan = 0;
51563 printk(KERN_WARNING "uvesafb: NX protection is active, "
51564 "better not use the PMI.\n");
51565 - } else {
51566 + } else
51567 +#endif
51568 uvesafb_vbe_getpmi(task, par);
51569 - }
51570 }
51571 #else
51572 /* The protected mode interface is not available on non-x86. */
51573 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51574 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
51575
51576 /* Disable blanking if the user requested so. */
51577 - if (!blank)
51578 - info->fbops->fb_blank = NULL;
51579 + if (!blank) {
51580 + pax_open_kernel();
51581 + *(void **)&info->fbops->fb_blank = NULL;
51582 + pax_close_kernel();
51583 + }
51584
51585 /*
51586 * Find out how much IO memory is required for the mode with
51587 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51588 info->flags = FBINFO_FLAG_DEFAULT |
51589 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
51590
51591 - if (!par->ypan)
51592 - info->fbops->fb_pan_display = NULL;
51593 + if (!par->ypan) {
51594 + pax_open_kernel();
51595 + *(void **)&info->fbops->fb_pan_display = NULL;
51596 + pax_close_kernel();
51597 + }
51598 }
51599
51600 static void uvesafb_init_mtrr(struct fb_info *info)
51601 @@ -1796,6 +1826,11 @@ out:
51602 if (par->vbe_modes)
51603 kfree(par->vbe_modes);
51604
51605 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51606 + if (par->pmi_code)
51607 + module_free_exec(NULL, par->pmi_code);
51608 +#endif
51609 +
51610 framebuffer_release(info);
51611 return err;
51612 }
51613 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
51614 kfree(par->vbe_state_orig);
51615 if (par->vbe_state_saved)
51616 kfree(par->vbe_state_saved);
51617 +
51618 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51619 + if (par->pmi_code)
51620 + module_free_exec(NULL, par->pmi_code);
51621 +#endif
51622 +
51623 }
51624
51625 framebuffer_release(info);
51626 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
51627 index 501b340..d80aa17 100644
51628 --- a/drivers/video/vesafb.c
51629 +++ b/drivers/video/vesafb.c
51630 @@ -9,6 +9,7 @@
51631 */
51632
51633 #include <linux/module.h>
51634 +#include <linux/moduleloader.h>
51635 #include <linux/kernel.h>
51636 #include <linux/errno.h>
51637 #include <linux/string.h>
51638 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
51639 static int vram_total __initdata; /* Set total amount of memory */
51640 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
51641 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
51642 -static void (*pmi_start)(void) __read_mostly;
51643 -static void (*pmi_pal) (void) __read_mostly;
51644 +static void (*pmi_start)(void) __read_only;
51645 +static void (*pmi_pal) (void) __read_only;
51646 static int depth __read_mostly;
51647 static int vga_compat __read_mostly;
51648 /* --------------------------------------------------------------------- */
51649 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
51650 unsigned int size_vmode;
51651 unsigned int size_remap;
51652 unsigned int size_total;
51653 + void *pmi_code = NULL;
51654
51655 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
51656 return -ENODEV;
51657 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
51658 size_remap = size_total;
51659 vesafb_fix.smem_len = size_remap;
51660
51661 -#ifndef __i386__
51662 - screen_info.vesapm_seg = 0;
51663 -#endif
51664 -
51665 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
51666 printk(KERN_WARNING
51667 "vesafb: cannot reserve video memory at 0x%lx\n",
51668 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
51669 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
51670 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
51671
51672 +#ifdef __i386__
51673 +
51674 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51675 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
51676 + if (!pmi_code)
51677 +#elif !defined(CONFIG_PAX_KERNEXEC)
51678 + if (0)
51679 +#endif
51680 +
51681 +#endif
51682 + screen_info.vesapm_seg = 0;
51683 +
51684 if (screen_info.vesapm_seg) {
51685 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
51686 - screen_info.vesapm_seg,screen_info.vesapm_off);
51687 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
51688 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
51689 }
51690
51691 if (screen_info.vesapm_seg < 0xc000)
51692 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
51693
51694 if (ypan || pmi_setpal) {
51695 unsigned short *pmi_base;
51696 +
51697 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
51698 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
51699 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
51700 +
51701 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51702 + pax_open_kernel();
51703 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
51704 +#else
51705 + pmi_code = pmi_base;
51706 +#endif
51707 +
51708 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
51709 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
51710 +
51711 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51712 + pmi_start = ktva_ktla(pmi_start);
51713 + pmi_pal = ktva_ktla(pmi_pal);
51714 + pax_close_kernel();
51715 +#endif
51716 +
51717 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
51718 if (pmi_base[3]) {
51719 printk(KERN_INFO "vesafb: pmi: ports = ");
51720 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
51721 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
51722 (ypan ? FBINFO_HWACCEL_YPAN : 0);
51723
51724 - if (!ypan)
51725 - info->fbops->fb_pan_display = NULL;
51726 + if (!ypan) {
51727 + pax_open_kernel();
51728 + *(void **)&info->fbops->fb_pan_display = NULL;
51729 + pax_close_kernel();
51730 + }
51731
51732 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
51733 err = -ENOMEM;
51734 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
51735 info->node, info->fix.id);
51736 return 0;
51737 err:
51738 +
51739 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51740 + module_free_exec(NULL, pmi_code);
51741 +#endif
51742 +
51743 if (info->screen_base)
51744 iounmap(info->screen_base);
51745 framebuffer_release(info);
51746 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
51747 index 88714ae..16c2e11 100644
51748 --- a/drivers/video/via/via_clock.h
51749 +++ b/drivers/video/via/via_clock.h
51750 @@ -56,7 +56,7 @@ struct via_clock {
51751
51752 void (*set_engine_pll_state)(u8 state);
51753 void (*set_engine_pll)(struct via_pll_config config);
51754 -};
51755 +} __no_const;
51756
51757
51758 static inline u32 get_pll_internal_frequency(u32 ref_freq,
51759 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
51760 index fef20db..d28b1ab 100644
51761 --- a/drivers/xen/xenfs/xenstored.c
51762 +++ b/drivers/xen/xenfs/xenstored.c
51763 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
51764 static int xsd_kva_open(struct inode *inode, struct file *file)
51765 {
51766 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
51767 +#ifdef CONFIG_GRKERNSEC_HIDESYM
51768 + NULL);
51769 +#else
51770 xen_store_interface);
51771 +#endif
51772 +
51773 if (!file->private_data)
51774 return -ENOMEM;
51775 return 0;
51776 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
51777 index 9ff073f..05cef23 100644
51778 --- a/fs/9p/vfs_addr.c
51779 +++ b/fs/9p/vfs_addr.c
51780 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
51781
51782 retval = v9fs_file_write_internal(inode,
51783 v9inode->writeback_fid,
51784 - (__force const char __user *)buffer,
51785 + (const char __force_user *)buffer,
51786 len, &offset, 0);
51787 if (retval > 0)
51788 retval = 0;
51789 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
51790 index 25b018e..b941525 100644
51791 --- a/fs/9p/vfs_inode.c
51792 +++ b/fs/9p/vfs_inode.c
51793 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
51794 void
51795 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
51796 {
51797 - char *s = nd_get_link(nd);
51798 + const char *s = nd_get_link(nd);
51799
51800 p9_debug(P9_DEBUG_VFS, " %s %s\n",
51801 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
51802 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
51803 index 370b24c..ff0be7b 100644
51804 --- a/fs/Kconfig.binfmt
51805 +++ b/fs/Kconfig.binfmt
51806 @@ -103,7 +103,7 @@ config HAVE_AOUT
51807
51808 config BINFMT_AOUT
51809 tristate "Kernel support for a.out and ECOFF binaries"
51810 - depends on HAVE_AOUT
51811 + depends on HAVE_AOUT && BROKEN
51812 ---help---
51813 A.out (Assembler.OUTput) is a set of formats for libraries and
51814 executables used in the earliest versions of UNIX. Linux used
51815 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
51816 index 789bc25..fafaeea 100644
51817 --- a/fs/afs/inode.c
51818 +++ b/fs/afs/inode.c
51819 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
51820 struct afs_vnode *vnode;
51821 struct super_block *sb;
51822 struct inode *inode;
51823 - static atomic_t afs_autocell_ino;
51824 + static atomic_unchecked_t afs_autocell_ino;
51825
51826 _enter("{%x:%u},%*.*s,",
51827 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
51828 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
51829 data.fid.unique = 0;
51830 data.fid.vnode = 0;
51831
51832 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
51833 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
51834 afs_iget5_autocell_test, afs_iget5_set,
51835 &data);
51836 if (!inode) {
51837 diff --git a/fs/aio.c b/fs/aio.c
51838 index 9b5ca11..c530886 100644
51839 --- a/fs/aio.c
51840 +++ b/fs/aio.c
51841 @@ -162,7 +162,7 @@ static int aio_setup_ring(struct kioctx *ctx)
51842 size += sizeof(struct io_event) * nr_events;
51843 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
51844
51845 - if (nr_pages < 0)
51846 + if (nr_pages <= 0)
51847 return -EINVAL;
51848
51849 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
51850 @@ -952,6 +952,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
51851 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
51852 {
51853 ssize_t ret;
51854 + struct iovec iovstack;
51855
51856 kiocb->ki_nr_segs = kiocb->ki_nbytes;
51857
51858 @@ -959,17 +960,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
51859 if (compat)
51860 ret = compat_rw_copy_check_uvector(rw,
51861 (struct compat_iovec __user *)kiocb->ki_buf,
51862 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
51863 + kiocb->ki_nr_segs, 1, &iovstack,
51864 &kiocb->ki_iovec);
51865 else
51866 #endif
51867 ret = rw_copy_check_uvector(rw,
51868 (struct iovec __user *)kiocb->ki_buf,
51869 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
51870 + kiocb->ki_nr_segs, 1, &iovstack,
51871 &kiocb->ki_iovec);
51872 if (ret < 0)
51873 return ret;
51874
51875 + if (kiocb->ki_iovec == &iovstack) {
51876 + kiocb->ki_inline_vec = iovstack;
51877 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
51878 + }
51879 +
51880 /* ki_nbytes now reflect bytes instead of segs */
51881 kiocb->ki_nbytes = ret;
51882 return 0;
51883 diff --git a/fs/attr.c b/fs/attr.c
51884 index 1449adb..a2038c2 100644
51885 --- a/fs/attr.c
51886 +++ b/fs/attr.c
51887 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
51888 unsigned long limit;
51889
51890 limit = rlimit(RLIMIT_FSIZE);
51891 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
51892 if (limit != RLIM_INFINITY && offset > limit)
51893 goto out_sig;
51894 if (offset > inode->i_sb->s_maxbytes)
51895 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
51896 index 3db70da..7aeec5b 100644
51897 --- a/fs/autofs4/waitq.c
51898 +++ b/fs/autofs4/waitq.c
51899 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
51900 {
51901 unsigned long sigpipe, flags;
51902 mm_segment_t fs;
51903 - const char *data = (const char *)addr;
51904 + const char __user *data = (const char __force_user *)addr;
51905 ssize_t wr = 0;
51906
51907 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
51908 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
51909 return 1;
51910 }
51911
51912 +#ifdef CONFIG_GRKERNSEC_HIDESYM
51913 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
51914 +#endif
51915 +
51916 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
51917 enum autofs_notify notify)
51918 {
51919 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
51920
51921 /* If this is a direct mount request create a dummy name */
51922 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
51923 +#ifdef CONFIG_GRKERNSEC_HIDESYM
51924 + /* this name does get written to userland via autofs4_write() */
51925 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
51926 +#else
51927 qstr.len = sprintf(name, "%p", dentry);
51928 +#endif
51929 else {
51930 qstr.len = autofs4_getpath(sbi, dentry, &name);
51931 if (!qstr.len) {
51932 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
51933 index 2722387..c8dd2a7 100644
51934 --- a/fs/befs/endian.h
51935 +++ b/fs/befs/endian.h
51936 @@ -11,7 +11,7 @@
51937
51938 #include <asm/byteorder.h>
51939
51940 -static inline u64
51941 +static inline u64 __intentional_overflow(-1)
51942 fs64_to_cpu(const struct super_block *sb, fs64 n)
51943 {
51944 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
51945 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
51946 return (__force fs64)cpu_to_be64(n);
51947 }
51948
51949 -static inline u32
51950 +static inline u32 __intentional_overflow(-1)
51951 fs32_to_cpu(const struct super_block *sb, fs32 n)
51952 {
51953 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
51954 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
51955 index e9c75e2..1baece1 100644
51956 --- a/fs/befs/linuxvfs.c
51957 +++ b/fs/befs/linuxvfs.c
51958 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
51959 {
51960 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
51961 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
51962 - char *link = nd_get_link(nd);
51963 + const char *link = nd_get_link(nd);
51964 if (!IS_ERR(link))
51965 kfree(link);
51966 }
51967 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
51968 index 89dec7f..361b0d75 100644
51969 --- a/fs/binfmt_aout.c
51970 +++ b/fs/binfmt_aout.c
51971 @@ -16,6 +16,7 @@
51972 #include <linux/string.h>
51973 #include <linux/fs.h>
51974 #include <linux/file.h>
51975 +#include <linux/security.h>
51976 #include <linux/stat.h>
51977 #include <linux/fcntl.h>
51978 #include <linux/ptrace.h>
51979 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
51980 #endif
51981 # define START_STACK(u) ((void __user *)u.start_stack)
51982
51983 + memset(&dump, 0, sizeof(dump));
51984 +
51985 fs = get_fs();
51986 set_fs(KERNEL_DS);
51987 has_dumped = 1;
51988 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
51989
51990 /* If the size of the dump file exceeds the rlimit, then see what would happen
51991 if we wrote the stack, but not the data area. */
51992 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
51993 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
51994 dump.u_dsize = 0;
51995
51996 /* Make sure we have enough room to write the stack and data areas. */
51997 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
51998 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
51999 dump.u_ssize = 0;
52000
52001 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52002 rlim = rlimit(RLIMIT_DATA);
52003 if (rlim >= RLIM_INFINITY)
52004 rlim = ~0;
52005 +
52006 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52007 if (ex.a_data + ex.a_bss > rlim)
52008 return -ENOMEM;
52009
52010 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52011
52012 install_exec_creds(bprm);
52013
52014 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52015 + current->mm->pax_flags = 0UL;
52016 +#endif
52017 +
52018 +#ifdef CONFIG_PAX_PAGEEXEC
52019 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52020 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52021 +
52022 +#ifdef CONFIG_PAX_EMUTRAMP
52023 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52024 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52025 +#endif
52026 +
52027 +#ifdef CONFIG_PAX_MPROTECT
52028 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52029 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52030 +#endif
52031 +
52032 + }
52033 +#endif
52034 +
52035 if (N_MAGIC(ex) == OMAGIC) {
52036 unsigned long text_addr, map_size;
52037 loff_t pos;
52038 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52039 }
52040
52041 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52042 - PROT_READ | PROT_WRITE | PROT_EXEC,
52043 + PROT_READ | PROT_WRITE,
52044 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52045 fd_offset + ex.a_text);
52046 if (error != N_DATADDR(ex)) {
52047 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52048 index 100edcc..244db37 100644
52049 --- a/fs/binfmt_elf.c
52050 +++ b/fs/binfmt_elf.c
52051 @@ -34,6 +34,7 @@
52052 #include <linux/utsname.h>
52053 #include <linux/coredump.h>
52054 #include <linux/sched.h>
52055 +#include <linux/xattr.h>
52056 #include <asm/uaccess.h>
52057 #include <asm/param.h>
52058 #include <asm/page.h>
52059 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52060 #define elf_core_dump NULL
52061 #endif
52062
52063 +#ifdef CONFIG_PAX_MPROTECT
52064 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52065 +#endif
52066 +
52067 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52068 +static void elf_handle_mmap(struct file *file);
52069 +#endif
52070 +
52071 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52072 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52073 #else
52074 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52075 .load_binary = load_elf_binary,
52076 .load_shlib = load_elf_library,
52077 .core_dump = elf_core_dump,
52078 +
52079 +#ifdef CONFIG_PAX_MPROTECT
52080 + .handle_mprotect= elf_handle_mprotect,
52081 +#endif
52082 +
52083 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52084 + .handle_mmap = elf_handle_mmap,
52085 +#endif
52086 +
52087 .min_coredump = ELF_EXEC_PAGESIZE,
52088 };
52089
52090 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52091
52092 static int set_brk(unsigned long start, unsigned long end)
52093 {
52094 + unsigned long e = end;
52095 +
52096 start = ELF_PAGEALIGN(start);
52097 end = ELF_PAGEALIGN(end);
52098 if (end > start) {
52099 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52100 if (BAD_ADDR(addr))
52101 return addr;
52102 }
52103 - current->mm->start_brk = current->mm->brk = end;
52104 + current->mm->start_brk = current->mm->brk = e;
52105 return 0;
52106 }
52107
52108 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52109 elf_addr_t __user *u_rand_bytes;
52110 const char *k_platform = ELF_PLATFORM;
52111 const char *k_base_platform = ELF_BASE_PLATFORM;
52112 - unsigned char k_rand_bytes[16];
52113 + u32 k_rand_bytes[4];
52114 int items;
52115 elf_addr_t *elf_info;
52116 int ei_index = 0;
52117 const struct cred *cred = current_cred();
52118 struct vm_area_struct *vma;
52119 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52120
52121 /*
52122 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52123 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52124 * Generate 16 random bytes for userspace PRNG seeding.
52125 */
52126 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52127 - u_rand_bytes = (elf_addr_t __user *)
52128 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52129 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52130 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52131 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52132 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52133 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52134 + u_rand_bytes = (elf_addr_t __user *) p;
52135 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52136 return -EFAULT;
52137
52138 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52139 return -EFAULT;
52140 current->mm->env_end = p;
52141
52142 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52143 +
52144 /* Put the elf_info on the stack in the right place. */
52145 sp = (elf_addr_t __user *)envp + 1;
52146 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52147 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52148 return -EFAULT;
52149 return 0;
52150 }
52151 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52152 an ELF header */
52153
52154 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52155 - struct file *interpreter, unsigned long *interp_map_addr,
52156 - unsigned long no_base)
52157 + struct file *interpreter, unsigned long no_base)
52158 {
52159 struct elf_phdr *elf_phdata;
52160 struct elf_phdr *eppnt;
52161 - unsigned long load_addr = 0;
52162 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52163 int load_addr_set = 0;
52164 unsigned long last_bss = 0, elf_bss = 0;
52165 - unsigned long error = ~0UL;
52166 + unsigned long error = -EINVAL;
52167 unsigned long total_size;
52168 int retval, i, size;
52169
52170 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52171 goto out_close;
52172 }
52173
52174 +#ifdef CONFIG_PAX_SEGMEXEC
52175 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52176 + pax_task_size = SEGMEXEC_TASK_SIZE;
52177 +#endif
52178 +
52179 eppnt = elf_phdata;
52180 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52181 if (eppnt->p_type == PT_LOAD) {
52182 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52183 map_addr = elf_map(interpreter, load_addr + vaddr,
52184 eppnt, elf_prot, elf_type, total_size);
52185 total_size = 0;
52186 - if (!*interp_map_addr)
52187 - *interp_map_addr = map_addr;
52188 error = map_addr;
52189 if (BAD_ADDR(map_addr))
52190 goto out_close;
52191 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52192 k = load_addr + eppnt->p_vaddr;
52193 if (BAD_ADDR(k) ||
52194 eppnt->p_filesz > eppnt->p_memsz ||
52195 - eppnt->p_memsz > TASK_SIZE ||
52196 - TASK_SIZE - eppnt->p_memsz < k) {
52197 + eppnt->p_memsz > pax_task_size ||
52198 + pax_task_size - eppnt->p_memsz < k) {
52199 error = -ENOMEM;
52200 goto out_close;
52201 }
52202 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52203 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
52204
52205 /* Map the last of the bss segment */
52206 - error = vm_brk(elf_bss, last_bss - elf_bss);
52207 - if (BAD_ADDR(error))
52208 - goto out_close;
52209 + if (last_bss > elf_bss) {
52210 + error = vm_brk(elf_bss, last_bss - elf_bss);
52211 + if (BAD_ADDR(error))
52212 + goto out_close;
52213 + }
52214 }
52215
52216 error = load_addr;
52217 @@ -538,6 +569,315 @@ out:
52218 return error;
52219 }
52220
52221 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52222 +#ifdef CONFIG_PAX_SOFTMODE
52223 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52224 +{
52225 + unsigned long pax_flags = 0UL;
52226 +
52227 +#ifdef CONFIG_PAX_PAGEEXEC
52228 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52229 + pax_flags |= MF_PAX_PAGEEXEC;
52230 +#endif
52231 +
52232 +#ifdef CONFIG_PAX_SEGMEXEC
52233 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52234 + pax_flags |= MF_PAX_SEGMEXEC;
52235 +#endif
52236 +
52237 +#ifdef CONFIG_PAX_EMUTRAMP
52238 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52239 + pax_flags |= MF_PAX_EMUTRAMP;
52240 +#endif
52241 +
52242 +#ifdef CONFIG_PAX_MPROTECT
52243 + if (elf_phdata->p_flags & PF_MPROTECT)
52244 + pax_flags |= MF_PAX_MPROTECT;
52245 +#endif
52246 +
52247 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52248 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52249 + pax_flags |= MF_PAX_RANDMMAP;
52250 +#endif
52251 +
52252 + return pax_flags;
52253 +}
52254 +#endif
52255 +
52256 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52257 +{
52258 + unsigned long pax_flags = 0UL;
52259 +
52260 +#ifdef CONFIG_PAX_PAGEEXEC
52261 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52262 + pax_flags |= MF_PAX_PAGEEXEC;
52263 +#endif
52264 +
52265 +#ifdef CONFIG_PAX_SEGMEXEC
52266 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52267 + pax_flags |= MF_PAX_SEGMEXEC;
52268 +#endif
52269 +
52270 +#ifdef CONFIG_PAX_EMUTRAMP
52271 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52272 + pax_flags |= MF_PAX_EMUTRAMP;
52273 +#endif
52274 +
52275 +#ifdef CONFIG_PAX_MPROTECT
52276 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
52277 + pax_flags |= MF_PAX_MPROTECT;
52278 +#endif
52279 +
52280 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52281 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
52282 + pax_flags |= MF_PAX_RANDMMAP;
52283 +#endif
52284 +
52285 + return pax_flags;
52286 +}
52287 +#endif
52288 +
52289 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52290 +#ifdef CONFIG_PAX_SOFTMODE
52291 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
52292 +{
52293 + unsigned long pax_flags = 0UL;
52294 +
52295 +#ifdef CONFIG_PAX_PAGEEXEC
52296 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
52297 + pax_flags |= MF_PAX_PAGEEXEC;
52298 +#endif
52299 +
52300 +#ifdef CONFIG_PAX_SEGMEXEC
52301 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
52302 + pax_flags |= MF_PAX_SEGMEXEC;
52303 +#endif
52304 +
52305 +#ifdef CONFIG_PAX_EMUTRAMP
52306 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52307 + pax_flags |= MF_PAX_EMUTRAMP;
52308 +#endif
52309 +
52310 +#ifdef CONFIG_PAX_MPROTECT
52311 + if (pax_flags_softmode & MF_PAX_MPROTECT)
52312 + pax_flags |= MF_PAX_MPROTECT;
52313 +#endif
52314 +
52315 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52316 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
52317 + pax_flags |= MF_PAX_RANDMMAP;
52318 +#endif
52319 +
52320 + return pax_flags;
52321 +}
52322 +#endif
52323 +
52324 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
52325 +{
52326 + unsigned long pax_flags = 0UL;
52327 +
52328 +#ifdef CONFIG_PAX_PAGEEXEC
52329 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
52330 + pax_flags |= MF_PAX_PAGEEXEC;
52331 +#endif
52332 +
52333 +#ifdef CONFIG_PAX_SEGMEXEC
52334 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
52335 + pax_flags |= MF_PAX_SEGMEXEC;
52336 +#endif
52337 +
52338 +#ifdef CONFIG_PAX_EMUTRAMP
52339 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
52340 + pax_flags |= MF_PAX_EMUTRAMP;
52341 +#endif
52342 +
52343 +#ifdef CONFIG_PAX_MPROTECT
52344 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
52345 + pax_flags |= MF_PAX_MPROTECT;
52346 +#endif
52347 +
52348 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52349 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
52350 + pax_flags |= MF_PAX_RANDMMAP;
52351 +#endif
52352 +
52353 + return pax_flags;
52354 +}
52355 +#endif
52356 +
52357 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52358 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
52359 +{
52360 + unsigned long pax_flags = 0UL;
52361 +
52362 +#ifdef CONFIG_PAX_EI_PAX
52363 +
52364 +#ifdef CONFIG_PAX_PAGEEXEC
52365 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
52366 + pax_flags |= MF_PAX_PAGEEXEC;
52367 +#endif
52368 +
52369 +#ifdef CONFIG_PAX_SEGMEXEC
52370 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
52371 + pax_flags |= MF_PAX_SEGMEXEC;
52372 +#endif
52373 +
52374 +#ifdef CONFIG_PAX_EMUTRAMP
52375 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
52376 + pax_flags |= MF_PAX_EMUTRAMP;
52377 +#endif
52378 +
52379 +#ifdef CONFIG_PAX_MPROTECT
52380 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
52381 + pax_flags |= MF_PAX_MPROTECT;
52382 +#endif
52383 +
52384 +#ifdef CONFIG_PAX_ASLR
52385 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
52386 + pax_flags |= MF_PAX_RANDMMAP;
52387 +#endif
52388 +
52389 +#else
52390 +
52391 +#ifdef CONFIG_PAX_PAGEEXEC
52392 + pax_flags |= MF_PAX_PAGEEXEC;
52393 +#endif
52394 +
52395 +#ifdef CONFIG_PAX_SEGMEXEC
52396 + pax_flags |= MF_PAX_SEGMEXEC;
52397 +#endif
52398 +
52399 +#ifdef CONFIG_PAX_MPROTECT
52400 + pax_flags |= MF_PAX_MPROTECT;
52401 +#endif
52402 +
52403 +#ifdef CONFIG_PAX_RANDMMAP
52404 + if (randomize_va_space)
52405 + pax_flags |= MF_PAX_RANDMMAP;
52406 +#endif
52407 +
52408 +#endif
52409 +
52410 + return pax_flags;
52411 +}
52412 +
52413 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
52414 +{
52415 +
52416 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52417 + unsigned long i;
52418 +
52419 + for (i = 0UL; i < elf_ex->e_phnum; i++)
52420 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
52421 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
52422 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
52423 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
52424 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
52425 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
52426 + return ~0UL;
52427 +
52428 +#ifdef CONFIG_PAX_SOFTMODE
52429 + if (pax_softmode)
52430 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
52431 + else
52432 +#endif
52433 +
52434 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
52435 + break;
52436 + }
52437 +#endif
52438 +
52439 + return ~0UL;
52440 +}
52441 +
52442 +static unsigned long pax_parse_xattr_pax(struct file * const file)
52443 +{
52444 +
52445 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52446 + ssize_t xattr_size, i;
52447 + unsigned char xattr_value[sizeof("pemrs") - 1];
52448 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
52449 +
52450 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
52451 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
52452 + return ~0UL;
52453 +
52454 + for (i = 0; i < xattr_size; i++)
52455 + switch (xattr_value[i]) {
52456 + default:
52457 + return ~0UL;
52458 +
52459 +#define parse_flag(option1, option2, flag) \
52460 + case option1: \
52461 + if (pax_flags_hardmode & MF_PAX_##flag) \
52462 + return ~0UL; \
52463 + pax_flags_hardmode |= MF_PAX_##flag; \
52464 + break; \
52465 + case option2: \
52466 + if (pax_flags_softmode & MF_PAX_##flag) \
52467 + return ~0UL; \
52468 + pax_flags_softmode |= MF_PAX_##flag; \
52469 + break;
52470 +
52471 + parse_flag('p', 'P', PAGEEXEC);
52472 + parse_flag('e', 'E', EMUTRAMP);
52473 + parse_flag('m', 'M', MPROTECT);
52474 + parse_flag('r', 'R', RANDMMAP);
52475 + parse_flag('s', 'S', SEGMEXEC);
52476 +
52477 +#undef parse_flag
52478 + }
52479 +
52480 + if (pax_flags_hardmode & pax_flags_softmode)
52481 + return ~0UL;
52482 +
52483 +#ifdef CONFIG_PAX_SOFTMODE
52484 + if (pax_softmode)
52485 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
52486 + else
52487 +#endif
52488 +
52489 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
52490 +#else
52491 + return ~0UL;
52492 +#endif
52493 +
52494 +}
52495 +
52496 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
52497 +{
52498 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
52499 +
52500 + pax_flags = pax_parse_ei_pax(elf_ex);
52501 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
52502 + xattr_pax_flags = pax_parse_xattr_pax(file);
52503 +
52504 + if (pt_pax_flags == ~0UL)
52505 + pt_pax_flags = xattr_pax_flags;
52506 + else if (xattr_pax_flags == ~0UL)
52507 + xattr_pax_flags = pt_pax_flags;
52508 + if (pt_pax_flags != xattr_pax_flags)
52509 + return -EINVAL;
52510 + if (pt_pax_flags != ~0UL)
52511 + pax_flags = pt_pax_flags;
52512 +
52513 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
52514 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52515 + if ((__supported_pte_mask & _PAGE_NX))
52516 + pax_flags &= ~MF_PAX_SEGMEXEC;
52517 + else
52518 + pax_flags &= ~MF_PAX_PAGEEXEC;
52519 + }
52520 +#endif
52521 +
52522 + if (0 > pax_check_flags(&pax_flags))
52523 + return -EINVAL;
52524 +
52525 + current->mm->pax_flags = pax_flags;
52526 + return 0;
52527 +}
52528 +#endif
52529 +
52530 /*
52531 * These are the functions used to load ELF style executables and shared
52532 * libraries. There is no binary dependent code anywhere else.
52533 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
52534 {
52535 unsigned int random_variable = 0;
52536
52537 +#ifdef CONFIG_PAX_RANDUSTACK
52538 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
52539 + return stack_top - current->mm->delta_stack;
52540 +#endif
52541 +
52542 if ((current->flags & PF_RANDOMIZE) &&
52543 !(current->personality & ADDR_NO_RANDOMIZE)) {
52544 random_variable = get_random_int() & STACK_RND_MASK;
52545 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
52546 unsigned long load_addr = 0, load_bias = 0;
52547 int load_addr_set = 0;
52548 char * elf_interpreter = NULL;
52549 - unsigned long error;
52550 + unsigned long error = 0;
52551 struct elf_phdr *elf_ppnt, *elf_phdata;
52552 unsigned long elf_bss, elf_brk;
52553 int retval, i;
52554 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
52555 unsigned long start_code, end_code, start_data, end_data;
52556 unsigned long reloc_func_desc __maybe_unused = 0;
52557 int executable_stack = EXSTACK_DEFAULT;
52558 - unsigned long def_flags = 0;
52559 struct pt_regs *regs = current_pt_regs();
52560 struct {
52561 struct elfhdr elf_ex;
52562 struct elfhdr interp_elf_ex;
52563 } *loc;
52564 + unsigned long pax_task_size = TASK_SIZE;
52565
52566 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
52567 if (!loc) {
52568 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
52569 goto out_free_dentry;
52570
52571 /* OK, This is the point of no return */
52572 - current->mm->def_flags = def_flags;
52573 +
52574 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52575 + current->mm->pax_flags = 0UL;
52576 +#endif
52577 +
52578 +#ifdef CONFIG_PAX_DLRESOLVE
52579 + current->mm->call_dl_resolve = 0UL;
52580 +#endif
52581 +
52582 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
52583 + current->mm->call_syscall = 0UL;
52584 +#endif
52585 +
52586 +#ifdef CONFIG_PAX_ASLR
52587 + current->mm->delta_mmap = 0UL;
52588 + current->mm->delta_stack = 0UL;
52589 +#endif
52590 +
52591 + current->mm->def_flags = 0;
52592 +
52593 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52594 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
52595 + send_sig(SIGKILL, current, 0);
52596 + goto out_free_dentry;
52597 + }
52598 +#endif
52599 +
52600 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
52601 + pax_set_initial_flags(bprm);
52602 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
52603 + if (pax_set_initial_flags_func)
52604 + (pax_set_initial_flags_func)(bprm);
52605 +#endif
52606 +
52607 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
52608 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
52609 + current->mm->context.user_cs_limit = PAGE_SIZE;
52610 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
52611 + }
52612 +#endif
52613 +
52614 +#ifdef CONFIG_PAX_SEGMEXEC
52615 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
52616 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
52617 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
52618 + pax_task_size = SEGMEXEC_TASK_SIZE;
52619 + current->mm->def_flags |= VM_NOHUGEPAGE;
52620 + }
52621 +#endif
52622 +
52623 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
52624 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52625 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
52626 + put_cpu();
52627 + }
52628 +#endif
52629
52630 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
52631 may depend on the personality. */
52632 SET_PERSONALITY(loc->elf_ex);
52633 +
52634 +#ifdef CONFIG_PAX_ASLR
52635 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52636 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
52637 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
52638 + }
52639 +#endif
52640 +
52641 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
52642 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52643 + executable_stack = EXSTACK_DISABLE_X;
52644 + current->personality &= ~READ_IMPLIES_EXEC;
52645 + } else
52646 +#endif
52647 +
52648 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
52649 current->personality |= READ_IMPLIES_EXEC;
52650
52651 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
52652 #else
52653 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
52654 #endif
52655 +
52656 +#ifdef CONFIG_PAX_RANDMMAP
52657 + /* PaX: randomize base address at the default exe base if requested */
52658 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
52659 +#ifdef CONFIG_SPARC64
52660 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
52661 +#else
52662 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
52663 +#endif
52664 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
52665 + elf_flags |= MAP_FIXED;
52666 + }
52667 +#endif
52668 +
52669 }
52670
52671 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
52672 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
52673 * allowed task size. Note that p_filesz must always be
52674 * <= p_memsz so it is only necessary to check p_memsz.
52675 */
52676 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52677 - elf_ppnt->p_memsz > TASK_SIZE ||
52678 - TASK_SIZE - elf_ppnt->p_memsz < k) {
52679 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
52680 + elf_ppnt->p_memsz > pax_task_size ||
52681 + pax_task_size - elf_ppnt->p_memsz < k) {
52682 /* set_brk can never work. Avoid overflows. */
52683 send_sig(SIGKILL, current, 0);
52684 retval = -EINVAL;
52685 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
52686 goto out_free_dentry;
52687 }
52688 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
52689 - send_sig(SIGSEGV, current, 0);
52690 - retval = -EFAULT; /* Nobody gets to see this, but.. */
52691 - goto out_free_dentry;
52692 + /*
52693 + * This bss-zeroing can fail if the ELF
52694 + * file specifies odd protections. So
52695 + * we don't check the return value
52696 + */
52697 }
52698
52699 +#ifdef CONFIG_PAX_RANDMMAP
52700 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
52701 + unsigned long start, size, flags;
52702 + vm_flags_t vm_flags;
52703 +
52704 + start = ELF_PAGEALIGN(elf_brk);
52705 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
52706 + flags = MAP_FIXED | MAP_PRIVATE;
52707 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
52708 +
52709 + down_write(&current->mm->mmap_sem);
52710 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
52711 + retval = -ENOMEM;
52712 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
52713 +// if (current->personality & ADDR_NO_RANDOMIZE)
52714 +// vm_flags |= VM_READ | VM_MAYREAD;
52715 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
52716 + retval = IS_ERR_VALUE(start) ? start : 0;
52717 + }
52718 + up_write(&current->mm->mmap_sem);
52719 + if (retval == 0)
52720 + retval = set_brk(start + size, start + size + PAGE_SIZE);
52721 + if (retval < 0) {
52722 + send_sig(SIGKILL, current, 0);
52723 + goto out_free_dentry;
52724 + }
52725 + }
52726 +#endif
52727 +
52728 if (elf_interpreter) {
52729 - unsigned long interp_map_addr = 0;
52730 -
52731 elf_entry = load_elf_interp(&loc->interp_elf_ex,
52732 interpreter,
52733 - &interp_map_addr,
52734 load_bias);
52735 if (!IS_ERR((void *)elf_entry)) {
52736 /*
52737 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
52738 * Decide what to dump of a segment, part, all or none.
52739 */
52740 static unsigned long vma_dump_size(struct vm_area_struct *vma,
52741 - unsigned long mm_flags)
52742 + unsigned long mm_flags, long signr)
52743 {
52744 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
52745
52746 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
52747 if (vma->vm_file == NULL)
52748 return 0;
52749
52750 - if (FILTER(MAPPED_PRIVATE))
52751 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
52752 goto whole;
52753
52754 /*
52755 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
52756 {
52757 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
52758 int i = 0;
52759 - do
52760 + do {
52761 i += 2;
52762 - while (auxv[i - 2] != AT_NULL);
52763 + } while (auxv[i - 2] != AT_NULL);
52764 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
52765 }
52766
52767 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
52768 {
52769 mm_segment_t old_fs = get_fs();
52770 set_fs(KERNEL_DS);
52771 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
52772 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
52773 set_fs(old_fs);
52774 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
52775 }
52776 @@ -2017,14 +2474,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
52777 }
52778
52779 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
52780 - unsigned long mm_flags)
52781 + struct coredump_params *cprm)
52782 {
52783 struct vm_area_struct *vma;
52784 size_t size = 0;
52785
52786 for (vma = first_vma(current, gate_vma); vma != NULL;
52787 vma = next_vma(vma, gate_vma))
52788 - size += vma_dump_size(vma, mm_flags);
52789 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
52790 return size;
52791 }
52792
52793 @@ -2117,7 +2574,7 @@ static int elf_core_dump(struct coredump_params *cprm)
52794
52795 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
52796
52797 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
52798 + offset += elf_core_vma_data_size(gate_vma, cprm);
52799 offset += elf_core_extra_data_size();
52800 e_shoff = offset;
52801
52802 @@ -2131,10 +2588,12 @@ static int elf_core_dump(struct coredump_params *cprm)
52803 offset = dataoff;
52804
52805 size += sizeof(*elf);
52806 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
52807 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
52808 goto end_coredump;
52809
52810 size += sizeof(*phdr4note);
52811 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
52812 if (size > cprm->limit
52813 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
52814 goto end_coredump;
52815 @@ -2148,7 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
52816 phdr.p_offset = offset;
52817 phdr.p_vaddr = vma->vm_start;
52818 phdr.p_paddr = 0;
52819 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
52820 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
52821 phdr.p_memsz = vma->vm_end - vma->vm_start;
52822 offset += phdr.p_filesz;
52823 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
52824 @@ -2159,6 +2618,7 @@ static int elf_core_dump(struct coredump_params *cprm)
52825 phdr.p_align = ELF_EXEC_PAGESIZE;
52826
52827 size += sizeof(phdr);
52828 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
52829 if (size > cprm->limit
52830 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
52831 goto end_coredump;
52832 @@ -2183,7 +2643,7 @@ static int elf_core_dump(struct coredump_params *cprm)
52833 unsigned long addr;
52834 unsigned long end;
52835
52836 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
52837 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
52838
52839 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
52840 struct page *page;
52841 @@ -2192,6 +2652,7 @@ static int elf_core_dump(struct coredump_params *cprm)
52842 page = get_dump_page(addr);
52843 if (page) {
52844 void *kaddr = kmap(page);
52845 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
52846 stop = ((size += PAGE_SIZE) > cprm->limit) ||
52847 !dump_write(cprm->file, kaddr,
52848 PAGE_SIZE);
52849 @@ -2209,6 +2670,7 @@ static int elf_core_dump(struct coredump_params *cprm)
52850
52851 if (e_phnum == PN_XNUM) {
52852 size += sizeof(*shdr4extnum);
52853 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
52854 if (size > cprm->limit
52855 || !dump_write(cprm->file, shdr4extnum,
52856 sizeof(*shdr4extnum)))
52857 @@ -2229,6 +2691,167 @@ out:
52858
52859 #endif /* CONFIG_ELF_CORE */
52860
52861 +#ifdef CONFIG_PAX_MPROTECT
52862 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
52863 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
52864 + * we'll remove VM_MAYWRITE for good on RELRO segments.
52865 + *
52866 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
52867 + * basis because we want to allow the common case and not the special ones.
52868 + */
52869 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
52870 +{
52871 + struct elfhdr elf_h;
52872 + struct elf_phdr elf_p;
52873 + unsigned long i;
52874 + unsigned long oldflags;
52875 + bool is_textrel_rw, is_textrel_rx, is_relro;
52876 +
52877 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
52878 + return;
52879 +
52880 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
52881 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
52882 +
52883 +#ifdef CONFIG_PAX_ELFRELOCS
52884 + /* possible TEXTREL */
52885 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
52886 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
52887 +#else
52888 + is_textrel_rw = false;
52889 + is_textrel_rx = false;
52890 +#endif
52891 +
52892 + /* possible RELRO */
52893 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
52894 +
52895 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
52896 + return;
52897 +
52898 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
52899 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
52900 +
52901 +#ifdef CONFIG_PAX_ETEXECRELOCS
52902 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
52903 +#else
52904 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
52905 +#endif
52906 +
52907 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
52908 + !elf_check_arch(&elf_h) ||
52909 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
52910 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
52911 + return;
52912 +
52913 + for (i = 0UL; i < elf_h.e_phnum; i++) {
52914 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
52915 + return;
52916 + switch (elf_p.p_type) {
52917 + case PT_DYNAMIC:
52918 + if (!is_textrel_rw && !is_textrel_rx)
52919 + continue;
52920 + i = 0UL;
52921 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
52922 + elf_dyn dyn;
52923 +
52924 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
52925 + break;
52926 + if (dyn.d_tag == DT_NULL)
52927 + break;
52928 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
52929 + gr_log_textrel(vma);
52930 + if (is_textrel_rw)
52931 + vma->vm_flags |= VM_MAYWRITE;
52932 + else
52933 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
52934 + vma->vm_flags &= ~VM_MAYWRITE;
52935 + break;
52936 + }
52937 + i++;
52938 + }
52939 + is_textrel_rw = false;
52940 + is_textrel_rx = false;
52941 + continue;
52942 +
52943 + case PT_GNU_RELRO:
52944 + if (!is_relro)
52945 + continue;
52946 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
52947 + vma->vm_flags &= ~VM_MAYWRITE;
52948 + is_relro = false;
52949 + continue;
52950 +
52951 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52952 + case PT_PAX_FLAGS: {
52953 + const char *msg_mprotect = "", *msg_emutramp = "";
52954 + char *buffer_lib, *buffer_exe;
52955 +
52956 + if (elf_p.p_flags & PF_NOMPROTECT)
52957 + msg_mprotect = "MPROTECT disabled";
52958 +
52959 +#ifdef CONFIG_PAX_EMUTRAMP
52960 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
52961 + msg_emutramp = "EMUTRAMP enabled";
52962 +#endif
52963 +
52964 + if (!msg_mprotect[0] && !msg_emutramp[0])
52965 + continue;
52966 +
52967 + if (!printk_ratelimit())
52968 + continue;
52969 +
52970 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
52971 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
52972 + if (buffer_lib && buffer_exe) {
52973 + char *path_lib, *path_exe;
52974 +
52975 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
52976 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
52977 +
52978 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
52979 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
52980 +
52981 + }
52982 + free_page((unsigned long)buffer_exe);
52983 + free_page((unsigned long)buffer_lib);
52984 + continue;
52985 + }
52986 +#endif
52987 +
52988 + }
52989 + }
52990 +}
52991 +#endif
52992 +
52993 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52994 +
52995 +extern int grsec_enable_log_rwxmaps;
52996 +
52997 +static void elf_handle_mmap(struct file *file)
52998 +{
52999 + struct elfhdr elf_h;
53000 + struct elf_phdr elf_p;
53001 + unsigned long i;
53002 +
53003 + if (!grsec_enable_log_rwxmaps)
53004 + return;
53005 +
53006 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53007 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53008 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53009 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53010 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53011 + return;
53012 +
53013 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53014 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53015 + return;
53016 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53017 + gr_log_ptgnustack(file);
53018 + }
53019 +}
53020 +#endif
53021 +
53022 static int __init init_elf_binfmt(void)
53023 {
53024 register_binfmt(&elf_format);
53025 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53026 index d50bbe5..af3b649 100644
53027 --- a/fs/binfmt_flat.c
53028 +++ b/fs/binfmt_flat.c
53029 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53030 realdatastart = (unsigned long) -ENOMEM;
53031 printk("Unable to allocate RAM for process data, errno %d\n",
53032 (int)-realdatastart);
53033 + down_write(&current->mm->mmap_sem);
53034 vm_munmap(textpos, text_len);
53035 + up_write(&current->mm->mmap_sem);
53036 ret = realdatastart;
53037 goto err;
53038 }
53039 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53040 }
53041 if (IS_ERR_VALUE(result)) {
53042 printk("Unable to read data+bss, errno %d\n", (int)-result);
53043 + down_write(&current->mm->mmap_sem);
53044 vm_munmap(textpos, text_len);
53045 vm_munmap(realdatastart, len);
53046 + up_write(&current->mm->mmap_sem);
53047 ret = result;
53048 goto err;
53049 }
53050 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53051 }
53052 if (IS_ERR_VALUE(result)) {
53053 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53054 + down_write(&current->mm->mmap_sem);
53055 vm_munmap(textpos, text_len + data_len + extra +
53056 MAX_SHARED_LIBS * sizeof(unsigned long));
53057 + up_write(&current->mm->mmap_sem);
53058 ret = result;
53059 goto err;
53060 }
53061 diff --git a/fs/bio.c b/fs/bio.c
53062 index c5eae72..599e3cf 100644
53063 --- a/fs/bio.c
53064 +++ b/fs/bio.c
53065 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53066 /*
53067 * Overflow, abort
53068 */
53069 - if (end < start)
53070 + if (end < start || end - start > INT_MAX - nr_pages)
53071 return ERR_PTR(-EINVAL);
53072
53073 nr_pages += end - start;
53074 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53075 /*
53076 * Overflow, abort
53077 */
53078 - if (end < start)
53079 + if (end < start || end - start > INT_MAX - nr_pages)
53080 return ERR_PTR(-EINVAL);
53081
53082 nr_pages += end - start;
53083 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53084 const int read = bio_data_dir(bio) == READ;
53085 struct bio_map_data *bmd = bio->bi_private;
53086 int i;
53087 - char *p = bmd->sgvecs[0].iov_base;
53088 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53089
53090 bio_for_each_segment_all(bvec, bio, i) {
53091 char *addr = page_address(bvec->bv_page);
53092 diff --git a/fs/block_dev.c b/fs/block_dev.c
53093 index c7bda5c..2121e94 100644
53094 --- a/fs/block_dev.c
53095 +++ b/fs/block_dev.c
53096 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53097 else if (bdev->bd_contains == bdev)
53098 return true; /* is a whole device which isn't held */
53099
53100 - else if (whole->bd_holder == bd_may_claim)
53101 + else if (whole->bd_holder == (void *)bd_may_claim)
53102 return true; /* is a partition of a device that is being partitioned */
53103 else if (whole->bd_holder != NULL)
53104 return false; /* is a partition of a held device */
53105 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53106 index ed50460..fe84385 100644
53107 --- a/fs/btrfs/ctree.c
53108 +++ b/fs/btrfs/ctree.c
53109 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53110 free_extent_buffer(buf);
53111 add_root_to_dirty_list(root);
53112 } else {
53113 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53114 - parent_start = parent->start;
53115 - else
53116 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53117 + if (parent)
53118 + parent_start = parent->start;
53119 + else
53120 + parent_start = 0;
53121 + } else
53122 parent_start = 0;
53123
53124 WARN_ON(trans->transid != btrfs_header_generation(parent));
53125 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53126 index 3755109..e3d457f 100644
53127 --- a/fs/btrfs/delayed-inode.c
53128 +++ b/fs/btrfs/delayed-inode.c
53129 @@ -458,7 +458,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53130
53131 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53132 {
53133 - int seq = atomic_inc_return(&delayed_root->items_seq);
53134 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53135 if ((atomic_dec_return(&delayed_root->items) <
53136 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53137 waitqueue_active(&delayed_root->wait))
53138 @@ -1377,7 +1377,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53139 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53140 int seq, int count)
53141 {
53142 - int val = atomic_read(&delayed_root->items_seq);
53143 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53144
53145 if (val < seq || val >= seq + count)
53146 return 1;
53147 @@ -1394,7 +1394,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53148 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53149 return;
53150
53151 - seq = atomic_read(&delayed_root->items_seq);
53152 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53153
53154 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53155 int ret;
53156 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53157 index a4b38f9..f86a509 100644
53158 --- a/fs/btrfs/delayed-inode.h
53159 +++ b/fs/btrfs/delayed-inode.h
53160 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53161 */
53162 struct list_head prepare_list;
53163 atomic_t items; /* for delayed items */
53164 - atomic_t items_seq; /* for delayed items */
53165 + atomic_unchecked_t items_seq; /* for delayed items */
53166 int nodes; /* for delayed nodes */
53167 wait_queue_head_t wait;
53168 };
53169 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53170 struct btrfs_delayed_root *delayed_root)
53171 {
53172 atomic_set(&delayed_root->items, 0);
53173 - atomic_set(&delayed_root->items_seq, 0);
53174 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53175 delayed_root->nodes = 0;
53176 spin_lock_init(&delayed_root->lock);
53177 init_waitqueue_head(&delayed_root->wait);
53178 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53179 index 9877a2a..7ebf9ab 100644
53180 --- a/fs/btrfs/ioctl.c
53181 +++ b/fs/btrfs/ioctl.c
53182 @@ -3097,9 +3097,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53183 for (i = 0; i < num_types; i++) {
53184 struct btrfs_space_info *tmp;
53185
53186 + /* Don't copy in more than we allocated */
53187 if (!slot_count)
53188 break;
53189
53190 + slot_count--;
53191 +
53192 info = NULL;
53193 rcu_read_lock();
53194 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53195 @@ -3121,10 +3124,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53196 memcpy(dest, &space, sizeof(space));
53197 dest++;
53198 space_args.total_spaces++;
53199 - slot_count--;
53200 }
53201 - if (!slot_count)
53202 - break;
53203 }
53204 up_read(&info->groups_sem);
53205 }
53206 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53207 index 8eb6191..eda91e2 100644
53208 --- a/fs/btrfs/super.c
53209 +++ b/fs/btrfs/super.c
53210 @@ -264,7 +264,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53211 function, line, errstr);
53212 return;
53213 }
53214 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53215 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53216 /* Wake up anybody who may be waiting on this transaction */
53217 wake_up(&root->fs_info->transaction_wait);
53218 wake_up(&root->fs_info->transaction_blocked_wait);
53219 diff --git a/fs/buffer.c b/fs/buffer.c
53220 index 4d74335..b0df7f9 100644
53221 --- a/fs/buffer.c
53222 +++ b/fs/buffer.c
53223 @@ -3416,7 +3416,7 @@ void __init buffer_init(void)
53224 bh_cachep = kmem_cache_create("buffer_head",
53225 sizeof(struct buffer_head), 0,
53226 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53227 - SLAB_MEM_SPREAD),
53228 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53229 NULL);
53230
53231 /*
53232 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53233 index 622f469..e8d2d55 100644
53234 --- a/fs/cachefiles/bind.c
53235 +++ b/fs/cachefiles/bind.c
53236 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53237 args);
53238
53239 /* start by checking things over */
53240 - ASSERT(cache->fstop_percent >= 0 &&
53241 - cache->fstop_percent < cache->fcull_percent &&
53242 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53243 cache->fcull_percent < cache->frun_percent &&
53244 cache->frun_percent < 100);
53245
53246 - ASSERT(cache->bstop_percent >= 0 &&
53247 - cache->bstop_percent < cache->bcull_percent &&
53248 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53249 cache->bcull_percent < cache->brun_percent &&
53250 cache->brun_percent < 100);
53251
53252 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53253 index 0a1467b..6a53245 100644
53254 --- a/fs/cachefiles/daemon.c
53255 +++ b/fs/cachefiles/daemon.c
53256 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53257 if (n > buflen)
53258 return -EMSGSIZE;
53259
53260 - if (copy_to_user(_buffer, buffer, n) != 0)
53261 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53262 return -EFAULT;
53263
53264 return n;
53265 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53266 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53267 return -EIO;
53268
53269 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53270 + if (datalen > PAGE_SIZE - 1)
53271 return -EOPNOTSUPP;
53272
53273 /* drag the command string into the kernel so we can parse it */
53274 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53275 if (args[0] != '%' || args[1] != '\0')
53276 return -EINVAL;
53277
53278 - if (fstop < 0 || fstop >= cache->fcull_percent)
53279 + if (fstop >= cache->fcull_percent)
53280 return cachefiles_daemon_range_error(cache, args);
53281
53282 cache->fstop_percent = fstop;
53283 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
53284 if (args[0] != '%' || args[1] != '\0')
53285 return -EINVAL;
53286
53287 - if (bstop < 0 || bstop >= cache->bcull_percent)
53288 + if (bstop >= cache->bcull_percent)
53289 return cachefiles_daemon_range_error(cache, args);
53290
53291 cache->bstop_percent = bstop;
53292 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
53293 index 4938251..7e01445 100644
53294 --- a/fs/cachefiles/internal.h
53295 +++ b/fs/cachefiles/internal.h
53296 @@ -59,7 +59,7 @@ struct cachefiles_cache {
53297 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
53298 struct rb_root active_nodes; /* active nodes (can't be culled) */
53299 rwlock_t active_lock; /* lock for active_nodes */
53300 - atomic_t gravecounter; /* graveyard uniquifier */
53301 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
53302 unsigned frun_percent; /* when to stop culling (% files) */
53303 unsigned fcull_percent; /* when to start culling (% files) */
53304 unsigned fstop_percent; /* when to stop allocating (% files) */
53305 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
53306 * proc.c
53307 */
53308 #ifdef CONFIG_CACHEFILES_HISTOGRAM
53309 -extern atomic_t cachefiles_lookup_histogram[HZ];
53310 -extern atomic_t cachefiles_mkdir_histogram[HZ];
53311 -extern atomic_t cachefiles_create_histogram[HZ];
53312 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53313 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53314 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
53315
53316 extern int __init cachefiles_proc_init(void);
53317 extern void cachefiles_proc_cleanup(void);
53318 static inline
53319 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
53320 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
53321 {
53322 unsigned long jif = jiffies - start_jif;
53323 if (jif >= HZ)
53324 jif = HZ - 1;
53325 - atomic_inc(&histogram[jif]);
53326 + atomic_inc_unchecked(&histogram[jif]);
53327 }
53328
53329 #else
53330 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
53331 index 25badd1..d70d918 100644
53332 --- a/fs/cachefiles/namei.c
53333 +++ b/fs/cachefiles/namei.c
53334 @@ -317,7 +317,7 @@ try_again:
53335 /* first step is to make up a grave dentry in the graveyard */
53336 sprintf(nbuffer, "%08x%08x",
53337 (uint32_t) get_seconds(),
53338 - (uint32_t) atomic_inc_return(&cache->gravecounter));
53339 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
53340
53341 /* do the multiway lock magic */
53342 trap = lock_rename(cache->graveyard, dir);
53343 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
53344 index eccd339..4c1d995 100644
53345 --- a/fs/cachefiles/proc.c
53346 +++ b/fs/cachefiles/proc.c
53347 @@ -14,9 +14,9 @@
53348 #include <linux/seq_file.h>
53349 #include "internal.h"
53350
53351 -atomic_t cachefiles_lookup_histogram[HZ];
53352 -atomic_t cachefiles_mkdir_histogram[HZ];
53353 -atomic_t cachefiles_create_histogram[HZ];
53354 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53355 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53356 +atomic_unchecked_t cachefiles_create_histogram[HZ];
53357
53358 /*
53359 * display the latency histogram
53360 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
53361 return 0;
53362 default:
53363 index = (unsigned long) v - 3;
53364 - x = atomic_read(&cachefiles_lookup_histogram[index]);
53365 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
53366 - z = atomic_read(&cachefiles_create_histogram[index]);
53367 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
53368 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
53369 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
53370 if (x == 0 && y == 0 && z == 0)
53371 return 0;
53372
53373 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
53374 index ebaff36..7e3ea26 100644
53375 --- a/fs/cachefiles/rdwr.c
53376 +++ b/fs/cachefiles/rdwr.c
53377 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
53378 old_fs = get_fs();
53379 set_fs(KERNEL_DS);
53380 ret = file->f_op->write(
53381 - file, (const void __user *) data, len, &pos);
53382 + file, (const void __force_user *) data, len, &pos);
53383 set_fs(old_fs);
53384 kunmap(page);
53385 file_end_write(file);
53386 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
53387 index a40ceda..f43d17c 100644
53388 --- a/fs/ceph/dir.c
53389 +++ b/fs/ceph/dir.c
53390 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
53391 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
53392 struct ceph_mds_client *mdsc = fsc->mdsc;
53393 unsigned frag = fpos_frag(ctx->pos);
53394 - int off = fpos_off(ctx->pos);
53395 + unsigned int off = fpos_off(ctx->pos);
53396 int err;
53397 u32 ftype;
53398 struct ceph_mds_reply_info_parsed *rinfo;
53399 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
53400 index 6627b26..634ec4b 100644
53401 --- a/fs/ceph/super.c
53402 +++ b/fs/ceph/super.c
53403 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
53404 /*
53405 * construct our own bdi so we can control readahead, etc.
53406 */
53407 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
53408 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
53409
53410 static int ceph_register_bdi(struct super_block *sb,
53411 struct ceph_fs_client *fsc)
53412 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
53413 default_backing_dev_info.ra_pages;
53414
53415 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
53416 - atomic_long_inc_return(&bdi_seq));
53417 + atomic_long_inc_return_unchecked(&bdi_seq));
53418 if (!err)
53419 sb->s_bdi = &fsc->backing_dev_info;
53420 return err;
53421 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
53422 index f3ac415..3d2420c 100644
53423 --- a/fs/cifs/cifs_debug.c
53424 +++ b/fs/cifs/cifs_debug.c
53425 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53426
53427 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
53428 #ifdef CONFIG_CIFS_STATS2
53429 - atomic_set(&totBufAllocCount, 0);
53430 - atomic_set(&totSmBufAllocCount, 0);
53431 + atomic_set_unchecked(&totBufAllocCount, 0);
53432 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53433 #endif /* CONFIG_CIFS_STATS2 */
53434 spin_lock(&cifs_tcp_ses_lock);
53435 list_for_each(tmp1, &cifs_tcp_ses_list) {
53436 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53437 tcon = list_entry(tmp3,
53438 struct cifs_tcon,
53439 tcon_list);
53440 - atomic_set(&tcon->num_smbs_sent, 0);
53441 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
53442 if (server->ops->clear_stats)
53443 server->ops->clear_stats(tcon);
53444 }
53445 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53446 smBufAllocCount.counter, cifs_min_small);
53447 #ifdef CONFIG_CIFS_STATS2
53448 seq_printf(m, "Total Large %d Small %d Allocations\n",
53449 - atomic_read(&totBufAllocCount),
53450 - atomic_read(&totSmBufAllocCount));
53451 + atomic_read_unchecked(&totBufAllocCount),
53452 + atomic_read_unchecked(&totSmBufAllocCount));
53453 #endif /* CONFIG_CIFS_STATS2 */
53454
53455 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
53456 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53457 if (tcon->need_reconnect)
53458 seq_puts(m, "\tDISCONNECTED ");
53459 seq_printf(m, "\nSMBs: %d",
53460 - atomic_read(&tcon->num_smbs_sent));
53461 + atomic_read_unchecked(&tcon->num_smbs_sent));
53462 if (server->ops->print_stats)
53463 server->ops->print_stats(m, tcon);
53464 }
53465 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
53466 index 85ea98d..b3ed4d6 100644
53467 --- a/fs/cifs/cifsfs.c
53468 +++ b/fs/cifs/cifsfs.c
53469 @@ -1037,7 +1037,7 @@ cifs_init_request_bufs(void)
53470 */
53471 cifs_req_cachep = kmem_cache_create("cifs_request",
53472 CIFSMaxBufSize + max_hdr_size, 0,
53473 - SLAB_HWCACHE_ALIGN, NULL);
53474 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
53475 if (cifs_req_cachep == NULL)
53476 return -ENOMEM;
53477
53478 @@ -1064,7 +1064,7 @@ cifs_init_request_bufs(void)
53479 efficient to alloc 1 per page off the slab compared to 17K (5page)
53480 alloc of large cifs buffers even when page debugging is on */
53481 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
53482 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
53483 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
53484 NULL);
53485 if (cifs_sm_req_cachep == NULL) {
53486 mempool_destroy(cifs_req_poolp);
53487 @@ -1149,8 +1149,8 @@ init_cifs(void)
53488 atomic_set(&bufAllocCount, 0);
53489 atomic_set(&smBufAllocCount, 0);
53490 #ifdef CONFIG_CIFS_STATS2
53491 - atomic_set(&totBufAllocCount, 0);
53492 - atomic_set(&totSmBufAllocCount, 0);
53493 + atomic_set_unchecked(&totBufAllocCount, 0);
53494 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53495 #endif /* CONFIG_CIFS_STATS2 */
53496
53497 atomic_set(&midCount, 0);
53498 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
53499 index 52ca861..47f309c 100644
53500 --- a/fs/cifs/cifsglob.h
53501 +++ b/fs/cifs/cifsglob.h
53502 @@ -756,35 +756,35 @@ struct cifs_tcon {
53503 __u16 Flags; /* optional support bits */
53504 enum statusEnum tidStatus;
53505 #ifdef CONFIG_CIFS_STATS
53506 - atomic_t num_smbs_sent;
53507 + atomic_unchecked_t num_smbs_sent;
53508 union {
53509 struct {
53510 - atomic_t num_writes;
53511 - atomic_t num_reads;
53512 - atomic_t num_flushes;
53513 - atomic_t num_oplock_brks;
53514 - atomic_t num_opens;
53515 - atomic_t num_closes;
53516 - atomic_t num_deletes;
53517 - atomic_t num_mkdirs;
53518 - atomic_t num_posixopens;
53519 - atomic_t num_posixmkdirs;
53520 - atomic_t num_rmdirs;
53521 - atomic_t num_renames;
53522 - atomic_t num_t2renames;
53523 - atomic_t num_ffirst;
53524 - atomic_t num_fnext;
53525 - atomic_t num_fclose;
53526 - atomic_t num_hardlinks;
53527 - atomic_t num_symlinks;
53528 - atomic_t num_locks;
53529 - atomic_t num_acl_get;
53530 - atomic_t num_acl_set;
53531 + atomic_unchecked_t num_writes;
53532 + atomic_unchecked_t num_reads;
53533 + atomic_unchecked_t num_flushes;
53534 + atomic_unchecked_t num_oplock_brks;
53535 + atomic_unchecked_t num_opens;
53536 + atomic_unchecked_t num_closes;
53537 + atomic_unchecked_t num_deletes;
53538 + atomic_unchecked_t num_mkdirs;
53539 + atomic_unchecked_t num_posixopens;
53540 + atomic_unchecked_t num_posixmkdirs;
53541 + atomic_unchecked_t num_rmdirs;
53542 + atomic_unchecked_t num_renames;
53543 + atomic_unchecked_t num_t2renames;
53544 + atomic_unchecked_t num_ffirst;
53545 + atomic_unchecked_t num_fnext;
53546 + atomic_unchecked_t num_fclose;
53547 + atomic_unchecked_t num_hardlinks;
53548 + atomic_unchecked_t num_symlinks;
53549 + atomic_unchecked_t num_locks;
53550 + atomic_unchecked_t num_acl_get;
53551 + atomic_unchecked_t num_acl_set;
53552 } cifs_stats;
53553 #ifdef CONFIG_CIFS_SMB2
53554 struct {
53555 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53556 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53557 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53558 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53559 } smb2_stats;
53560 #endif /* CONFIG_CIFS_SMB2 */
53561 } stats;
53562 @@ -1096,7 +1096,7 @@ convert_delimiter(char *path, char delim)
53563 }
53564
53565 #ifdef CONFIG_CIFS_STATS
53566 -#define cifs_stats_inc atomic_inc
53567 +#define cifs_stats_inc atomic_inc_unchecked
53568
53569 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
53570 unsigned int bytes)
53571 @@ -1461,8 +1461,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
53572 /* Various Debug counters */
53573 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
53574 #ifdef CONFIG_CIFS_STATS2
53575 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
53576 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
53577 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
53578 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
53579 #endif
53580 GLOBAL_EXTERN atomic_t smBufAllocCount;
53581 GLOBAL_EXTERN atomic_t midCount;
53582 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
53583 index 562044f..4af6a17 100644
53584 --- a/fs/cifs/link.c
53585 +++ b/fs/cifs/link.c
53586 @@ -638,7 +638,7 @@ symlink_exit:
53587
53588 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
53589 {
53590 - char *p = nd_get_link(nd);
53591 + const char *p = nd_get_link(nd);
53592 if (!IS_ERR(p))
53593 kfree(p);
53594 }
53595 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
53596 index f7d4b22..1254377 100644
53597 --- a/fs/cifs/misc.c
53598 +++ b/fs/cifs/misc.c
53599 @@ -169,7 +169,7 @@ cifs_buf_get(void)
53600 memset(ret_buf, 0, buf_size + 3);
53601 atomic_inc(&bufAllocCount);
53602 #ifdef CONFIG_CIFS_STATS2
53603 - atomic_inc(&totBufAllocCount);
53604 + atomic_inc_unchecked(&totBufAllocCount);
53605 #endif /* CONFIG_CIFS_STATS2 */
53606 }
53607
53608 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
53609 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
53610 atomic_inc(&smBufAllocCount);
53611 #ifdef CONFIG_CIFS_STATS2
53612 - atomic_inc(&totSmBufAllocCount);
53613 + atomic_inc_unchecked(&totSmBufAllocCount);
53614 #endif /* CONFIG_CIFS_STATS2 */
53615
53616 }
53617 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
53618 index 6094397..51e576f 100644
53619 --- a/fs/cifs/smb1ops.c
53620 +++ b/fs/cifs/smb1ops.c
53621 @@ -590,27 +590,27 @@ static void
53622 cifs_clear_stats(struct cifs_tcon *tcon)
53623 {
53624 #ifdef CONFIG_CIFS_STATS
53625 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
53626 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
53627 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
53628 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53629 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
53630 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
53631 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53632 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
53633 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
53634 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
53635 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
53636 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
53637 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
53638 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
53639 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
53640 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
53641 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
53642 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
53643 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
53644 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
53645 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
53646 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
53647 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
53648 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
53649 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
53650 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
53651 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
53652 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
53653 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
53654 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
53655 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
53656 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
53657 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
53658 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
53659 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
53660 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
53661 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
53662 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
53663 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
53664 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
53665 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
53666 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
53667 #endif
53668 }
53669
53670 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
53671 {
53672 #ifdef CONFIG_CIFS_STATS
53673 seq_printf(m, " Oplocks breaks: %d",
53674 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
53675 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
53676 seq_printf(m, "\nReads: %d Bytes: %llu",
53677 - atomic_read(&tcon->stats.cifs_stats.num_reads),
53678 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
53679 (long long)(tcon->bytes_read));
53680 seq_printf(m, "\nWrites: %d Bytes: %llu",
53681 - atomic_read(&tcon->stats.cifs_stats.num_writes),
53682 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
53683 (long long)(tcon->bytes_written));
53684 seq_printf(m, "\nFlushes: %d",
53685 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
53686 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
53687 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
53688 - atomic_read(&tcon->stats.cifs_stats.num_locks),
53689 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
53690 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
53691 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
53692 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
53693 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
53694 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
53695 - atomic_read(&tcon->stats.cifs_stats.num_opens),
53696 - atomic_read(&tcon->stats.cifs_stats.num_closes),
53697 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
53698 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
53699 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
53700 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
53701 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
53702 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
53703 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
53704 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
53705 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
53706 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
53707 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
53708 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
53709 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
53710 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
53711 seq_printf(m, "\nRenames: %d T2 Renames %d",
53712 - atomic_read(&tcon->stats.cifs_stats.num_renames),
53713 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
53714 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
53715 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
53716 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
53717 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
53718 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
53719 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
53720 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
53721 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
53722 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
53723 #endif
53724 }
53725
53726 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
53727 index f259e6c..ca948ff 100644
53728 --- a/fs/cifs/smb2ops.c
53729 +++ b/fs/cifs/smb2ops.c
53730 @@ -281,8 +281,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
53731 #ifdef CONFIG_CIFS_STATS
53732 int i;
53733 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
53734 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
53735 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
53736 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
53737 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
53738 }
53739 #endif
53740 }
53741 @@ -310,65 +310,65 @@ static void
53742 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
53743 {
53744 #ifdef CONFIG_CIFS_STATS
53745 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
53746 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
53747 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
53748 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
53749 seq_printf(m, "\nNegotiates: %d sent %d failed",
53750 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
53751 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
53752 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
53753 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
53754 seq_printf(m, "\nSessionSetups: %d sent %d failed",
53755 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
53756 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
53757 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
53758 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
53759 seq_printf(m, "\nLogoffs: %d sent %d failed",
53760 - atomic_read(&sent[SMB2_LOGOFF_HE]),
53761 - atomic_read(&failed[SMB2_LOGOFF_HE]));
53762 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
53763 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
53764 seq_printf(m, "\nTreeConnects: %d sent %d failed",
53765 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
53766 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
53767 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
53768 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
53769 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
53770 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
53771 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
53772 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
53773 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
53774 seq_printf(m, "\nCreates: %d sent %d failed",
53775 - atomic_read(&sent[SMB2_CREATE_HE]),
53776 - atomic_read(&failed[SMB2_CREATE_HE]));
53777 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
53778 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
53779 seq_printf(m, "\nCloses: %d sent %d failed",
53780 - atomic_read(&sent[SMB2_CLOSE_HE]),
53781 - atomic_read(&failed[SMB2_CLOSE_HE]));
53782 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
53783 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
53784 seq_printf(m, "\nFlushes: %d sent %d failed",
53785 - atomic_read(&sent[SMB2_FLUSH_HE]),
53786 - atomic_read(&failed[SMB2_FLUSH_HE]));
53787 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
53788 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
53789 seq_printf(m, "\nReads: %d sent %d failed",
53790 - atomic_read(&sent[SMB2_READ_HE]),
53791 - atomic_read(&failed[SMB2_READ_HE]));
53792 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
53793 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
53794 seq_printf(m, "\nWrites: %d sent %d failed",
53795 - atomic_read(&sent[SMB2_WRITE_HE]),
53796 - atomic_read(&failed[SMB2_WRITE_HE]));
53797 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
53798 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
53799 seq_printf(m, "\nLocks: %d sent %d failed",
53800 - atomic_read(&sent[SMB2_LOCK_HE]),
53801 - atomic_read(&failed[SMB2_LOCK_HE]));
53802 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
53803 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
53804 seq_printf(m, "\nIOCTLs: %d sent %d failed",
53805 - atomic_read(&sent[SMB2_IOCTL_HE]),
53806 - atomic_read(&failed[SMB2_IOCTL_HE]));
53807 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
53808 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
53809 seq_printf(m, "\nCancels: %d sent %d failed",
53810 - atomic_read(&sent[SMB2_CANCEL_HE]),
53811 - atomic_read(&failed[SMB2_CANCEL_HE]));
53812 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
53813 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
53814 seq_printf(m, "\nEchos: %d sent %d failed",
53815 - atomic_read(&sent[SMB2_ECHO_HE]),
53816 - atomic_read(&failed[SMB2_ECHO_HE]));
53817 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
53818 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
53819 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
53820 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
53821 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
53822 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
53823 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
53824 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
53825 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
53826 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
53827 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
53828 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
53829 seq_printf(m, "\nQueryInfos: %d sent %d failed",
53830 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
53831 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
53832 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
53833 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
53834 seq_printf(m, "\nSetInfos: %d sent %d failed",
53835 - atomic_read(&sent[SMB2_SET_INFO_HE]),
53836 - atomic_read(&failed[SMB2_SET_INFO_HE]));
53837 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
53838 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
53839 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
53840 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
53841 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
53842 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
53843 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
53844 #endif
53845 }
53846
53847 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
53848 index abc9c28..3fdae28 100644
53849 --- a/fs/cifs/smb2pdu.c
53850 +++ b/fs/cifs/smb2pdu.c
53851 @@ -1946,8 +1946,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
53852 default:
53853 cifs_dbg(VFS, "info level %u isn't supported\n",
53854 srch_inf->info_level);
53855 - rc = -EINVAL;
53856 - goto qdir_exit;
53857 + return -EINVAL;
53858 }
53859
53860 req->FileIndex = cpu_to_le32(index);
53861 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
53862 index 1da168c..8bc7ff6 100644
53863 --- a/fs/coda/cache.c
53864 +++ b/fs/coda/cache.c
53865 @@ -24,7 +24,7 @@
53866 #include "coda_linux.h"
53867 #include "coda_cache.h"
53868
53869 -static atomic_t permission_epoch = ATOMIC_INIT(0);
53870 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
53871
53872 /* replace or extend an acl cache hit */
53873 void coda_cache_enter(struct inode *inode, int mask)
53874 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
53875 struct coda_inode_info *cii = ITOC(inode);
53876
53877 spin_lock(&cii->c_lock);
53878 - cii->c_cached_epoch = atomic_read(&permission_epoch);
53879 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
53880 if (!uid_eq(cii->c_uid, current_fsuid())) {
53881 cii->c_uid = current_fsuid();
53882 cii->c_cached_perm = mask;
53883 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
53884 {
53885 struct coda_inode_info *cii = ITOC(inode);
53886 spin_lock(&cii->c_lock);
53887 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
53888 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
53889 spin_unlock(&cii->c_lock);
53890 }
53891
53892 /* remove all acl caches */
53893 void coda_cache_clear_all(struct super_block *sb)
53894 {
53895 - atomic_inc(&permission_epoch);
53896 + atomic_inc_unchecked(&permission_epoch);
53897 }
53898
53899
53900 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
53901 spin_lock(&cii->c_lock);
53902 hit = (mask & cii->c_cached_perm) == mask &&
53903 uid_eq(cii->c_uid, current_fsuid()) &&
53904 - cii->c_cached_epoch == atomic_read(&permission_epoch);
53905 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
53906 spin_unlock(&cii->c_lock);
53907
53908 return hit;
53909 diff --git a/fs/compat.c b/fs/compat.c
53910 index 6af20de..fec3fbb 100644
53911 --- a/fs/compat.c
53912 +++ b/fs/compat.c
53913 @@ -54,7 +54,7 @@
53914 #include <asm/ioctls.h>
53915 #include "internal.h"
53916
53917 -int compat_log = 1;
53918 +int compat_log = 0;
53919
53920 int compat_printk(const char *fmt, ...)
53921 {
53922 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
53923
53924 set_fs(KERNEL_DS);
53925 /* The __user pointer cast is valid because of the set_fs() */
53926 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
53927 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
53928 set_fs(oldfs);
53929 /* truncating is ok because it's a user address */
53930 if (!ret)
53931 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
53932 goto out;
53933
53934 ret = -EINVAL;
53935 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
53936 + if (nr_segs > UIO_MAXIOV)
53937 goto out;
53938 if (nr_segs > fast_segs) {
53939 ret = -ENOMEM;
53940 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
53941 struct compat_readdir_callback {
53942 struct dir_context ctx;
53943 struct compat_old_linux_dirent __user *dirent;
53944 + struct file * file;
53945 int result;
53946 };
53947
53948 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
53949 buf->result = -EOVERFLOW;
53950 return -EOVERFLOW;
53951 }
53952 +
53953 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
53954 + return 0;
53955 +
53956 buf->result++;
53957 dirent = buf->dirent;
53958 if (!access_ok(VERIFY_WRITE, dirent,
53959 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
53960 if (!f.file)
53961 return -EBADF;
53962
53963 + buf.file = f.file;
53964 error = iterate_dir(f.file, &buf.ctx);
53965 if (buf.result)
53966 error = buf.result;
53967 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
53968 struct dir_context ctx;
53969 struct compat_linux_dirent __user *current_dir;
53970 struct compat_linux_dirent __user *previous;
53971 + struct file * file;
53972 int count;
53973 int error;
53974 };
53975 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
53976 buf->error = -EOVERFLOW;
53977 return -EOVERFLOW;
53978 }
53979 +
53980 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
53981 + return 0;
53982 +
53983 dirent = buf->previous;
53984 if (dirent) {
53985 if (__put_user(offset, &dirent->d_off))
53986 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
53987 if (!f.file)
53988 return -EBADF;
53989
53990 + buf.file = f.file;
53991 error = iterate_dir(f.file, &buf.ctx);
53992 if (error >= 0)
53993 error = buf.error;
53994 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
53995 struct dir_context ctx;
53996 struct linux_dirent64 __user *current_dir;
53997 struct linux_dirent64 __user *previous;
53998 + struct file * file;
53999 int count;
54000 int error;
54001 };
54002 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54003 buf->error = -EINVAL; /* only used if we fail.. */
54004 if (reclen > buf->count)
54005 return -EINVAL;
54006 +
54007 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54008 + return 0;
54009 +
54010 dirent = buf->previous;
54011
54012 if (dirent) {
54013 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54014 if (!f.file)
54015 return -EBADF;
54016
54017 + buf.file = f.file;
54018 error = iterate_dir(f.file, &buf.ctx);
54019 if (error >= 0)
54020 error = buf.error;
54021 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54022 index a81147e..20bf2b5 100644
54023 --- a/fs/compat_binfmt_elf.c
54024 +++ b/fs/compat_binfmt_elf.c
54025 @@ -30,11 +30,13 @@
54026 #undef elf_phdr
54027 #undef elf_shdr
54028 #undef elf_note
54029 +#undef elf_dyn
54030 #undef elf_addr_t
54031 #define elfhdr elf32_hdr
54032 #define elf_phdr elf32_phdr
54033 #define elf_shdr elf32_shdr
54034 #define elf_note elf32_note
54035 +#define elf_dyn Elf32_Dyn
54036 #define elf_addr_t Elf32_Addr
54037
54038 /*
54039 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54040 index 5d19acf..9ab093b 100644
54041 --- a/fs/compat_ioctl.c
54042 +++ b/fs/compat_ioctl.c
54043 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54044 return -EFAULT;
54045 if (__get_user(udata, &ss32->iomem_base))
54046 return -EFAULT;
54047 - ss.iomem_base = compat_ptr(udata);
54048 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54049 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54050 __get_user(ss.port_high, &ss32->port_high))
54051 return -EFAULT;
54052 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54053 for (i = 0; i < nmsgs; i++) {
54054 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54055 return -EFAULT;
54056 - if (get_user(datap, &umsgs[i].buf) ||
54057 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54058 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54059 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54060 return -EFAULT;
54061 }
54062 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54063 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54064 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54065 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54066 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54067 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54068 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54069 return -EFAULT;
54070
54071 return ioctl_preallocate(file, p);
54072 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54073 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54074 {
54075 unsigned int a, b;
54076 - a = *(unsigned int *)p;
54077 - b = *(unsigned int *)q;
54078 + a = *(const unsigned int *)p;
54079 + b = *(const unsigned int *)q;
54080 if (a > b)
54081 return 1;
54082 if (a < b)
54083 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54084 index 277bd1b..f312c9e 100644
54085 --- a/fs/configfs/dir.c
54086 +++ b/fs/configfs/dir.c
54087 @@ -1546,7 +1546,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54088 }
54089 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54090 struct configfs_dirent *next;
54091 - const char *name;
54092 + const unsigned char * name;
54093 + char d_name[sizeof(next->s_dentry->d_iname)];
54094 int len;
54095 struct inode *inode = NULL;
54096
54097 @@ -1555,7 +1556,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54098 continue;
54099
54100 name = configfs_get_name(next);
54101 - len = strlen(name);
54102 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54103 + len = next->s_dentry->d_name.len;
54104 + memcpy(d_name, name, len);
54105 + name = d_name;
54106 + } else
54107 + len = strlen(name);
54108
54109 /*
54110 * We'll have a dentry and an inode for
54111 diff --git a/fs/coredump.c b/fs/coredump.c
54112 index 72f816d..1ba8eff 100644
54113 --- a/fs/coredump.c
54114 +++ b/fs/coredump.c
54115 @@ -433,8 +433,8 @@ static void wait_for_dump_helpers(struct file *file)
54116 struct pipe_inode_info *pipe = file->private_data;
54117
54118 pipe_lock(pipe);
54119 - pipe->readers++;
54120 - pipe->writers--;
54121 + atomic_inc(&pipe->readers);
54122 + atomic_dec(&pipe->writers);
54123 wake_up_interruptible_sync(&pipe->wait);
54124 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54125 pipe_unlock(pipe);
54126 @@ -443,11 +443,11 @@ static void wait_for_dump_helpers(struct file *file)
54127 * We actually want wait_event_freezable() but then we need
54128 * to clear TIF_SIGPENDING and improve dump_interrupted().
54129 */
54130 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54131 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54132
54133 pipe_lock(pipe);
54134 - pipe->readers--;
54135 - pipe->writers++;
54136 + atomic_dec(&pipe->readers);
54137 + atomic_inc(&pipe->writers);
54138 pipe_unlock(pipe);
54139 }
54140
54141 @@ -494,7 +494,8 @@ void do_coredump(siginfo_t *siginfo)
54142 struct files_struct *displaced;
54143 bool need_nonrelative = false;
54144 bool core_dumped = false;
54145 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54146 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54147 + long signr = siginfo->si_signo;
54148 struct coredump_params cprm = {
54149 .siginfo = siginfo,
54150 .regs = signal_pt_regs(),
54151 @@ -507,7 +508,10 @@ void do_coredump(siginfo_t *siginfo)
54152 .mm_flags = mm->flags,
54153 };
54154
54155 - audit_core_dumps(siginfo->si_signo);
54156 + audit_core_dumps(signr);
54157 +
54158 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54159 + gr_handle_brute_attach(cprm.mm_flags);
54160
54161 binfmt = mm->binfmt;
54162 if (!binfmt || !binfmt->core_dump)
54163 @@ -531,7 +535,7 @@ void do_coredump(siginfo_t *siginfo)
54164 need_nonrelative = true;
54165 }
54166
54167 - retval = coredump_wait(siginfo->si_signo, &core_state);
54168 + retval = coredump_wait(signr, &core_state);
54169 if (retval < 0)
54170 goto fail_creds;
54171
54172 @@ -574,7 +578,7 @@ void do_coredump(siginfo_t *siginfo)
54173 }
54174 cprm.limit = RLIM_INFINITY;
54175
54176 - dump_count = atomic_inc_return(&core_dump_count);
54177 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54178 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54179 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54180 task_tgid_vnr(current), current->comm);
54181 @@ -606,6 +610,8 @@ void do_coredump(siginfo_t *siginfo)
54182 } else {
54183 struct inode *inode;
54184
54185 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54186 +
54187 if (cprm.limit < binfmt->min_coredump)
54188 goto fail_unlock;
54189
54190 @@ -664,7 +670,7 @@ close_fail:
54191 filp_close(cprm.file, NULL);
54192 fail_dropcount:
54193 if (ispipe)
54194 - atomic_dec(&core_dump_count);
54195 + atomic_dec_unchecked(&core_dump_count);
54196 fail_unlock:
54197 kfree(cn.corename);
54198 coredump_finish(mm, core_dumped);
54199 @@ -684,7 +690,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54200 {
54201 return !dump_interrupted() &&
54202 access_ok(VERIFY_READ, addr, nr) &&
54203 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54204 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54205 }
54206 EXPORT_SYMBOL(dump_write);
54207
54208 diff --git a/fs/dcache.c b/fs/dcache.c
54209 index b949af8..5978926 100644
54210 --- a/fs/dcache.c
54211 +++ b/fs/dcache.c
54212 @@ -3073,7 +3073,8 @@ void __init vfs_caches_init(unsigned long mempages)
54213 mempages -= reserve;
54214
54215 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54216 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54217 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54218 + SLAB_NO_SANITIZE, NULL);
54219
54220 dcache_init();
54221 inode_init();
54222 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54223 index c7c83ff..bda9461 100644
54224 --- a/fs/debugfs/inode.c
54225 +++ b/fs/debugfs/inode.c
54226 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54227 */
54228 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54229 {
54230 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54231 + return __create_file(name, S_IFDIR | S_IRWXU,
54232 +#else
54233 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54234 +#endif
54235 parent, NULL, NULL);
54236 }
54237 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54238 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54239 index 67e9b63..a9adb68 100644
54240 --- a/fs/ecryptfs/inode.c
54241 +++ b/fs/ecryptfs/inode.c
54242 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54243 old_fs = get_fs();
54244 set_fs(get_ds());
54245 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54246 - (char __user *)lower_buf,
54247 + (char __force_user *)lower_buf,
54248 PATH_MAX);
54249 set_fs(old_fs);
54250 if (rc < 0)
54251 @@ -706,7 +706,7 @@ out:
54252 static void
54253 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
54254 {
54255 - char *buf = nd_get_link(nd);
54256 + const char *buf = nd_get_link(nd);
54257 if (!IS_ERR(buf)) {
54258 /* Free the char* */
54259 kfree(buf);
54260 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
54261 index e4141f2..d8263e8 100644
54262 --- a/fs/ecryptfs/miscdev.c
54263 +++ b/fs/ecryptfs/miscdev.c
54264 @@ -304,7 +304,7 @@ check_list:
54265 goto out_unlock_msg_ctx;
54266 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
54267 if (msg_ctx->msg) {
54268 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
54269 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
54270 goto out_unlock_msg_ctx;
54271 i += packet_length_size;
54272 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
54273 diff --git a/fs/exec.c b/fs/exec.c
54274 index fd774c7..1c6a7bf 100644
54275 --- a/fs/exec.c
54276 +++ b/fs/exec.c
54277 @@ -55,8 +55,20 @@
54278 #include <linux/pipe_fs_i.h>
54279 #include <linux/oom.h>
54280 #include <linux/compat.h>
54281 +#include <linux/random.h>
54282 +#include <linux/seq_file.h>
54283 +#include <linux/coredump.h>
54284 +#include <linux/mman.h>
54285 +
54286 +#ifdef CONFIG_PAX_REFCOUNT
54287 +#include <linux/kallsyms.h>
54288 +#include <linux/kdebug.h>
54289 +#endif
54290 +
54291 +#include <trace/events/fs.h>
54292
54293 #include <asm/uaccess.h>
54294 +#include <asm/sections.h>
54295 #include <asm/mmu_context.h>
54296 #include <asm/tlb.h>
54297
54298 @@ -66,17 +78,32 @@
54299
54300 #include <trace/events/sched.h>
54301
54302 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54303 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
54304 +{
54305 + 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");
54306 +}
54307 +#endif
54308 +
54309 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
54310 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
54311 +EXPORT_SYMBOL(pax_set_initial_flags_func);
54312 +#endif
54313 +
54314 int suid_dumpable = 0;
54315
54316 static LIST_HEAD(formats);
54317 static DEFINE_RWLOCK(binfmt_lock);
54318
54319 +extern int gr_process_kernel_exec_ban(void);
54320 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
54321 +
54322 void __register_binfmt(struct linux_binfmt * fmt, int insert)
54323 {
54324 BUG_ON(!fmt);
54325 write_lock(&binfmt_lock);
54326 - insert ? list_add(&fmt->lh, &formats) :
54327 - list_add_tail(&fmt->lh, &formats);
54328 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
54329 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
54330 write_unlock(&binfmt_lock);
54331 }
54332
54333 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
54334 void unregister_binfmt(struct linux_binfmt * fmt)
54335 {
54336 write_lock(&binfmt_lock);
54337 - list_del(&fmt->lh);
54338 + pax_list_del((struct list_head *)&fmt->lh);
54339 write_unlock(&binfmt_lock);
54340 }
54341
54342 @@ -181,18 +208,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54343 int write)
54344 {
54345 struct page *page;
54346 - int ret;
54347
54348 -#ifdef CONFIG_STACK_GROWSUP
54349 - if (write) {
54350 - ret = expand_downwards(bprm->vma, pos);
54351 - if (ret < 0)
54352 - return NULL;
54353 - }
54354 -#endif
54355 - ret = get_user_pages(current, bprm->mm, pos,
54356 - 1, write, 1, &page, NULL);
54357 - if (ret <= 0)
54358 + if (0 > expand_downwards(bprm->vma, pos))
54359 + return NULL;
54360 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
54361 return NULL;
54362
54363 if (write) {
54364 @@ -208,6 +227,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54365 if (size <= ARG_MAX)
54366 return page;
54367
54368 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54369 + // only allow 512KB for argv+env on suid/sgid binaries
54370 + // to prevent easy ASLR exhaustion
54371 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
54372 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
54373 + (size > (512 * 1024))) {
54374 + put_page(page);
54375 + return NULL;
54376 + }
54377 +#endif
54378 +
54379 /*
54380 * Limit to 1/4-th the stack size for the argv+env strings.
54381 * This ensures that:
54382 @@ -267,6 +297,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54383 vma->vm_end = STACK_TOP_MAX;
54384 vma->vm_start = vma->vm_end - PAGE_SIZE;
54385 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
54386 +
54387 +#ifdef CONFIG_PAX_SEGMEXEC
54388 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
54389 +#endif
54390 +
54391 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
54392 INIT_LIST_HEAD(&vma->anon_vma_chain);
54393
54394 @@ -277,6 +312,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54395 mm->stack_vm = mm->total_vm = 1;
54396 up_write(&mm->mmap_sem);
54397 bprm->p = vma->vm_end - sizeof(void *);
54398 +
54399 +#ifdef CONFIG_PAX_RANDUSTACK
54400 + if (randomize_va_space)
54401 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
54402 +#endif
54403 +
54404 return 0;
54405 err:
54406 up_write(&mm->mmap_sem);
54407 @@ -397,7 +438,7 @@ struct user_arg_ptr {
54408 } ptr;
54409 };
54410
54411 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54412 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54413 {
54414 const char __user *native;
54415
54416 @@ -406,14 +447,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54417 compat_uptr_t compat;
54418
54419 if (get_user(compat, argv.ptr.compat + nr))
54420 - return ERR_PTR(-EFAULT);
54421 + return (const char __force_user *)ERR_PTR(-EFAULT);
54422
54423 return compat_ptr(compat);
54424 }
54425 #endif
54426
54427 if (get_user(native, argv.ptr.native + nr))
54428 - return ERR_PTR(-EFAULT);
54429 + return (const char __force_user *)ERR_PTR(-EFAULT);
54430
54431 return native;
54432 }
54433 @@ -432,7 +473,7 @@ static int count(struct user_arg_ptr argv, int max)
54434 if (!p)
54435 break;
54436
54437 - if (IS_ERR(p))
54438 + if (IS_ERR((const char __force_kernel *)p))
54439 return -EFAULT;
54440
54441 if (i >= max)
54442 @@ -467,7 +508,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
54443
54444 ret = -EFAULT;
54445 str = get_user_arg_ptr(argv, argc);
54446 - if (IS_ERR(str))
54447 + if (IS_ERR((const char __force_kernel *)str))
54448 goto out;
54449
54450 len = strnlen_user(str, MAX_ARG_STRLEN);
54451 @@ -549,7 +590,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
54452 int r;
54453 mm_segment_t oldfs = get_fs();
54454 struct user_arg_ptr argv = {
54455 - .ptr.native = (const char __user *const __user *)__argv,
54456 + .ptr.native = (const char __force_user * const __force_user *)__argv,
54457 };
54458
54459 set_fs(KERNEL_DS);
54460 @@ -584,7 +625,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54461 unsigned long new_end = old_end - shift;
54462 struct mmu_gather tlb;
54463
54464 - BUG_ON(new_start > new_end);
54465 + if (new_start >= new_end || new_start < mmap_min_addr)
54466 + return -ENOMEM;
54467
54468 /*
54469 * ensure there are no vmas between where we want to go
54470 @@ -593,6 +635,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54471 if (vma != find_vma(mm, new_start))
54472 return -EFAULT;
54473
54474 +#ifdef CONFIG_PAX_SEGMEXEC
54475 + BUG_ON(pax_find_mirror_vma(vma));
54476 +#endif
54477 +
54478 /*
54479 * cover the whole range: [new_start, old_end)
54480 */
54481 @@ -673,10 +719,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54482 stack_top = arch_align_stack(stack_top);
54483 stack_top = PAGE_ALIGN(stack_top);
54484
54485 - if (unlikely(stack_top < mmap_min_addr) ||
54486 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
54487 - return -ENOMEM;
54488 -
54489 stack_shift = vma->vm_end - stack_top;
54490
54491 bprm->p -= stack_shift;
54492 @@ -688,8 +730,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
54493 bprm->exec -= stack_shift;
54494
54495 down_write(&mm->mmap_sem);
54496 +
54497 + /* Move stack pages down in memory. */
54498 + if (stack_shift) {
54499 + ret = shift_arg_pages(vma, stack_shift);
54500 + if (ret)
54501 + goto out_unlock;
54502 + }
54503 +
54504 vm_flags = VM_STACK_FLAGS;
54505
54506 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54507 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54508 + vm_flags &= ~VM_EXEC;
54509 +
54510 +#ifdef CONFIG_PAX_MPROTECT
54511 + if (mm->pax_flags & MF_PAX_MPROTECT)
54512 + vm_flags &= ~VM_MAYEXEC;
54513 +#endif
54514 +
54515 + }
54516 +#endif
54517 +
54518 /*
54519 * Adjust stack execute permissions; explicitly enable for
54520 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
54521 @@ -708,13 +770,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54522 goto out_unlock;
54523 BUG_ON(prev != vma);
54524
54525 - /* Move stack pages down in memory. */
54526 - if (stack_shift) {
54527 - ret = shift_arg_pages(vma, stack_shift);
54528 - if (ret)
54529 - goto out_unlock;
54530 - }
54531 -
54532 /* mprotect_fixup is overkill to remove the temporary stack flags */
54533 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
54534
54535 @@ -738,6 +793,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
54536 #endif
54537 current->mm->start_stack = bprm->p;
54538 ret = expand_stack(vma, stack_base);
54539 +
54540 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
54541 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
54542 + unsigned long size;
54543 + vm_flags_t vm_flags;
54544 +
54545 + size = STACK_TOP - vma->vm_end;
54546 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
54547 +
54548 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
54549 +
54550 +#ifdef CONFIG_X86
54551 + if (!ret) {
54552 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
54553 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
54554 + }
54555 +#endif
54556 +
54557 + }
54558 +#endif
54559 +
54560 if (ret)
54561 ret = -EFAULT;
54562
54563 @@ -774,6 +850,8 @@ struct file *open_exec(const char *name)
54564
54565 fsnotify_open(file);
54566
54567 + trace_open_exec(name);
54568 +
54569 err = deny_write_access(file);
54570 if (err)
54571 goto exit;
54572 @@ -797,7 +875,7 @@ int kernel_read(struct file *file, loff_t offset,
54573 old_fs = get_fs();
54574 set_fs(get_ds());
54575 /* The cast to a user pointer is valid due to the set_fs() */
54576 - result = vfs_read(file, (void __user *)addr, count, &pos);
54577 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
54578 set_fs(old_fs);
54579 return result;
54580 }
54581 @@ -1253,7 +1331,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
54582 }
54583 rcu_read_unlock();
54584
54585 - if (p->fs->users > n_fs) {
54586 + if (atomic_read(&p->fs->users) > n_fs) {
54587 bprm->unsafe |= LSM_UNSAFE_SHARE;
54588 } else {
54589 res = -EAGAIN;
54590 @@ -1453,6 +1531,31 @@ int search_binary_handler(struct linux_binprm *bprm)
54591
54592 EXPORT_SYMBOL(search_binary_handler);
54593
54594 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54595 +static DEFINE_PER_CPU(u64, exec_counter);
54596 +static int __init init_exec_counters(void)
54597 +{
54598 + unsigned int cpu;
54599 +
54600 + for_each_possible_cpu(cpu) {
54601 + per_cpu(exec_counter, cpu) = (u64)cpu;
54602 + }
54603 +
54604 + return 0;
54605 +}
54606 +early_initcall(init_exec_counters);
54607 +static inline void increment_exec_counter(void)
54608 +{
54609 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
54610 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
54611 +}
54612 +#else
54613 +static inline void increment_exec_counter(void) {}
54614 +#endif
54615 +
54616 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
54617 + struct user_arg_ptr argv);
54618 +
54619 /*
54620 * sys_execve() executes a new program.
54621 */
54622 @@ -1460,12 +1563,19 @@ static int do_execve_common(const char *filename,
54623 struct user_arg_ptr argv,
54624 struct user_arg_ptr envp)
54625 {
54626 +#ifdef CONFIG_GRKERNSEC
54627 + struct file *old_exec_file;
54628 + struct acl_subject_label *old_acl;
54629 + struct rlimit old_rlim[RLIM_NLIMITS];
54630 +#endif
54631 struct linux_binprm *bprm;
54632 struct file *file;
54633 struct files_struct *displaced;
54634 bool clear_in_exec;
54635 int retval;
54636
54637 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
54638 +
54639 /*
54640 * We move the actual failure in case of RLIMIT_NPROC excess from
54641 * set*uid() to execve() because too many poorly written programs
54642 @@ -1506,12 +1616,22 @@ static int do_execve_common(const char *filename,
54643 if (IS_ERR(file))
54644 goto out_unmark;
54645
54646 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
54647 + retval = -EPERM;
54648 + goto out_file;
54649 + }
54650 +
54651 sched_exec();
54652
54653 bprm->file = file;
54654 bprm->filename = filename;
54655 bprm->interp = filename;
54656
54657 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
54658 + retval = -EACCES;
54659 + goto out_file;
54660 + }
54661 +
54662 retval = bprm_mm_init(bprm);
54663 if (retval)
54664 goto out_file;
54665 @@ -1528,24 +1648,70 @@ static int do_execve_common(const char *filename,
54666 if (retval < 0)
54667 goto out;
54668
54669 +#ifdef CONFIG_GRKERNSEC
54670 + old_acl = current->acl;
54671 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
54672 + old_exec_file = current->exec_file;
54673 + get_file(file);
54674 + current->exec_file = file;
54675 +#endif
54676 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54677 + /* limit suid stack to 8MB
54678 + * we saved the old limits above and will restore them if this exec fails
54679 + */
54680 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
54681 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
54682 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
54683 +#endif
54684 +
54685 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
54686 + retval = -EPERM;
54687 + goto out_fail;
54688 + }
54689 +
54690 + if (!gr_tpe_allow(file)) {
54691 + retval = -EACCES;
54692 + goto out_fail;
54693 + }
54694 +
54695 + if (gr_check_crash_exec(file)) {
54696 + retval = -EACCES;
54697 + goto out_fail;
54698 + }
54699 +
54700 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
54701 + bprm->unsafe);
54702 + if (retval < 0)
54703 + goto out_fail;
54704 +
54705 retval = copy_strings_kernel(1, &bprm->filename, bprm);
54706 if (retval < 0)
54707 - goto out;
54708 + goto out_fail;
54709
54710 bprm->exec = bprm->p;
54711 retval = copy_strings(bprm->envc, envp, bprm);
54712 if (retval < 0)
54713 - goto out;
54714 + goto out_fail;
54715
54716 retval = copy_strings(bprm->argc, argv, bprm);
54717 if (retval < 0)
54718 - goto out;
54719 + goto out_fail;
54720 +
54721 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
54722 +
54723 + gr_handle_exec_args(bprm, argv);
54724
54725 retval = search_binary_handler(bprm);
54726 if (retval < 0)
54727 - goto out;
54728 + goto out_fail;
54729 +#ifdef CONFIG_GRKERNSEC
54730 + if (old_exec_file)
54731 + fput(old_exec_file);
54732 +#endif
54733
54734 /* execve succeeded */
54735 +
54736 + increment_exec_counter();
54737 current->fs->in_exec = 0;
54738 current->in_execve = 0;
54739 acct_update_integrals(current);
54740 @@ -1554,6 +1720,14 @@ static int do_execve_common(const char *filename,
54741 put_files_struct(displaced);
54742 return retval;
54743
54744 +out_fail:
54745 +#ifdef CONFIG_GRKERNSEC
54746 + current->acl = old_acl;
54747 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
54748 + fput(current->exec_file);
54749 + current->exec_file = old_exec_file;
54750 +#endif
54751 +
54752 out:
54753 if (bprm->mm) {
54754 acct_arg_size(bprm, 0);
54755 @@ -1702,3 +1876,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
54756 return error;
54757 }
54758 #endif
54759 +
54760 +int pax_check_flags(unsigned long *flags)
54761 +{
54762 + int retval = 0;
54763 +
54764 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
54765 + if (*flags & MF_PAX_SEGMEXEC)
54766 + {
54767 + *flags &= ~MF_PAX_SEGMEXEC;
54768 + retval = -EINVAL;
54769 + }
54770 +#endif
54771 +
54772 + if ((*flags & MF_PAX_PAGEEXEC)
54773 +
54774 +#ifdef CONFIG_PAX_PAGEEXEC
54775 + && (*flags & MF_PAX_SEGMEXEC)
54776 +#endif
54777 +
54778 + )
54779 + {
54780 + *flags &= ~MF_PAX_PAGEEXEC;
54781 + retval = -EINVAL;
54782 + }
54783 +
54784 + if ((*flags & MF_PAX_MPROTECT)
54785 +
54786 +#ifdef CONFIG_PAX_MPROTECT
54787 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
54788 +#endif
54789 +
54790 + )
54791 + {
54792 + *flags &= ~MF_PAX_MPROTECT;
54793 + retval = -EINVAL;
54794 + }
54795 +
54796 + if ((*flags & MF_PAX_EMUTRAMP)
54797 +
54798 +#ifdef CONFIG_PAX_EMUTRAMP
54799 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
54800 +#endif
54801 +
54802 + )
54803 + {
54804 + *flags &= ~MF_PAX_EMUTRAMP;
54805 + retval = -EINVAL;
54806 + }
54807 +
54808 + return retval;
54809 +}
54810 +
54811 +EXPORT_SYMBOL(pax_check_flags);
54812 +
54813 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54814 +char *pax_get_path(const struct path *path, char *buf, int buflen)
54815 +{
54816 + char *pathname = d_path(path, buf, buflen);
54817 +
54818 + if (IS_ERR(pathname))
54819 + goto toolong;
54820 +
54821 + pathname = mangle_path(buf, pathname, "\t\n\\");
54822 + if (!pathname)
54823 + goto toolong;
54824 +
54825 + *pathname = 0;
54826 + return buf;
54827 +
54828 +toolong:
54829 + return "<path too long>";
54830 +}
54831 +EXPORT_SYMBOL(pax_get_path);
54832 +
54833 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
54834 +{
54835 + struct task_struct *tsk = current;
54836 + struct mm_struct *mm = current->mm;
54837 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
54838 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
54839 + char *path_exec = NULL;
54840 + char *path_fault = NULL;
54841 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
54842 + siginfo_t info = { };
54843 +
54844 + if (buffer_exec && buffer_fault) {
54845 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
54846 +
54847 + down_read(&mm->mmap_sem);
54848 + vma = mm->mmap;
54849 + while (vma && (!vma_exec || !vma_fault)) {
54850 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
54851 + vma_exec = vma;
54852 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
54853 + vma_fault = vma;
54854 + vma = vma->vm_next;
54855 + }
54856 + if (vma_exec)
54857 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
54858 + if (vma_fault) {
54859 + start = vma_fault->vm_start;
54860 + end = vma_fault->vm_end;
54861 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
54862 + if (vma_fault->vm_file)
54863 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
54864 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
54865 + path_fault = "<heap>";
54866 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
54867 + path_fault = "<stack>";
54868 + else
54869 + path_fault = "<anonymous mapping>";
54870 + }
54871 + up_read(&mm->mmap_sem);
54872 + }
54873 + if (tsk->signal->curr_ip)
54874 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
54875 + else
54876 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
54877 + 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),
54878 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
54879 + free_page((unsigned long)buffer_exec);
54880 + free_page((unsigned long)buffer_fault);
54881 + pax_report_insns(regs, pc, sp);
54882 + info.si_signo = SIGKILL;
54883 + info.si_errno = 0;
54884 + info.si_code = SI_KERNEL;
54885 + info.si_pid = 0;
54886 + info.si_uid = 0;
54887 + do_coredump(&info);
54888 +}
54889 +#endif
54890 +
54891 +#ifdef CONFIG_PAX_REFCOUNT
54892 +void pax_report_refcount_overflow(struct pt_regs *regs)
54893 +{
54894 + if (current->signal->curr_ip)
54895 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
54896 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
54897 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
54898 + else
54899 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
54900 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
54901 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
54902 + preempt_disable();
54903 + show_regs(regs);
54904 + preempt_enable();
54905 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
54906 +}
54907 +#endif
54908 +
54909 +#ifdef CONFIG_PAX_USERCOPY
54910 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
54911 +static noinline int check_stack_object(const void *obj, unsigned long len)
54912 +{
54913 + const void * const stack = task_stack_page(current);
54914 + const void * const stackend = stack + THREAD_SIZE;
54915 +
54916 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
54917 + const void *frame = NULL;
54918 + const void *oldframe;
54919 +#endif
54920 +
54921 + if (obj + len < obj)
54922 + return -1;
54923 +
54924 + if (obj + len <= stack || stackend <= obj)
54925 + return 0;
54926 +
54927 + if (obj < stack || stackend < obj + len)
54928 + return -1;
54929 +
54930 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
54931 + oldframe = __builtin_frame_address(1);
54932 + if (oldframe)
54933 + frame = __builtin_frame_address(2);
54934 + /*
54935 + low ----------------------------------------------> high
54936 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
54937 + ^----------------^
54938 + allow copies only within here
54939 + */
54940 + while (stack <= frame && frame < stackend) {
54941 + /* if obj + len extends past the last frame, this
54942 + check won't pass and the next frame will be 0,
54943 + causing us to bail out and correctly report
54944 + the copy as invalid
54945 + */
54946 + if (obj + len <= frame)
54947 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
54948 + oldframe = frame;
54949 + frame = *(const void * const *)frame;
54950 + }
54951 + return -1;
54952 +#else
54953 + return 1;
54954 +#endif
54955 +}
54956 +
54957 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
54958 +{
54959 + if (current->signal->curr_ip)
54960 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
54961 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
54962 + else
54963 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
54964 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
54965 + dump_stack();
54966 + gr_handle_kernel_exploit();
54967 + do_group_exit(SIGKILL);
54968 +}
54969 +#endif
54970 +
54971 +#ifdef CONFIG_PAX_USERCOPY
54972 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
54973 +{
54974 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
54975 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
54976 +#ifdef CONFIG_MODULES
54977 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
54978 +#else
54979 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
54980 +#endif
54981 +
54982 +#else
54983 + unsigned long textlow = (unsigned long)_stext;
54984 + unsigned long texthigh = (unsigned long)_etext;
54985 +#endif
54986 +
54987 + if (high <= textlow || low > texthigh)
54988 + return false;
54989 + else
54990 + return true;
54991 +}
54992 +#endif
54993 +
54994 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
54995 +{
54996 +
54997 +#ifdef CONFIG_PAX_USERCOPY
54998 + const char *type;
54999 +
55000 + if (!n)
55001 + return;
55002 +
55003 + type = check_heap_object(ptr, n);
55004 + if (!type) {
55005 + int ret = check_stack_object(ptr, n);
55006 + if (ret == 1 || ret == 2)
55007 + return;
55008 + if (ret == 0) {
55009 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55010 + type = "<kernel text>";
55011 + else
55012 + return;
55013 + } else
55014 + type = "<process stack>";
55015 + }
55016 +
55017 + pax_report_usercopy(ptr, n, to_user, type);
55018 +#endif
55019 +
55020 +}
55021 +EXPORT_SYMBOL(__check_object_size);
55022 +
55023 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55024 +void pax_track_stack(void)
55025 +{
55026 + unsigned long sp = (unsigned long)&sp;
55027 + if (sp < current_thread_info()->lowest_stack &&
55028 + sp > (unsigned long)task_stack_page(current))
55029 + current_thread_info()->lowest_stack = sp;
55030 +}
55031 +EXPORT_SYMBOL(pax_track_stack);
55032 +#endif
55033 +
55034 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55035 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55036 +{
55037 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55038 + dump_stack();
55039 + do_group_exit(SIGKILL);
55040 +}
55041 +EXPORT_SYMBOL(report_size_overflow);
55042 +#endif
55043 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55044 index 9f9992b..8b59411 100644
55045 --- a/fs/ext2/balloc.c
55046 +++ b/fs/ext2/balloc.c
55047 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55048
55049 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55050 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55051 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55052 + if (free_blocks < root_blocks + 1 &&
55053 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55054 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55055 - !in_group_p (sbi->s_resgid))) {
55056 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55057 return 0;
55058 }
55059 return 1;
55060 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55061 index 22548f5..41521d8 100644
55062 --- a/fs/ext3/balloc.c
55063 +++ b/fs/ext3/balloc.c
55064 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55065
55066 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55067 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55068 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55069 + if (free_blocks < root_blocks + 1 &&
55070 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55071 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55072 - !in_group_p (sbi->s_resgid))) {
55073 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55074 return 0;
55075 }
55076 return 1;
55077 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55078 index ddd715e..c772f88 100644
55079 --- a/fs/ext4/balloc.c
55080 +++ b/fs/ext4/balloc.c
55081 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55082 /* Hm, nope. Are (enough) root reserved clusters available? */
55083 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55084 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55085 - capable(CAP_SYS_RESOURCE) ||
55086 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55087 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55088 + capable_nolog(CAP_SYS_RESOURCE)) {
55089
55090 if (free_clusters >= (nclusters + dirty_clusters +
55091 resv_clusters))
55092 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55093 index 0ab26fb..b6ecb39 100644
55094 --- a/fs/ext4/ext4.h
55095 +++ b/fs/ext4/ext4.h
55096 @@ -1247,19 +1247,19 @@ struct ext4_sb_info {
55097 unsigned long s_mb_last_start;
55098
55099 /* stats for buddy allocator */
55100 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55101 - atomic_t s_bal_success; /* we found long enough chunks */
55102 - atomic_t s_bal_allocated; /* in blocks */
55103 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55104 - atomic_t s_bal_goals; /* goal hits */
55105 - atomic_t s_bal_breaks; /* too long searches */
55106 - atomic_t s_bal_2orders; /* 2^order hits */
55107 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55108 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55109 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55110 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55111 + atomic_unchecked_t s_bal_goals; /* goal hits */
55112 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55113 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55114 spinlock_t s_bal_lock;
55115 unsigned long s_mb_buddies_generated;
55116 unsigned long long s_mb_generation_time;
55117 - atomic_t s_mb_lost_chunks;
55118 - atomic_t s_mb_preallocated;
55119 - atomic_t s_mb_discarded;
55120 + atomic_unchecked_t s_mb_lost_chunks;
55121 + atomic_unchecked_t s_mb_preallocated;
55122 + atomic_unchecked_t s_mb_discarded;
55123 atomic_t s_lock_busy;
55124
55125 /* locality groups */
55126 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55127 index 4bbbf13b..dcceaeb 100644
55128 --- a/fs/ext4/mballoc.c
55129 +++ b/fs/ext4/mballoc.c
55130 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55131 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55132
55133 if (EXT4_SB(sb)->s_mb_stats)
55134 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55135 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55136
55137 break;
55138 }
55139 @@ -2171,7 +2171,7 @@ repeat:
55140 ac->ac_status = AC_STATUS_CONTINUE;
55141 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55142 cr = 3;
55143 - atomic_inc(&sbi->s_mb_lost_chunks);
55144 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55145 goto repeat;
55146 }
55147 }
55148 @@ -2679,25 +2679,25 @@ int ext4_mb_release(struct super_block *sb)
55149 if (sbi->s_mb_stats) {
55150 ext4_msg(sb, KERN_INFO,
55151 "mballoc: %u blocks %u reqs (%u success)",
55152 - atomic_read(&sbi->s_bal_allocated),
55153 - atomic_read(&sbi->s_bal_reqs),
55154 - atomic_read(&sbi->s_bal_success));
55155 + atomic_read_unchecked(&sbi->s_bal_allocated),
55156 + atomic_read_unchecked(&sbi->s_bal_reqs),
55157 + atomic_read_unchecked(&sbi->s_bal_success));
55158 ext4_msg(sb, KERN_INFO,
55159 "mballoc: %u extents scanned, %u goal hits, "
55160 "%u 2^N hits, %u breaks, %u lost",
55161 - atomic_read(&sbi->s_bal_ex_scanned),
55162 - atomic_read(&sbi->s_bal_goals),
55163 - atomic_read(&sbi->s_bal_2orders),
55164 - atomic_read(&sbi->s_bal_breaks),
55165 - atomic_read(&sbi->s_mb_lost_chunks));
55166 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55167 + atomic_read_unchecked(&sbi->s_bal_goals),
55168 + atomic_read_unchecked(&sbi->s_bal_2orders),
55169 + atomic_read_unchecked(&sbi->s_bal_breaks),
55170 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55171 ext4_msg(sb, KERN_INFO,
55172 "mballoc: %lu generated and it took %Lu",
55173 sbi->s_mb_buddies_generated,
55174 sbi->s_mb_generation_time);
55175 ext4_msg(sb, KERN_INFO,
55176 "mballoc: %u preallocated, %u discarded",
55177 - atomic_read(&sbi->s_mb_preallocated),
55178 - atomic_read(&sbi->s_mb_discarded));
55179 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55180 + atomic_read_unchecked(&sbi->s_mb_discarded));
55181 }
55182
55183 free_percpu(sbi->s_locality_groups);
55184 @@ -3151,16 +3151,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55185 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55186
55187 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55188 - atomic_inc(&sbi->s_bal_reqs);
55189 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55190 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55191 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55192 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
55193 - atomic_inc(&sbi->s_bal_success);
55194 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
55195 + atomic_inc_unchecked(&sbi->s_bal_success);
55196 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
55197 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
55198 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
55199 - atomic_inc(&sbi->s_bal_goals);
55200 + atomic_inc_unchecked(&sbi->s_bal_goals);
55201 if (ac->ac_found > sbi->s_mb_max_to_scan)
55202 - atomic_inc(&sbi->s_bal_breaks);
55203 + atomic_inc_unchecked(&sbi->s_bal_breaks);
55204 }
55205
55206 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
55207 @@ -3560,7 +3560,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
55208 trace_ext4_mb_new_inode_pa(ac, pa);
55209
55210 ext4_mb_use_inode_pa(ac, pa);
55211 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
55212 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
55213
55214 ei = EXT4_I(ac->ac_inode);
55215 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55216 @@ -3620,7 +3620,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
55217 trace_ext4_mb_new_group_pa(ac, pa);
55218
55219 ext4_mb_use_group_pa(ac, pa);
55220 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55221 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55222
55223 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55224 lg = ac->ac_lg;
55225 @@ -3709,7 +3709,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
55226 * from the bitmap and continue.
55227 */
55228 }
55229 - atomic_add(free, &sbi->s_mb_discarded);
55230 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
55231
55232 return err;
55233 }
55234 @@ -3727,7 +3727,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
55235 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
55236 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
55237 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
55238 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55239 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55240 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
55241
55242 return 0;
55243 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
55244 index 214461e..3614c89 100644
55245 --- a/fs/ext4/mmp.c
55246 +++ b/fs/ext4/mmp.c
55247 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
55248 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
55249 const char *function, unsigned int line, const char *msg)
55250 {
55251 - __ext4_warning(sb, function, line, msg);
55252 + __ext4_warning(sb, function, line, "%s", msg);
55253 __ext4_warning(sb, function, line,
55254 "MMP failure info: last update time: %llu, last update "
55255 "node: %s, last update device: %s\n",
55256 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
55257 index b59373b..f41c2b5 100644
55258 --- a/fs/ext4/super.c
55259 +++ b/fs/ext4/super.c
55260 @@ -1254,7 +1254,7 @@ static ext4_fsblk_t get_sb_block(void **data)
55261 }
55262
55263 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
55264 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55265 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55266 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
55267
55268 #ifdef CONFIG_QUOTA
55269 @@ -2394,7 +2394,7 @@ struct ext4_attr {
55270 int offset;
55271 int deprecated_val;
55272 } u;
55273 -};
55274 +} __do_const;
55275
55276 static int parse_strtoull(const char *buf,
55277 unsigned long long max, unsigned long long *value)
55278 diff --git a/fs/fcntl.c b/fs/fcntl.c
55279 index 65343c3..9969dcf 100644
55280 --- a/fs/fcntl.c
55281 +++ b/fs/fcntl.c
55282 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
55283 if (err)
55284 return err;
55285
55286 + if (gr_handle_chroot_fowner(pid, type))
55287 + return -ENOENT;
55288 + if (gr_check_protected_task_fowner(pid, type))
55289 + return -EACCES;
55290 +
55291 f_modown(filp, pid, type, force);
55292 return 0;
55293 }
55294 diff --git a/fs/fhandle.c b/fs/fhandle.c
55295 index 999ff5c..41f4109 100644
55296 --- a/fs/fhandle.c
55297 +++ b/fs/fhandle.c
55298 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
55299 } else
55300 retval = 0;
55301 /* copy the mount id */
55302 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
55303 - sizeof(*mnt_id)) ||
55304 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
55305 copy_to_user(ufh, handle,
55306 sizeof(struct file_handle) + handle_bytes))
55307 retval = -EFAULT;
55308 diff --git a/fs/file.c b/fs/file.c
55309 index 4a78f98..9447397 100644
55310 --- a/fs/file.c
55311 +++ b/fs/file.c
55312 @@ -16,6 +16,7 @@
55313 #include <linux/slab.h>
55314 #include <linux/vmalloc.h>
55315 #include <linux/file.h>
55316 +#include <linux/security.h>
55317 #include <linux/fdtable.h>
55318 #include <linux/bitops.h>
55319 #include <linux/interrupt.h>
55320 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
55321 if (!file)
55322 return __close_fd(files, fd);
55323
55324 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
55325 if (fd >= rlimit(RLIMIT_NOFILE))
55326 return -EBADF;
55327
55328 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
55329 if (unlikely(oldfd == newfd))
55330 return -EINVAL;
55331
55332 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
55333 if (newfd >= rlimit(RLIMIT_NOFILE))
55334 return -EBADF;
55335
55336 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
55337 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
55338 {
55339 int err;
55340 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
55341 if (from >= rlimit(RLIMIT_NOFILE))
55342 return -EINVAL;
55343 err = alloc_fd(from, flags);
55344 diff --git a/fs/filesystems.c b/fs/filesystems.c
55345 index 92567d9..fcd8cbf 100644
55346 --- a/fs/filesystems.c
55347 +++ b/fs/filesystems.c
55348 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
55349 int len = dot ? dot - name : strlen(name);
55350
55351 fs = __get_fs_type(name, len);
55352 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
55353 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
55354 +#else
55355 if (!fs && (request_module("fs-%.*s", len, name) == 0))
55356 +#endif
55357 fs = __get_fs_type(name, len);
55358
55359 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
55360 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
55361 index d8ac61d..79a36f0 100644
55362 --- a/fs/fs_struct.c
55363 +++ b/fs/fs_struct.c
55364 @@ -4,6 +4,7 @@
55365 #include <linux/path.h>
55366 #include <linux/slab.h>
55367 #include <linux/fs_struct.h>
55368 +#include <linux/grsecurity.h>
55369 #include "internal.h"
55370
55371 /*
55372 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
55373 write_seqcount_begin(&fs->seq);
55374 old_root = fs->root;
55375 fs->root = *path;
55376 + gr_set_chroot_entries(current, path);
55377 write_seqcount_end(&fs->seq);
55378 spin_unlock(&fs->lock);
55379 if (old_root.dentry)
55380 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
55381 int hits = 0;
55382 spin_lock(&fs->lock);
55383 write_seqcount_begin(&fs->seq);
55384 + /* this root replacement is only done by pivot_root,
55385 + leave grsec's chroot tagging alone for this task
55386 + so that a pivoted root isn't treated as a chroot
55387 + */
55388 hits += replace_path(&fs->root, old_root, new_root);
55389 hits += replace_path(&fs->pwd, old_root, new_root);
55390 write_seqcount_end(&fs->seq);
55391 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
55392 task_lock(tsk);
55393 spin_lock(&fs->lock);
55394 tsk->fs = NULL;
55395 - kill = !--fs->users;
55396 + gr_clear_chroot_entries(tsk);
55397 + kill = !atomic_dec_return(&fs->users);
55398 spin_unlock(&fs->lock);
55399 task_unlock(tsk);
55400 if (kill)
55401 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55402 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
55403 /* We don't need to lock fs - think why ;-) */
55404 if (fs) {
55405 - fs->users = 1;
55406 + atomic_set(&fs->users, 1);
55407 fs->in_exec = 0;
55408 spin_lock_init(&fs->lock);
55409 seqcount_init(&fs->seq);
55410 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55411 spin_lock(&old->lock);
55412 fs->root = old->root;
55413 path_get(&fs->root);
55414 + /* instead of calling gr_set_chroot_entries here,
55415 + we call it from every caller of this function
55416 + */
55417 fs->pwd = old->pwd;
55418 path_get(&fs->pwd);
55419 spin_unlock(&old->lock);
55420 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
55421
55422 task_lock(current);
55423 spin_lock(&fs->lock);
55424 - kill = !--fs->users;
55425 + kill = !atomic_dec_return(&fs->users);
55426 current->fs = new_fs;
55427 + gr_set_chroot_entries(current, &new_fs->root);
55428 spin_unlock(&fs->lock);
55429 task_unlock(current);
55430
55431 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
55432
55433 int current_umask(void)
55434 {
55435 - return current->fs->umask;
55436 + return current->fs->umask | gr_acl_umask();
55437 }
55438 EXPORT_SYMBOL(current_umask);
55439
55440 /* to be mentioned only in INIT_TASK */
55441 struct fs_struct init_fs = {
55442 - .users = 1,
55443 + .users = ATOMIC_INIT(1),
55444 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
55445 .seq = SEQCNT_ZERO,
55446 .umask = 0022,
55447 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
55448 index 0e91a3c..6c6d2e0 100644
55449 --- a/fs/fscache/cookie.c
55450 +++ b/fs/fscache/cookie.c
55451 @@ -19,7 +19,7 @@
55452
55453 struct kmem_cache *fscache_cookie_jar;
55454
55455 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
55456 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
55457
55458 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
55459 static int fscache_alloc_object(struct fscache_cache *cache,
55460 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
55461 parent ? (char *) parent->def->name : "<no-parent>",
55462 def->name, netfs_data);
55463
55464 - fscache_stat(&fscache_n_acquires);
55465 + fscache_stat_unchecked(&fscache_n_acquires);
55466
55467 /* if there's no parent cookie, then we don't create one here either */
55468 if (!parent) {
55469 - fscache_stat(&fscache_n_acquires_null);
55470 + fscache_stat_unchecked(&fscache_n_acquires_null);
55471 _leave(" [no parent]");
55472 return NULL;
55473 }
55474 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
55475 /* allocate and initialise a cookie */
55476 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
55477 if (!cookie) {
55478 - fscache_stat(&fscache_n_acquires_oom);
55479 + fscache_stat_unchecked(&fscache_n_acquires_oom);
55480 _leave(" [ENOMEM]");
55481 return NULL;
55482 }
55483 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55484
55485 switch (cookie->def->type) {
55486 case FSCACHE_COOKIE_TYPE_INDEX:
55487 - fscache_stat(&fscache_n_cookie_index);
55488 + fscache_stat_unchecked(&fscache_n_cookie_index);
55489 break;
55490 case FSCACHE_COOKIE_TYPE_DATAFILE:
55491 - fscache_stat(&fscache_n_cookie_data);
55492 + fscache_stat_unchecked(&fscache_n_cookie_data);
55493 break;
55494 default:
55495 - fscache_stat(&fscache_n_cookie_special);
55496 + fscache_stat_unchecked(&fscache_n_cookie_special);
55497 break;
55498 }
55499
55500 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
55501 if (fscache_acquire_non_index_cookie(cookie) < 0) {
55502 atomic_dec(&parent->n_children);
55503 __fscache_cookie_put(cookie);
55504 - fscache_stat(&fscache_n_acquires_nobufs);
55505 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
55506 _leave(" = NULL");
55507 return NULL;
55508 }
55509 }
55510
55511 - fscache_stat(&fscache_n_acquires_ok);
55512 + fscache_stat_unchecked(&fscache_n_acquires_ok);
55513 _leave(" = %p", cookie);
55514 return cookie;
55515 }
55516 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
55517 cache = fscache_select_cache_for_object(cookie->parent);
55518 if (!cache) {
55519 up_read(&fscache_addremove_sem);
55520 - fscache_stat(&fscache_n_acquires_no_cache);
55521 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
55522 _leave(" = -ENOMEDIUM [no cache]");
55523 return -ENOMEDIUM;
55524 }
55525 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
55526 object = cache->ops->alloc_object(cache, cookie);
55527 fscache_stat_d(&fscache_n_cop_alloc_object);
55528 if (IS_ERR(object)) {
55529 - fscache_stat(&fscache_n_object_no_alloc);
55530 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
55531 ret = PTR_ERR(object);
55532 goto error;
55533 }
55534
55535 - fscache_stat(&fscache_n_object_alloc);
55536 + fscache_stat_unchecked(&fscache_n_object_alloc);
55537
55538 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
55539 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
55540
55541 _debug("ALLOC OBJ%x: %s {%lx}",
55542 object->debug_id, cookie->def->name, object->events);
55543 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
55544
55545 _enter("{%s}", cookie->def->name);
55546
55547 - fscache_stat(&fscache_n_invalidates);
55548 + fscache_stat_unchecked(&fscache_n_invalidates);
55549
55550 /* Only permit invalidation of data files. Invalidating an index will
55551 * require the caller to release all its attachments to the tree rooted
55552 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
55553 {
55554 struct fscache_object *object;
55555
55556 - fscache_stat(&fscache_n_updates);
55557 + fscache_stat_unchecked(&fscache_n_updates);
55558
55559 if (!cookie) {
55560 - fscache_stat(&fscache_n_updates_null);
55561 + fscache_stat_unchecked(&fscache_n_updates_null);
55562 _leave(" [no cookie]");
55563 return;
55564 }
55565 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
55566 {
55567 struct fscache_object *object;
55568
55569 - fscache_stat(&fscache_n_relinquishes);
55570 + fscache_stat_unchecked(&fscache_n_relinquishes);
55571 if (retire)
55572 - fscache_stat(&fscache_n_relinquishes_retire);
55573 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
55574
55575 if (!cookie) {
55576 - fscache_stat(&fscache_n_relinquishes_null);
55577 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
55578 _leave(" [no cookie]");
55579 return;
55580 }
55581 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
55582 index 12d505b..86473a3 100644
55583 --- a/fs/fscache/internal.h
55584 +++ b/fs/fscache/internal.h
55585 @@ -147,101 +147,101 @@ extern void fscache_proc_cleanup(void);
55586 * stats.c
55587 */
55588 #ifdef CONFIG_FSCACHE_STATS
55589 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55590 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55591 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
55592 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
55593
55594 -extern atomic_t fscache_n_op_pend;
55595 -extern atomic_t fscache_n_op_run;
55596 -extern atomic_t fscache_n_op_enqueue;
55597 -extern atomic_t fscache_n_op_deferred_release;
55598 -extern atomic_t fscache_n_op_release;
55599 -extern atomic_t fscache_n_op_gc;
55600 -extern atomic_t fscache_n_op_cancelled;
55601 -extern atomic_t fscache_n_op_rejected;
55602 +extern atomic_unchecked_t fscache_n_op_pend;
55603 +extern atomic_unchecked_t fscache_n_op_run;
55604 +extern atomic_unchecked_t fscache_n_op_enqueue;
55605 +extern atomic_unchecked_t fscache_n_op_deferred_release;
55606 +extern atomic_unchecked_t fscache_n_op_release;
55607 +extern atomic_unchecked_t fscache_n_op_gc;
55608 +extern atomic_unchecked_t fscache_n_op_cancelled;
55609 +extern atomic_unchecked_t fscache_n_op_rejected;
55610
55611 -extern atomic_t fscache_n_attr_changed;
55612 -extern atomic_t fscache_n_attr_changed_ok;
55613 -extern atomic_t fscache_n_attr_changed_nobufs;
55614 -extern atomic_t fscache_n_attr_changed_nomem;
55615 -extern atomic_t fscache_n_attr_changed_calls;
55616 +extern atomic_unchecked_t fscache_n_attr_changed;
55617 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
55618 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
55619 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
55620 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
55621
55622 -extern atomic_t fscache_n_allocs;
55623 -extern atomic_t fscache_n_allocs_ok;
55624 -extern atomic_t fscache_n_allocs_wait;
55625 -extern atomic_t fscache_n_allocs_nobufs;
55626 -extern atomic_t fscache_n_allocs_intr;
55627 -extern atomic_t fscache_n_allocs_object_dead;
55628 -extern atomic_t fscache_n_alloc_ops;
55629 -extern atomic_t fscache_n_alloc_op_waits;
55630 +extern atomic_unchecked_t fscache_n_allocs;
55631 +extern atomic_unchecked_t fscache_n_allocs_ok;
55632 +extern atomic_unchecked_t fscache_n_allocs_wait;
55633 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
55634 +extern atomic_unchecked_t fscache_n_allocs_intr;
55635 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
55636 +extern atomic_unchecked_t fscache_n_alloc_ops;
55637 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
55638
55639 -extern atomic_t fscache_n_retrievals;
55640 -extern atomic_t fscache_n_retrievals_ok;
55641 -extern atomic_t fscache_n_retrievals_wait;
55642 -extern atomic_t fscache_n_retrievals_nodata;
55643 -extern atomic_t fscache_n_retrievals_nobufs;
55644 -extern atomic_t fscache_n_retrievals_intr;
55645 -extern atomic_t fscache_n_retrievals_nomem;
55646 -extern atomic_t fscache_n_retrievals_object_dead;
55647 -extern atomic_t fscache_n_retrieval_ops;
55648 -extern atomic_t fscache_n_retrieval_op_waits;
55649 +extern atomic_unchecked_t fscache_n_retrievals;
55650 +extern atomic_unchecked_t fscache_n_retrievals_ok;
55651 +extern atomic_unchecked_t fscache_n_retrievals_wait;
55652 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
55653 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
55654 +extern atomic_unchecked_t fscache_n_retrievals_intr;
55655 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
55656 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
55657 +extern atomic_unchecked_t fscache_n_retrieval_ops;
55658 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
55659
55660 -extern atomic_t fscache_n_stores;
55661 -extern atomic_t fscache_n_stores_ok;
55662 -extern atomic_t fscache_n_stores_again;
55663 -extern atomic_t fscache_n_stores_nobufs;
55664 -extern atomic_t fscache_n_stores_oom;
55665 -extern atomic_t fscache_n_store_ops;
55666 -extern atomic_t fscache_n_store_calls;
55667 -extern atomic_t fscache_n_store_pages;
55668 -extern atomic_t fscache_n_store_radix_deletes;
55669 -extern atomic_t fscache_n_store_pages_over_limit;
55670 +extern atomic_unchecked_t fscache_n_stores;
55671 +extern atomic_unchecked_t fscache_n_stores_ok;
55672 +extern atomic_unchecked_t fscache_n_stores_again;
55673 +extern atomic_unchecked_t fscache_n_stores_nobufs;
55674 +extern atomic_unchecked_t fscache_n_stores_oom;
55675 +extern atomic_unchecked_t fscache_n_store_ops;
55676 +extern atomic_unchecked_t fscache_n_store_calls;
55677 +extern atomic_unchecked_t fscache_n_store_pages;
55678 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
55679 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
55680
55681 -extern atomic_t fscache_n_store_vmscan_not_storing;
55682 -extern atomic_t fscache_n_store_vmscan_gone;
55683 -extern atomic_t fscache_n_store_vmscan_busy;
55684 -extern atomic_t fscache_n_store_vmscan_cancelled;
55685 -extern atomic_t fscache_n_store_vmscan_wait;
55686 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
55687 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
55688 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
55689 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
55690 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
55691
55692 -extern atomic_t fscache_n_marks;
55693 -extern atomic_t fscache_n_uncaches;
55694 +extern atomic_unchecked_t fscache_n_marks;
55695 +extern atomic_unchecked_t fscache_n_uncaches;
55696
55697 -extern atomic_t fscache_n_acquires;
55698 -extern atomic_t fscache_n_acquires_null;
55699 -extern atomic_t fscache_n_acquires_no_cache;
55700 -extern atomic_t fscache_n_acquires_ok;
55701 -extern atomic_t fscache_n_acquires_nobufs;
55702 -extern atomic_t fscache_n_acquires_oom;
55703 +extern atomic_unchecked_t fscache_n_acquires;
55704 +extern atomic_unchecked_t fscache_n_acquires_null;
55705 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
55706 +extern atomic_unchecked_t fscache_n_acquires_ok;
55707 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
55708 +extern atomic_unchecked_t fscache_n_acquires_oom;
55709
55710 -extern atomic_t fscache_n_invalidates;
55711 -extern atomic_t fscache_n_invalidates_run;
55712 +extern atomic_unchecked_t fscache_n_invalidates;
55713 +extern atomic_unchecked_t fscache_n_invalidates_run;
55714
55715 -extern atomic_t fscache_n_updates;
55716 -extern atomic_t fscache_n_updates_null;
55717 -extern atomic_t fscache_n_updates_run;
55718 +extern atomic_unchecked_t fscache_n_updates;
55719 +extern atomic_unchecked_t fscache_n_updates_null;
55720 +extern atomic_unchecked_t fscache_n_updates_run;
55721
55722 -extern atomic_t fscache_n_relinquishes;
55723 -extern atomic_t fscache_n_relinquishes_null;
55724 -extern atomic_t fscache_n_relinquishes_waitcrt;
55725 -extern atomic_t fscache_n_relinquishes_retire;
55726 +extern atomic_unchecked_t fscache_n_relinquishes;
55727 +extern atomic_unchecked_t fscache_n_relinquishes_null;
55728 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
55729 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
55730
55731 -extern atomic_t fscache_n_cookie_index;
55732 -extern atomic_t fscache_n_cookie_data;
55733 -extern atomic_t fscache_n_cookie_special;
55734 +extern atomic_unchecked_t fscache_n_cookie_index;
55735 +extern atomic_unchecked_t fscache_n_cookie_data;
55736 +extern atomic_unchecked_t fscache_n_cookie_special;
55737
55738 -extern atomic_t fscache_n_object_alloc;
55739 -extern atomic_t fscache_n_object_no_alloc;
55740 -extern atomic_t fscache_n_object_lookups;
55741 -extern atomic_t fscache_n_object_lookups_negative;
55742 -extern atomic_t fscache_n_object_lookups_positive;
55743 -extern atomic_t fscache_n_object_lookups_timed_out;
55744 -extern atomic_t fscache_n_object_created;
55745 -extern atomic_t fscache_n_object_avail;
55746 -extern atomic_t fscache_n_object_dead;
55747 +extern atomic_unchecked_t fscache_n_object_alloc;
55748 +extern atomic_unchecked_t fscache_n_object_no_alloc;
55749 +extern atomic_unchecked_t fscache_n_object_lookups;
55750 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
55751 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
55752 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
55753 +extern atomic_unchecked_t fscache_n_object_created;
55754 +extern atomic_unchecked_t fscache_n_object_avail;
55755 +extern atomic_unchecked_t fscache_n_object_dead;
55756
55757 -extern atomic_t fscache_n_checkaux_none;
55758 -extern atomic_t fscache_n_checkaux_okay;
55759 -extern atomic_t fscache_n_checkaux_update;
55760 -extern atomic_t fscache_n_checkaux_obsolete;
55761 +extern atomic_unchecked_t fscache_n_checkaux_none;
55762 +extern atomic_unchecked_t fscache_n_checkaux_okay;
55763 +extern atomic_unchecked_t fscache_n_checkaux_update;
55764 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
55765
55766 extern atomic_t fscache_n_cop_alloc_object;
55767 extern atomic_t fscache_n_cop_lookup_object;
55768 @@ -266,6 +266,11 @@ static inline void fscache_stat(atomic_t *stat)
55769 atomic_inc(stat);
55770 }
55771
55772 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
55773 +{
55774 + atomic_inc_unchecked(stat);
55775 +}
55776 +
55777 static inline void fscache_stat_d(atomic_t *stat)
55778 {
55779 atomic_dec(stat);
55780 @@ -278,6 +283,7 @@ extern const struct file_operations fscache_stats_fops;
55781
55782 #define __fscache_stat(stat) (NULL)
55783 #define fscache_stat(stat) do {} while (0)
55784 +#define fscache_stat_unchecked(stat) do {} while (0)
55785 #define fscache_stat_d(stat) do {} while (0)
55786 #endif
55787
55788 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
55789 index 86d75a6..5f3d7a0 100644
55790 --- a/fs/fscache/object.c
55791 +++ b/fs/fscache/object.c
55792 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
55793 _debug("LOOKUP \"%s\" in \"%s\"",
55794 cookie->def->name, object->cache->tag->name);
55795
55796 - fscache_stat(&fscache_n_object_lookups);
55797 + fscache_stat_unchecked(&fscache_n_object_lookups);
55798 fscache_stat(&fscache_n_cop_lookup_object);
55799 ret = object->cache->ops->lookup_object(object);
55800 fscache_stat_d(&fscache_n_cop_lookup_object);
55801 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
55802 if (ret == -ETIMEDOUT) {
55803 /* probably stuck behind another object, so move this one to
55804 * the back of the queue */
55805 - fscache_stat(&fscache_n_object_lookups_timed_out);
55806 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
55807 _leave(" [timeout]");
55808 return NO_TRANSIT;
55809 }
55810 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
55811 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
55812
55813 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
55814 - fscache_stat(&fscache_n_object_lookups_negative);
55815 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
55816
55817 /* Allow write requests to begin stacking up and read requests to begin
55818 * returning ENODATA.
55819 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
55820 /* if we were still looking up, then we must have a positive lookup
55821 * result, in which case there may be data available */
55822 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
55823 - fscache_stat(&fscache_n_object_lookups_positive);
55824 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
55825
55826 /* We do (presumably) have data */
55827 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
55828 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
55829 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
55830 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
55831 } else {
55832 - fscache_stat(&fscache_n_object_created);
55833 + fscache_stat_unchecked(&fscache_n_object_created);
55834 }
55835
55836 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
55837 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
55838 fscache_stat_d(&fscache_n_cop_lookup_complete);
55839
55840 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
55841 - fscache_stat(&fscache_n_object_avail);
55842 + fscache_stat_unchecked(&fscache_n_object_avail);
55843
55844 _leave("");
55845 return transit_to(JUMPSTART_DEPS);
55846 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
55847
55848 /* this just shifts the object release to the work processor */
55849 fscache_put_object(object);
55850 - fscache_stat(&fscache_n_object_dead);
55851 + fscache_stat_unchecked(&fscache_n_object_dead);
55852
55853 _leave("");
55854 return transit_to(OBJECT_DEAD);
55855 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
55856 enum fscache_checkaux result;
55857
55858 if (!object->cookie->def->check_aux) {
55859 - fscache_stat(&fscache_n_checkaux_none);
55860 + fscache_stat_unchecked(&fscache_n_checkaux_none);
55861 return FSCACHE_CHECKAUX_OKAY;
55862 }
55863
55864 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
55865 switch (result) {
55866 /* entry okay as is */
55867 case FSCACHE_CHECKAUX_OKAY:
55868 - fscache_stat(&fscache_n_checkaux_okay);
55869 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
55870 break;
55871
55872 /* entry requires update */
55873 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
55874 - fscache_stat(&fscache_n_checkaux_update);
55875 + fscache_stat_unchecked(&fscache_n_checkaux_update);
55876 break;
55877
55878 /* entry requires deletion */
55879 case FSCACHE_CHECKAUX_OBSOLETE:
55880 - fscache_stat(&fscache_n_checkaux_obsolete);
55881 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
55882 break;
55883
55884 default:
55885 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
55886 {
55887 const struct fscache_state *s;
55888
55889 - fscache_stat(&fscache_n_invalidates_run);
55890 + fscache_stat_unchecked(&fscache_n_invalidates_run);
55891 fscache_stat(&fscache_n_cop_invalidate_object);
55892 s = _fscache_invalidate_object(object, event);
55893 fscache_stat_d(&fscache_n_cop_invalidate_object);
55894 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
55895 {
55896 _enter("{OBJ%x},%d", object->debug_id, event);
55897
55898 - fscache_stat(&fscache_n_updates_run);
55899 + fscache_stat_unchecked(&fscache_n_updates_run);
55900 fscache_stat(&fscache_n_cop_update_object);
55901 object->cache->ops->update_object(object);
55902 fscache_stat_d(&fscache_n_cop_update_object);
55903 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
55904 index 318071a..379938b 100644
55905 --- a/fs/fscache/operation.c
55906 +++ b/fs/fscache/operation.c
55907 @@ -17,7 +17,7 @@
55908 #include <linux/slab.h>
55909 #include "internal.h"
55910
55911 -atomic_t fscache_op_debug_id;
55912 +atomic_unchecked_t fscache_op_debug_id;
55913 EXPORT_SYMBOL(fscache_op_debug_id);
55914
55915 /**
55916 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
55917 ASSERTCMP(atomic_read(&op->usage), >, 0);
55918 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
55919
55920 - fscache_stat(&fscache_n_op_enqueue);
55921 + fscache_stat_unchecked(&fscache_n_op_enqueue);
55922 switch (op->flags & FSCACHE_OP_TYPE) {
55923 case FSCACHE_OP_ASYNC:
55924 _debug("queue async");
55925 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
55926 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
55927 if (op->processor)
55928 fscache_enqueue_operation(op);
55929 - fscache_stat(&fscache_n_op_run);
55930 + fscache_stat_unchecked(&fscache_n_op_run);
55931 }
55932
55933 /*
55934 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
55935 if (object->n_in_progress > 0) {
55936 atomic_inc(&op->usage);
55937 list_add_tail(&op->pend_link, &object->pending_ops);
55938 - fscache_stat(&fscache_n_op_pend);
55939 + fscache_stat_unchecked(&fscache_n_op_pend);
55940 } else if (!list_empty(&object->pending_ops)) {
55941 atomic_inc(&op->usage);
55942 list_add_tail(&op->pend_link, &object->pending_ops);
55943 - fscache_stat(&fscache_n_op_pend);
55944 + fscache_stat_unchecked(&fscache_n_op_pend);
55945 fscache_start_operations(object);
55946 } else {
55947 ASSERTCMP(object->n_in_progress, ==, 0);
55948 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
55949 object->n_exclusive++; /* reads and writes must wait */
55950 atomic_inc(&op->usage);
55951 list_add_tail(&op->pend_link, &object->pending_ops);
55952 - fscache_stat(&fscache_n_op_pend);
55953 + fscache_stat_unchecked(&fscache_n_op_pend);
55954 ret = 0;
55955 } else {
55956 /* If we're in any other state, there must have been an I/O
55957 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
55958 if (object->n_exclusive > 0) {
55959 atomic_inc(&op->usage);
55960 list_add_tail(&op->pend_link, &object->pending_ops);
55961 - fscache_stat(&fscache_n_op_pend);
55962 + fscache_stat_unchecked(&fscache_n_op_pend);
55963 } else if (!list_empty(&object->pending_ops)) {
55964 atomic_inc(&op->usage);
55965 list_add_tail(&op->pend_link, &object->pending_ops);
55966 - fscache_stat(&fscache_n_op_pend);
55967 + fscache_stat_unchecked(&fscache_n_op_pend);
55968 fscache_start_operations(object);
55969 } else {
55970 ASSERTCMP(object->n_exclusive, ==, 0);
55971 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
55972 object->n_ops++;
55973 atomic_inc(&op->usage);
55974 list_add_tail(&op->pend_link, &object->pending_ops);
55975 - fscache_stat(&fscache_n_op_pend);
55976 + fscache_stat_unchecked(&fscache_n_op_pend);
55977 ret = 0;
55978 } else if (fscache_object_is_dying(object)) {
55979 - fscache_stat(&fscache_n_op_rejected);
55980 + fscache_stat_unchecked(&fscache_n_op_rejected);
55981 op->state = FSCACHE_OP_ST_CANCELLED;
55982 ret = -ENOBUFS;
55983 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
55984 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
55985 ret = -EBUSY;
55986 if (op->state == FSCACHE_OP_ST_PENDING) {
55987 ASSERT(!list_empty(&op->pend_link));
55988 - fscache_stat(&fscache_n_op_cancelled);
55989 + fscache_stat_unchecked(&fscache_n_op_cancelled);
55990 list_del_init(&op->pend_link);
55991 if (do_cancel)
55992 do_cancel(op);
55993 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
55994 while (!list_empty(&object->pending_ops)) {
55995 op = list_entry(object->pending_ops.next,
55996 struct fscache_operation, pend_link);
55997 - fscache_stat(&fscache_n_op_cancelled);
55998 + fscache_stat_unchecked(&fscache_n_op_cancelled);
55999 list_del_init(&op->pend_link);
56000
56001 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56002 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56003 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56004 op->state = FSCACHE_OP_ST_DEAD;
56005
56006 - fscache_stat(&fscache_n_op_release);
56007 + fscache_stat_unchecked(&fscache_n_op_release);
56008
56009 if (op->release) {
56010 op->release(op);
56011 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56012 * lock, and defer it otherwise */
56013 if (!spin_trylock(&object->lock)) {
56014 _debug("defer put");
56015 - fscache_stat(&fscache_n_op_deferred_release);
56016 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56017
56018 cache = object->cache;
56019 spin_lock(&cache->op_gc_list_lock);
56020 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56021
56022 _debug("GC DEFERRED REL OBJ%x OP%x",
56023 object->debug_id, op->debug_id);
56024 - fscache_stat(&fscache_n_op_gc);
56025 + fscache_stat_unchecked(&fscache_n_op_gc);
56026
56027 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56028 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56029 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56030 index d479ab3..727a7f2 100644
56031 --- a/fs/fscache/page.c
56032 +++ b/fs/fscache/page.c
56033 @@ -61,7 +61,7 @@ try_again:
56034 val = radix_tree_lookup(&cookie->stores, page->index);
56035 if (!val) {
56036 rcu_read_unlock();
56037 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56038 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56039 __fscache_uncache_page(cookie, page);
56040 return true;
56041 }
56042 @@ -91,11 +91,11 @@ try_again:
56043 spin_unlock(&cookie->stores_lock);
56044
56045 if (xpage) {
56046 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56047 - fscache_stat(&fscache_n_store_radix_deletes);
56048 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56049 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56050 ASSERTCMP(xpage, ==, page);
56051 } else {
56052 - fscache_stat(&fscache_n_store_vmscan_gone);
56053 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56054 }
56055
56056 wake_up_bit(&cookie->flags, 0);
56057 @@ -110,11 +110,11 @@ page_busy:
56058 * sleeping on memory allocation, so we may need to impose a timeout
56059 * too. */
56060 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56061 - fscache_stat(&fscache_n_store_vmscan_busy);
56062 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56063 return false;
56064 }
56065
56066 - fscache_stat(&fscache_n_store_vmscan_wait);
56067 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56068 __fscache_wait_on_page_write(cookie, page);
56069 gfp &= ~__GFP_WAIT;
56070 goto try_again;
56071 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56072 FSCACHE_COOKIE_STORING_TAG);
56073 if (!radix_tree_tag_get(&cookie->stores, page->index,
56074 FSCACHE_COOKIE_PENDING_TAG)) {
56075 - fscache_stat(&fscache_n_store_radix_deletes);
56076 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56077 xpage = radix_tree_delete(&cookie->stores, page->index);
56078 }
56079 spin_unlock(&cookie->stores_lock);
56080 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56081
56082 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56083
56084 - fscache_stat(&fscache_n_attr_changed_calls);
56085 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56086
56087 if (fscache_object_is_active(object) &&
56088 fscache_use_cookie(object)) {
56089 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56090
56091 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56092
56093 - fscache_stat(&fscache_n_attr_changed);
56094 + fscache_stat_unchecked(&fscache_n_attr_changed);
56095
56096 op = kzalloc(sizeof(*op), GFP_KERNEL);
56097 if (!op) {
56098 - fscache_stat(&fscache_n_attr_changed_nomem);
56099 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56100 _leave(" = -ENOMEM");
56101 return -ENOMEM;
56102 }
56103 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56104 if (fscache_submit_exclusive_op(object, op) < 0)
56105 goto nobufs;
56106 spin_unlock(&cookie->lock);
56107 - fscache_stat(&fscache_n_attr_changed_ok);
56108 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56109 fscache_put_operation(op);
56110 _leave(" = 0");
56111 return 0;
56112 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56113 nobufs:
56114 spin_unlock(&cookie->lock);
56115 kfree(op);
56116 - fscache_stat(&fscache_n_attr_changed_nobufs);
56117 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56118 _leave(" = %d", -ENOBUFS);
56119 return -ENOBUFS;
56120 }
56121 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56122 /* allocate a retrieval operation and attempt to submit it */
56123 op = kzalloc(sizeof(*op), GFP_NOIO);
56124 if (!op) {
56125 - fscache_stat(&fscache_n_retrievals_nomem);
56126 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56127 return NULL;
56128 }
56129
56130 @@ -289,13 +289,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56131 return 0;
56132 }
56133
56134 - fscache_stat(&fscache_n_retrievals_wait);
56135 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56136
56137 jif = jiffies;
56138 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56139 fscache_wait_bit_interruptible,
56140 TASK_INTERRUPTIBLE) != 0) {
56141 - fscache_stat(&fscache_n_retrievals_intr);
56142 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56143 _leave(" = -ERESTARTSYS");
56144 return -ERESTARTSYS;
56145 }
56146 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56147 */
56148 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56149 struct fscache_retrieval *op,
56150 - atomic_t *stat_op_waits,
56151 - atomic_t *stat_object_dead)
56152 + atomic_unchecked_t *stat_op_waits,
56153 + atomic_unchecked_t *stat_object_dead)
56154 {
56155 int ret;
56156
56157 @@ -333,7 +333,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56158 goto check_if_dead;
56159
56160 _debug(">>> WT");
56161 - fscache_stat(stat_op_waits);
56162 + fscache_stat_unchecked(stat_op_waits);
56163 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
56164 fscache_wait_bit_interruptible,
56165 TASK_INTERRUPTIBLE) != 0) {
56166 @@ -350,14 +350,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56167
56168 check_if_dead:
56169 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
56170 - fscache_stat(stat_object_dead);
56171 + fscache_stat_unchecked(stat_object_dead);
56172 _leave(" = -ENOBUFS [cancelled]");
56173 return -ENOBUFS;
56174 }
56175 if (unlikely(fscache_object_is_dead(object))) {
56176 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
56177 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
56178 - fscache_stat(stat_object_dead);
56179 + fscache_stat_unchecked(stat_object_dead);
56180 return -ENOBUFS;
56181 }
56182 return 0;
56183 @@ -384,7 +384,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56184
56185 _enter("%p,%p,,,", cookie, page);
56186
56187 - fscache_stat(&fscache_n_retrievals);
56188 + fscache_stat_unchecked(&fscache_n_retrievals);
56189
56190 if (hlist_empty(&cookie->backing_objects))
56191 goto nobufs;
56192 @@ -424,7 +424,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56193 goto nobufs_unlock_dec;
56194 spin_unlock(&cookie->lock);
56195
56196 - fscache_stat(&fscache_n_retrieval_ops);
56197 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56198
56199 /* pin the netfs read context in case we need to do the actual netfs
56200 * read because we've encountered a cache read failure */
56201 @@ -454,15 +454,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56202
56203 error:
56204 if (ret == -ENOMEM)
56205 - fscache_stat(&fscache_n_retrievals_nomem);
56206 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56207 else if (ret == -ERESTARTSYS)
56208 - fscache_stat(&fscache_n_retrievals_intr);
56209 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56210 else if (ret == -ENODATA)
56211 - fscache_stat(&fscache_n_retrievals_nodata);
56212 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56213 else if (ret < 0)
56214 - fscache_stat(&fscache_n_retrievals_nobufs);
56215 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56216 else
56217 - fscache_stat(&fscache_n_retrievals_ok);
56218 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56219
56220 fscache_put_retrieval(op);
56221 _leave(" = %d", ret);
56222 @@ -475,7 +475,7 @@ nobufs_unlock:
56223 atomic_dec(&cookie->n_active);
56224 kfree(op);
56225 nobufs:
56226 - fscache_stat(&fscache_n_retrievals_nobufs);
56227 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56228 _leave(" = -ENOBUFS");
56229 return -ENOBUFS;
56230 }
56231 @@ -513,7 +513,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56232
56233 _enter("%p,,%d,,,", cookie, *nr_pages);
56234
56235 - fscache_stat(&fscache_n_retrievals);
56236 + fscache_stat_unchecked(&fscache_n_retrievals);
56237
56238 if (hlist_empty(&cookie->backing_objects))
56239 goto nobufs;
56240 @@ -549,7 +549,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56241 goto nobufs_unlock_dec;
56242 spin_unlock(&cookie->lock);
56243
56244 - fscache_stat(&fscache_n_retrieval_ops);
56245 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56246
56247 /* pin the netfs read context in case we need to do the actual netfs
56248 * read because we've encountered a cache read failure */
56249 @@ -579,15 +579,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56250
56251 error:
56252 if (ret == -ENOMEM)
56253 - fscache_stat(&fscache_n_retrievals_nomem);
56254 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56255 else if (ret == -ERESTARTSYS)
56256 - fscache_stat(&fscache_n_retrievals_intr);
56257 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56258 else if (ret == -ENODATA)
56259 - fscache_stat(&fscache_n_retrievals_nodata);
56260 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56261 else if (ret < 0)
56262 - fscache_stat(&fscache_n_retrievals_nobufs);
56263 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56264 else
56265 - fscache_stat(&fscache_n_retrievals_ok);
56266 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56267
56268 fscache_put_retrieval(op);
56269 _leave(" = %d", ret);
56270 @@ -600,7 +600,7 @@ nobufs_unlock:
56271 atomic_dec(&cookie->n_active);
56272 kfree(op);
56273 nobufs:
56274 - fscache_stat(&fscache_n_retrievals_nobufs);
56275 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56276 _leave(" = -ENOBUFS");
56277 return -ENOBUFS;
56278 }
56279 @@ -624,7 +624,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56280
56281 _enter("%p,%p,,,", cookie, page);
56282
56283 - fscache_stat(&fscache_n_allocs);
56284 + fscache_stat_unchecked(&fscache_n_allocs);
56285
56286 if (hlist_empty(&cookie->backing_objects))
56287 goto nobufs;
56288 @@ -656,7 +656,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56289 goto nobufs_unlock;
56290 spin_unlock(&cookie->lock);
56291
56292 - fscache_stat(&fscache_n_alloc_ops);
56293 + fscache_stat_unchecked(&fscache_n_alloc_ops);
56294
56295 ret = fscache_wait_for_retrieval_activation(
56296 object, op,
56297 @@ -672,11 +672,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56298
56299 error:
56300 if (ret == -ERESTARTSYS)
56301 - fscache_stat(&fscache_n_allocs_intr);
56302 + fscache_stat_unchecked(&fscache_n_allocs_intr);
56303 else if (ret < 0)
56304 - fscache_stat(&fscache_n_allocs_nobufs);
56305 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56306 else
56307 - fscache_stat(&fscache_n_allocs_ok);
56308 + fscache_stat_unchecked(&fscache_n_allocs_ok);
56309
56310 fscache_put_retrieval(op);
56311 _leave(" = %d", ret);
56312 @@ -687,7 +687,7 @@ nobufs_unlock:
56313 atomic_dec(&cookie->n_active);
56314 kfree(op);
56315 nobufs:
56316 - fscache_stat(&fscache_n_allocs_nobufs);
56317 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56318 _leave(" = -ENOBUFS");
56319 return -ENOBUFS;
56320 }
56321 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56322
56323 spin_lock(&cookie->stores_lock);
56324
56325 - fscache_stat(&fscache_n_store_calls);
56326 + fscache_stat_unchecked(&fscache_n_store_calls);
56327
56328 /* find a page to store */
56329 page = NULL;
56330 @@ -758,7 +758,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56331 page = results[0];
56332 _debug("gang %d [%lx]", n, page->index);
56333 if (page->index > op->store_limit) {
56334 - fscache_stat(&fscache_n_store_pages_over_limit);
56335 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
56336 goto superseded;
56337 }
56338
56339 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56340 spin_unlock(&cookie->stores_lock);
56341 spin_unlock(&object->lock);
56342
56343 - fscache_stat(&fscache_n_store_pages);
56344 + fscache_stat_unchecked(&fscache_n_store_pages);
56345 fscache_stat(&fscache_n_cop_write_page);
56346 ret = object->cache->ops->write_page(op, page);
56347 fscache_stat_d(&fscache_n_cop_write_page);
56348 @@ -873,7 +873,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56349 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56350 ASSERT(PageFsCache(page));
56351
56352 - fscache_stat(&fscache_n_stores);
56353 + fscache_stat_unchecked(&fscache_n_stores);
56354
56355 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
56356 _leave(" = -ENOBUFS [invalidating]");
56357 @@ -931,7 +931,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56358 spin_unlock(&cookie->stores_lock);
56359 spin_unlock(&object->lock);
56360
56361 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
56362 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56363 op->store_limit = object->store_limit;
56364
56365 atomic_inc(&cookie->n_active);
56366 @@ -940,8 +940,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56367
56368 spin_unlock(&cookie->lock);
56369 radix_tree_preload_end();
56370 - fscache_stat(&fscache_n_store_ops);
56371 - fscache_stat(&fscache_n_stores_ok);
56372 + fscache_stat_unchecked(&fscache_n_store_ops);
56373 + fscache_stat_unchecked(&fscache_n_stores_ok);
56374
56375 /* the work queue now carries its own ref on the object */
56376 fscache_put_operation(&op->op);
56377 @@ -949,14 +949,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56378 return 0;
56379
56380 already_queued:
56381 - fscache_stat(&fscache_n_stores_again);
56382 + fscache_stat_unchecked(&fscache_n_stores_again);
56383 already_pending:
56384 spin_unlock(&cookie->stores_lock);
56385 spin_unlock(&object->lock);
56386 spin_unlock(&cookie->lock);
56387 radix_tree_preload_end();
56388 kfree(op);
56389 - fscache_stat(&fscache_n_stores_ok);
56390 + fscache_stat_unchecked(&fscache_n_stores_ok);
56391 _leave(" = 0");
56392 return 0;
56393
56394 @@ -976,14 +976,14 @@ nobufs:
56395 spin_unlock(&cookie->lock);
56396 radix_tree_preload_end();
56397 kfree(op);
56398 - fscache_stat(&fscache_n_stores_nobufs);
56399 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
56400 _leave(" = -ENOBUFS");
56401 return -ENOBUFS;
56402
56403 nomem_free:
56404 kfree(op);
56405 nomem:
56406 - fscache_stat(&fscache_n_stores_oom);
56407 + fscache_stat_unchecked(&fscache_n_stores_oom);
56408 _leave(" = -ENOMEM");
56409 return -ENOMEM;
56410 }
56411 @@ -1001,7 +1001,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
56412 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56413 ASSERTCMP(page, !=, NULL);
56414
56415 - fscache_stat(&fscache_n_uncaches);
56416 + fscache_stat_unchecked(&fscache_n_uncaches);
56417
56418 /* cache withdrawal may beat us to it */
56419 if (!PageFsCache(page))
56420 @@ -1052,7 +1052,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
56421 struct fscache_cookie *cookie = op->op.object->cookie;
56422
56423 #ifdef CONFIG_FSCACHE_STATS
56424 - atomic_inc(&fscache_n_marks);
56425 + atomic_inc_unchecked(&fscache_n_marks);
56426 #endif
56427
56428 _debug("- mark %p{%lx}", page, page->index);
56429 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
56430 index 40d13c7..ddf52b9 100644
56431 --- a/fs/fscache/stats.c
56432 +++ b/fs/fscache/stats.c
56433 @@ -18,99 +18,99 @@
56434 /*
56435 * operation counters
56436 */
56437 -atomic_t fscache_n_op_pend;
56438 -atomic_t fscache_n_op_run;
56439 -atomic_t fscache_n_op_enqueue;
56440 -atomic_t fscache_n_op_requeue;
56441 -atomic_t fscache_n_op_deferred_release;
56442 -atomic_t fscache_n_op_release;
56443 -atomic_t fscache_n_op_gc;
56444 -atomic_t fscache_n_op_cancelled;
56445 -atomic_t fscache_n_op_rejected;
56446 +atomic_unchecked_t fscache_n_op_pend;
56447 +atomic_unchecked_t fscache_n_op_run;
56448 +atomic_unchecked_t fscache_n_op_enqueue;
56449 +atomic_unchecked_t fscache_n_op_requeue;
56450 +atomic_unchecked_t fscache_n_op_deferred_release;
56451 +atomic_unchecked_t fscache_n_op_release;
56452 +atomic_unchecked_t fscache_n_op_gc;
56453 +atomic_unchecked_t fscache_n_op_cancelled;
56454 +atomic_unchecked_t fscache_n_op_rejected;
56455
56456 -atomic_t fscache_n_attr_changed;
56457 -atomic_t fscache_n_attr_changed_ok;
56458 -atomic_t fscache_n_attr_changed_nobufs;
56459 -atomic_t fscache_n_attr_changed_nomem;
56460 -atomic_t fscache_n_attr_changed_calls;
56461 +atomic_unchecked_t fscache_n_attr_changed;
56462 +atomic_unchecked_t fscache_n_attr_changed_ok;
56463 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
56464 +atomic_unchecked_t fscache_n_attr_changed_nomem;
56465 +atomic_unchecked_t fscache_n_attr_changed_calls;
56466
56467 -atomic_t fscache_n_allocs;
56468 -atomic_t fscache_n_allocs_ok;
56469 -atomic_t fscache_n_allocs_wait;
56470 -atomic_t fscache_n_allocs_nobufs;
56471 -atomic_t fscache_n_allocs_intr;
56472 -atomic_t fscache_n_allocs_object_dead;
56473 -atomic_t fscache_n_alloc_ops;
56474 -atomic_t fscache_n_alloc_op_waits;
56475 +atomic_unchecked_t fscache_n_allocs;
56476 +atomic_unchecked_t fscache_n_allocs_ok;
56477 +atomic_unchecked_t fscache_n_allocs_wait;
56478 +atomic_unchecked_t fscache_n_allocs_nobufs;
56479 +atomic_unchecked_t fscache_n_allocs_intr;
56480 +atomic_unchecked_t fscache_n_allocs_object_dead;
56481 +atomic_unchecked_t fscache_n_alloc_ops;
56482 +atomic_unchecked_t fscache_n_alloc_op_waits;
56483
56484 -atomic_t fscache_n_retrievals;
56485 -atomic_t fscache_n_retrievals_ok;
56486 -atomic_t fscache_n_retrievals_wait;
56487 -atomic_t fscache_n_retrievals_nodata;
56488 -atomic_t fscache_n_retrievals_nobufs;
56489 -atomic_t fscache_n_retrievals_intr;
56490 -atomic_t fscache_n_retrievals_nomem;
56491 -atomic_t fscache_n_retrievals_object_dead;
56492 -atomic_t fscache_n_retrieval_ops;
56493 -atomic_t fscache_n_retrieval_op_waits;
56494 +atomic_unchecked_t fscache_n_retrievals;
56495 +atomic_unchecked_t fscache_n_retrievals_ok;
56496 +atomic_unchecked_t fscache_n_retrievals_wait;
56497 +atomic_unchecked_t fscache_n_retrievals_nodata;
56498 +atomic_unchecked_t fscache_n_retrievals_nobufs;
56499 +atomic_unchecked_t fscache_n_retrievals_intr;
56500 +atomic_unchecked_t fscache_n_retrievals_nomem;
56501 +atomic_unchecked_t fscache_n_retrievals_object_dead;
56502 +atomic_unchecked_t fscache_n_retrieval_ops;
56503 +atomic_unchecked_t fscache_n_retrieval_op_waits;
56504
56505 -atomic_t fscache_n_stores;
56506 -atomic_t fscache_n_stores_ok;
56507 -atomic_t fscache_n_stores_again;
56508 -atomic_t fscache_n_stores_nobufs;
56509 -atomic_t fscache_n_stores_oom;
56510 -atomic_t fscache_n_store_ops;
56511 -atomic_t fscache_n_store_calls;
56512 -atomic_t fscache_n_store_pages;
56513 -atomic_t fscache_n_store_radix_deletes;
56514 -atomic_t fscache_n_store_pages_over_limit;
56515 +atomic_unchecked_t fscache_n_stores;
56516 +atomic_unchecked_t fscache_n_stores_ok;
56517 +atomic_unchecked_t fscache_n_stores_again;
56518 +atomic_unchecked_t fscache_n_stores_nobufs;
56519 +atomic_unchecked_t fscache_n_stores_oom;
56520 +atomic_unchecked_t fscache_n_store_ops;
56521 +atomic_unchecked_t fscache_n_store_calls;
56522 +atomic_unchecked_t fscache_n_store_pages;
56523 +atomic_unchecked_t fscache_n_store_radix_deletes;
56524 +atomic_unchecked_t fscache_n_store_pages_over_limit;
56525
56526 -atomic_t fscache_n_store_vmscan_not_storing;
56527 -atomic_t fscache_n_store_vmscan_gone;
56528 -atomic_t fscache_n_store_vmscan_busy;
56529 -atomic_t fscache_n_store_vmscan_cancelled;
56530 -atomic_t fscache_n_store_vmscan_wait;
56531 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56532 +atomic_unchecked_t fscache_n_store_vmscan_gone;
56533 +atomic_unchecked_t fscache_n_store_vmscan_busy;
56534 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56535 +atomic_unchecked_t fscache_n_store_vmscan_wait;
56536
56537 -atomic_t fscache_n_marks;
56538 -atomic_t fscache_n_uncaches;
56539 +atomic_unchecked_t fscache_n_marks;
56540 +atomic_unchecked_t fscache_n_uncaches;
56541
56542 -atomic_t fscache_n_acquires;
56543 -atomic_t fscache_n_acquires_null;
56544 -atomic_t fscache_n_acquires_no_cache;
56545 -atomic_t fscache_n_acquires_ok;
56546 -atomic_t fscache_n_acquires_nobufs;
56547 -atomic_t fscache_n_acquires_oom;
56548 +atomic_unchecked_t fscache_n_acquires;
56549 +atomic_unchecked_t fscache_n_acquires_null;
56550 +atomic_unchecked_t fscache_n_acquires_no_cache;
56551 +atomic_unchecked_t fscache_n_acquires_ok;
56552 +atomic_unchecked_t fscache_n_acquires_nobufs;
56553 +atomic_unchecked_t fscache_n_acquires_oom;
56554
56555 -atomic_t fscache_n_invalidates;
56556 -atomic_t fscache_n_invalidates_run;
56557 +atomic_unchecked_t fscache_n_invalidates;
56558 +atomic_unchecked_t fscache_n_invalidates_run;
56559
56560 -atomic_t fscache_n_updates;
56561 -atomic_t fscache_n_updates_null;
56562 -atomic_t fscache_n_updates_run;
56563 +atomic_unchecked_t fscache_n_updates;
56564 +atomic_unchecked_t fscache_n_updates_null;
56565 +atomic_unchecked_t fscache_n_updates_run;
56566
56567 -atomic_t fscache_n_relinquishes;
56568 -atomic_t fscache_n_relinquishes_null;
56569 -atomic_t fscache_n_relinquishes_waitcrt;
56570 -atomic_t fscache_n_relinquishes_retire;
56571 +atomic_unchecked_t fscache_n_relinquishes;
56572 +atomic_unchecked_t fscache_n_relinquishes_null;
56573 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56574 +atomic_unchecked_t fscache_n_relinquishes_retire;
56575
56576 -atomic_t fscache_n_cookie_index;
56577 -atomic_t fscache_n_cookie_data;
56578 -atomic_t fscache_n_cookie_special;
56579 +atomic_unchecked_t fscache_n_cookie_index;
56580 +atomic_unchecked_t fscache_n_cookie_data;
56581 +atomic_unchecked_t fscache_n_cookie_special;
56582
56583 -atomic_t fscache_n_object_alloc;
56584 -atomic_t fscache_n_object_no_alloc;
56585 -atomic_t fscache_n_object_lookups;
56586 -atomic_t fscache_n_object_lookups_negative;
56587 -atomic_t fscache_n_object_lookups_positive;
56588 -atomic_t fscache_n_object_lookups_timed_out;
56589 -atomic_t fscache_n_object_created;
56590 -atomic_t fscache_n_object_avail;
56591 -atomic_t fscache_n_object_dead;
56592 +atomic_unchecked_t fscache_n_object_alloc;
56593 +atomic_unchecked_t fscache_n_object_no_alloc;
56594 +atomic_unchecked_t fscache_n_object_lookups;
56595 +atomic_unchecked_t fscache_n_object_lookups_negative;
56596 +atomic_unchecked_t fscache_n_object_lookups_positive;
56597 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
56598 +atomic_unchecked_t fscache_n_object_created;
56599 +atomic_unchecked_t fscache_n_object_avail;
56600 +atomic_unchecked_t fscache_n_object_dead;
56601
56602 -atomic_t fscache_n_checkaux_none;
56603 -atomic_t fscache_n_checkaux_okay;
56604 -atomic_t fscache_n_checkaux_update;
56605 -atomic_t fscache_n_checkaux_obsolete;
56606 +atomic_unchecked_t fscache_n_checkaux_none;
56607 +atomic_unchecked_t fscache_n_checkaux_okay;
56608 +atomic_unchecked_t fscache_n_checkaux_update;
56609 +atomic_unchecked_t fscache_n_checkaux_obsolete;
56610
56611 atomic_t fscache_n_cop_alloc_object;
56612 atomic_t fscache_n_cop_lookup_object;
56613 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
56614 seq_puts(m, "FS-Cache statistics\n");
56615
56616 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
56617 - atomic_read(&fscache_n_cookie_index),
56618 - atomic_read(&fscache_n_cookie_data),
56619 - atomic_read(&fscache_n_cookie_special));
56620 + atomic_read_unchecked(&fscache_n_cookie_index),
56621 + atomic_read_unchecked(&fscache_n_cookie_data),
56622 + atomic_read_unchecked(&fscache_n_cookie_special));
56623
56624 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
56625 - atomic_read(&fscache_n_object_alloc),
56626 - atomic_read(&fscache_n_object_no_alloc),
56627 - atomic_read(&fscache_n_object_avail),
56628 - atomic_read(&fscache_n_object_dead));
56629 + atomic_read_unchecked(&fscache_n_object_alloc),
56630 + atomic_read_unchecked(&fscache_n_object_no_alloc),
56631 + atomic_read_unchecked(&fscache_n_object_avail),
56632 + atomic_read_unchecked(&fscache_n_object_dead));
56633 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
56634 - atomic_read(&fscache_n_checkaux_none),
56635 - atomic_read(&fscache_n_checkaux_okay),
56636 - atomic_read(&fscache_n_checkaux_update),
56637 - atomic_read(&fscache_n_checkaux_obsolete));
56638 + atomic_read_unchecked(&fscache_n_checkaux_none),
56639 + atomic_read_unchecked(&fscache_n_checkaux_okay),
56640 + atomic_read_unchecked(&fscache_n_checkaux_update),
56641 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
56642
56643 seq_printf(m, "Pages : mrk=%u unc=%u\n",
56644 - atomic_read(&fscache_n_marks),
56645 - atomic_read(&fscache_n_uncaches));
56646 + atomic_read_unchecked(&fscache_n_marks),
56647 + atomic_read_unchecked(&fscache_n_uncaches));
56648
56649 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
56650 " oom=%u\n",
56651 - atomic_read(&fscache_n_acquires),
56652 - atomic_read(&fscache_n_acquires_null),
56653 - atomic_read(&fscache_n_acquires_no_cache),
56654 - atomic_read(&fscache_n_acquires_ok),
56655 - atomic_read(&fscache_n_acquires_nobufs),
56656 - atomic_read(&fscache_n_acquires_oom));
56657 + atomic_read_unchecked(&fscache_n_acquires),
56658 + atomic_read_unchecked(&fscache_n_acquires_null),
56659 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
56660 + atomic_read_unchecked(&fscache_n_acquires_ok),
56661 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
56662 + atomic_read_unchecked(&fscache_n_acquires_oom));
56663
56664 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
56665 - atomic_read(&fscache_n_object_lookups),
56666 - atomic_read(&fscache_n_object_lookups_negative),
56667 - atomic_read(&fscache_n_object_lookups_positive),
56668 - atomic_read(&fscache_n_object_created),
56669 - atomic_read(&fscache_n_object_lookups_timed_out));
56670 + atomic_read_unchecked(&fscache_n_object_lookups),
56671 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
56672 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
56673 + atomic_read_unchecked(&fscache_n_object_created),
56674 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
56675
56676 seq_printf(m, "Invals : n=%u run=%u\n",
56677 - atomic_read(&fscache_n_invalidates),
56678 - atomic_read(&fscache_n_invalidates_run));
56679 + atomic_read_unchecked(&fscache_n_invalidates),
56680 + atomic_read_unchecked(&fscache_n_invalidates_run));
56681
56682 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
56683 - atomic_read(&fscache_n_updates),
56684 - atomic_read(&fscache_n_updates_null),
56685 - atomic_read(&fscache_n_updates_run));
56686 + atomic_read_unchecked(&fscache_n_updates),
56687 + atomic_read_unchecked(&fscache_n_updates_null),
56688 + atomic_read_unchecked(&fscache_n_updates_run));
56689
56690 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
56691 - atomic_read(&fscache_n_relinquishes),
56692 - atomic_read(&fscache_n_relinquishes_null),
56693 - atomic_read(&fscache_n_relinquishes_waitcrt),
56694 - atomic_read(&fscache_n_relinquishes_retire));
56695 + atomic_read_unchecked(&fscache_n_relinquishes),
56696 + atomic_read_unchecked(&fscache_n_relinquishes_null),
56697 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
56698 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
56699
56700 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
56701 - atomic_read(&fscache_n_attr_changed),
56702 - atomic_read(&fscache_n_attr_changed_ok),
56703 - atomic_read(&fscache_n_attr_changed_nobufs),
56704 - atomic_read(&fscache_n_attr_changed_nomem),
56705 - atomic_read(&fscache_n_attr_changed_calls));
56706 + atomic_read_unchecked(&fscache_n_attr_changed),
56707 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
56708 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
56709 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
56710 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
56711
56712 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
56713 - atomic_read(&fscache_n_allocs),
56714 - atomic_read(&fscache_n_allocs_ok),
56715 - atomic_read(&fscache_n_allocs_wait),
56716 - atomic_read(&fscache_n_allocs_nobufs),
56717 - atomic_read(&fscache_n_allocs_intr));
56718 + atomic_read_unchecked(&fscache_n_allocs),
56719 + atomic_read_unchecked(&fscache_n_allocs_ok),
56720 + atomic_read_unchecked(&fscache_n_allocs_wait),
56721 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
56722 + atomic_read_unchecked(&fscache_n_allocs_intr));
56723 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
56724 - atomic_read(&fscache_n_alloc_ops),
56725 - atomic_read(&fscache_n_alloc_op_waits),
56726 - atomic_read(&fscache_n_allocs_object_dead));
56727 + atomic_read_unchecked(&fscache_n_alloc_ops),
56728 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
56729 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
56730
56731 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
56732 " int=%u oom=%u\n",
56733 - atomic_read(&fscache_n_retrievals),
56734 - atomic_read(&fscache_n_retrievals_ok),
56735 - atomic_read(&fscache_n_retrievals_wait),
56736 - atomic_read(&fscache_n_retrievals_nodata),
56737 - atomic_read(&fscache_n_retrievals_nobufs),
56738 - atomic_read(&fscache_n_retrievals_intr),
56739 - atomic_read(&fscache_n_retrievals_nomem));
56740 + atomic_read_unchecked(&fscache_n_retrievals),
56741 + atomic_read_unchecked(&fscache_n_retrievals_ok),
56742 + atomic_read_unchecked(&fscache_n_retrievals_wait),
56743 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
56744 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
56745 + atomic_read_unchecked(&fscache_n_retrievals_intr),
56746 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
56747 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
56748 - atomic_read(&fscache_n_retrieval_ops),
56749 - atomic_read(&fscache_n_retrieval_op_waits),
56750 - atomic_read(&fscache_n_retrievals_object_dead));
56751 + atomic_read_unchecked(&fscache_n_retrieval_ops),
56752 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
56753 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
56754
56755 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
56756 - atomic_read(&fscache_n_stores),
56757 - atomic_read(&fscache_n_stores_ok),
56758 - atomic_read(&fscache_n_stores_again),
56759 - atomic_read(&fscache_n_stores_nobufs),
56760 - atomic_read(&fscache_n_stores_oom));
56761 + atomic_read_unchecked(&fscache_n_stores),
56762 + atomic_read_unchecked(&fscache_n_stores_ok),
56763 + atomic_read_unchecked(&fscache_n_stores_again),
56764 + atomic_read_unchecked(&fscache_n_stores_nobufs),
56765 + atomic_read_unchecked(&fscache_n_stores_oom));
56766 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
56767 - atomic_read(&fscache_n_store_ops),
56768 - atomic_read(&fscache_n_store_calls),
56769 - atomic_read(&fscache_n_store_pages),
56770 - atomic_read(&fscache_n_store_radix_deletes),
56771 - atomic_read(&fscache_n_store_pages_over_limit));
56772 + atomic_read_unchecked(&fscache_n_store_ops),
56773 + atomic_read_unchecked(&fscache_n_store_calls),
56774 + atomic_read_unchecked(&fscache_n_store_pages),
56775 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
56776 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
56777
56778 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
56779 - atomic_read(&fscache_n_store_vmscan_not_storing),
56780 - atomic_read(&fscache_n_store_vmscan_gone),
56781 - atomic_read(&fscache_n_store_vmscan_busy),
56782 - atomic_read(&fscache_n_store_vmscan_cancelled),
56783 - atomic_read(&fscache_n_store_vmscan_wait));
56784 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
56785 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
56786 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
56787 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
56788 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
56789
56790 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
56791 - atomic_read(&fscache_n_op_pend),
56792 - atomic_read(&fscache_n_op_run),
56793 - atomic_read(&fscache_n_op_enqueue),
56794 - atomic_read(&fscache_n_op_cancelled),
56795 - atomic_read(&fscache_n_op_rejected));
56796 + atomic_read_unchecked(&fscache_n_op_pend),
56797 + atomic_read_unchecked(&fscache_n_op_run),
56798 + atomic_read_unchecked(&fscache_n_op_enqueue),
56799 + atomic_read_unchecked(&fscache_n_op_cancelled),
56800 + atomic_read_unchecked(&fscache_n_op_rejected));
56801 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
56802 - atomic_read(&fscache_n_op_deferred_release),
56803 - atomic_read(&fscache_n_op_release),
56804 - atomic_read(&fscache_n_op_gc));
56805 + atomic_read_unchecked(&fscache_n_op_deferred_release),
56806 + atomic_read_unchecked(&fscache_n_op_release),
56807 + atomic_read_unchecked(&fscache_n_op_gc));
56808
56809 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
56810 atomic_read(&fscache_n_cop_alloc_object),
56811 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
56812 index aef34b1..59bfd7b 100644
56813 --- a/fs/fuse/cuse.c
56814 +++ b/fs/fuse/cuse.c
56815 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
56816 INIT_LIST_HEAD(&cuse_conntbl[i]);
56817
56818 /* inherit and extend fuse_dev_operations */
56819 - cuse_channel_fops = fuse_dev_operations;
56820 - cuse_channel_fops.owner = THIS_MODULE;
56821 - cuse_channel_fops.open = cuse_channel_open;
56822 - cuse_channel_fops.release = cuse_channel_release;
56823 + pax_open_kernel();
56824 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
56825 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
56826 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
56827 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
56828 + pax_close_kernel();
56829
56830 cuse_class = class_create(THIS_MODULE, "cuse");
56831 if (IS_ERR(cuse_class))
56832 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
56833 index 1d55f94..088da65 100644
56834 --- a/fs/fuse/dev.c
56835 +++ b/fs/fuse/dev.c
56836 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
56837 ret = 0;
56838 pipe_lock(pipe);
56839
56840 - if (!pipe->readers) {
56841 + if (!atomic_read(&pipe->readers)) {
56842 send_sig(SIGPIPE, current, 0);
56843 if (!ret)
56844 ret = -EPIPE;
56845 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
56846 page_nr++;
56847 ret += buf->len;
56848
56849 - if (pipe->files)
56850 + if (atomic_read(&pipe->files))
56851 do_wakeup = 1;
56852 }
56853
56854 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
56855 index 8fec28f..cd40dba 100644
56856 --- a/fs/fuse/dir.c
56857 +++ b/fs/fuse/dir.c
56858 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
56859 return link;
56860 }
56861
56862 -static void free_link(char *link)
56863 +static void free_link(const char *link)
56864 {
56865 if (!IS_ERR(link))
56866 free_page((unsigned long) link);
56867 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
56868 index 64915ee..6bed500 100644
56869 --- a/fs/gfs2/inode.c
56870 +++ b/fs/gfs2/inode.c
56871 @@ -1506,7 +1506,7 @@ out:
56872
56873 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
56874 {
56875 - char *s = nd_get_link(nd);
56876 + const char *s = nd_get_link(nd);
56877 if (!IS_ERR(s))
56878 kfree(s);
56879 }
56880 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
56881 index d19b30a..ef89c36 100644
56882 --- a/fs/hugetlbfs/inode.c
56883 +++ b/fs/hugetlbfs/inode.c
56884 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
56885 struct mm_struct *mm = current->mm;
56886 struct vm_area_struct *vma;
56887 struct hstate *h = hstate_file(file);
56888 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
56889 struct vm_unmapped_area_info info;
56890
56891 if (len & ~huge_page_mask(h))
56892 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
56893 return addr;
56894 }
56895
56896 +#ifdef CONFIG_PAX_RANDMMAP
56897 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
56898 +#endif
56899 +
56900 if (addr) {
56901 addr = ALIGN(addr, huge_page_size(h));
56902 vma = find_vma(mm, addr);
56903 - if (TASK_SIZE - len >= addr &&
56904 - (!vma || addr + len <= vma->vm_start))
56905 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
56906 return addr;
56907 }
56908
56909 info.flags = 0;
56910 info.length = len;
56911 info.low_limit = TASK_UNMAPPED_BASE;
56912 +
56913 +#ifdef CONFIG_PAX_RANDMMAP
56914 + if (mm->pax_flags & MF_PAX_RANDMMAP)
56915 + info.low_limit += mm->delta_mmap;
56916 +#endif
56917 +
56918 info.high_limit = TASK_SIZE;
56919 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
56920 info.align_offset = 0;
56921 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
56922 };
56923 MODULE_ALIAS_FS("hugetlbfs");
56924
56925 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
56926 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
56927
56928 static int can_do_hugetlb_shm(void)
56929 {
56930 diff --git a/fs/inode.c b/fs/inode.c
56931 index d6dfb09..602e77e 100644
56932 --- a/fs/inode.c
56933 +++ b/fs/inode.c
56934 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
56935
56936 #ifdef CONFIG_SMP
56937 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
56938 - static atomic_t shared_last_ino;
56939 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
56940 + static atomic_unchecked_t shared_last_ino;
56941 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
56942
56943 res = next - LAST_INO_BATCH;
56944 }
56945 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
56946 index 4a6cf28..d3a29d3 100644
56947 --- a/fs/jffs2/erase.c
56948 +++ b/fs/jffs2/erase.c
56949 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
56950 struct jffs2_unknown_node marker = {
56951 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
56952 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
56953 - .totlen = cpu_to_je32(c->cleanmarker_size)
56954 + .totlen = cpu_to_je32(c->cleanmarker_size),
56955 + .hdr_crc = cpu_to_je32(0)
56956 };
56957
56958 jffs2_prealloc_raw_node_refs(c, jeb, 1);
56959 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
56960 index a6597d6..41b30ec 100644
56961 --- a/fs/jffs2/wbuf.c
56962 +++ b/fs/jffs2/wbuf.c
56963 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
56964 {
56965 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
56966 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
56967 - .totlen = constant_cpu_to_je32(8)
56968 + .totlen = constant_cpu_to_je32(8),
56969 + .hdr_crc = constant_cpu_to_je32(0)
56970 };
56971
56972 /*
56973 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
56974 index 6669aa2..36b033d 100644
56975 --- a/fs/jfs/super.c
56976 +++ b/fs/jfs/super.c
56977 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
56978
56979 jfs_inode_cachep =
56980 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
56981 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
56982 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
56983 init_once);
56984 if (jfs_inode_cachep == NULL)
56985 return -ENOMEM;
56986 diff --git a/fs/libfs.c b/fs/libfs.c
56987 index 3a3a9b5..3a9b074 100644
56988 --- a/fs/libfs.c
56989 +++ b/fs/libfs.c
56990 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
56991
56992 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
56993 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
56994 + char d_name[sizeof(next->d_iname)];
56995 + const unsigned char *name;
56996 +
56997 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
56998 if (!simple_positive(next)) {
56999 spin_unlock(&next->d_lock);
57000 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57001
57002 spin_unlock(&next->d_lock);
57003 spin_unlock(&dentry->d_lock);
57004 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57005 + name = next->d_name.name;
57006 + if (name == next->d_iname) {
57007 + memcpy(d_name, name, next->d_name.len);
57008 + name = d_name;
57009 + }
57010 + if (!dir_emit(ctx, name, next->d_name.len,
57011 next->d_inode->i_ino, dt_type(next->d_inode)))
57012 return 0;
57013 spin_lock(&dentry->d_lock);
57014 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57015 index acd3947..1f896e2 100644
57016 --- a/fs/lockd/clntproc.c
57017 +++ b/fs/lockd/clntproc.c
57018 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57019 /*
57020 * Cookie counter for NLM requests
57021 */
57022 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57023 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57024
57025 void nlmclnt_next_cookie(struct nlm_cookie *c)
57026 {
57027 - u32 cookie = atomic_inc_return(&nlm_cookie);
57028 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57029
57030 memcpy(c->data, &cookie, 4);
57031 c->len=4;
57032 diff --git a/fs/locks.c b/fs/locks.c
57033 index b27a300..4156d0b 100644
57034 --- a/fs/locks.c
57035 +++ b/fs/locks.c
57036 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57037 return;
57038
57039 if (filp->f_op && filp->f_op->flock) {
57040 - struct file_lock fl = {
57041 + struct file_lock flock = {
57042 .fl_pid = current->tgid,
57043 .fl_file = filp,
57044 .fl_flags = FL_FLOCK,
57045 .fl_type = F_UNLCK,
57046 .fl_end = OFFSET_MAX,
57047 };
57048 - filp->f_op->flock(filp, F_SETLKW, &fl);
57049 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57050 - fl.fl_ops->fl_release_private(&fl);
57051 + filp->f_op->flock(filp, F_SETLKW, &flock);
57052 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57053 + flock.fl_ops->fl_release_private(&flock);
57054 }
57055
57056 spin_lock(&inode->i_lock);
57057 diff --git a/fs/namei.c b/fs/namei.c
57058 index 7720fbd..7934bb2 100644
57059 --- a/fs/namei.c
57060 +++ b/fs/namei.c
57061 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57062 if (ret != -EACCES)
57063 return ret;
57064
57065 +#ifdef CONFIG_GRKERNSEC
57066 + /* we'll block if we have to log due to a denied capability use */
57067 + if (mask & MAY_NOT_BLOCK)
57068 + return -ECHILD;
57069 +#endif
57070 +
57071 if (S_ISDIR(inode->i_mode)) {
57072 /* DACs are overridable for directories */
57073 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57074 - return 0;
57075 if (!(mask & MAY_WRITE))
57076 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57077 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57078 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57079 return 0;
57080 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57081 + return 0;
57082 return -EACCES;
57083 }
57084 /*
57085 + * Searching includes executable on directories, else just read.
57086 + */
57087 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57088 + if (mask == MAY_READ)
57089 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57090 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57091 + return 0;
57092 +
57093 + /*
57094 * Read/write DACs are always overridable.
57095 * Executable DACs are overridable when there is
57096 * at least one exec bit set.
57097 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57098 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57099 return 0;
57100
57101 - /*
57102 - * Searching includes executable on directories, else just read.
57103 - */
57104 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57105 - if (mask == MAY_READ)
57106 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57107 - return 0;
57108 -
57109 return -EACCES;
57110 }
57111
57112 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57113 {
57114 struct dentry *dentry = link->dentry;
57115 int error;
57116 - char *s;
57117 + const char *s;
57118
57119 BUG_ON(nd->flags & LOOKUP_RCU);
57120
57121 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57122 if (error)
57123 goto out_put_nd_path;
57124
57125 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57126 + dentry->d_inode, dentry, nd->path.mnt)) {
57127 + error = -EACCES;
57128 + goto out_put_nd_path;
57129 + }
57130 +
57131 nd->last_type = LAST_BIND;
57132 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57133 error = PTR_ERR(*p);
57134 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
57135 if (res)
57136 break;
57137 res = walk_component(nd, path, LOOKUP_FOLLOW);
57138 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
57139 + res = -EACCES;
57140 put_link(nd, &link, cookie);
57141 } while (res > 0);
57142
57143 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
57144 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
57145 {
57146 unsigned long a, b, adata, bdata, mask, hash, len;
57147 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57148 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57149
57150 hash = a = 0;
57151 len = -sizeof(unsigned long);
57152 @@ -1967,6 +1983,8 @@ static int path_lookupat(int dfd, const char *name,
57153 if (err)
57154 break;
57155 err = lookup_last(nd, &path);
57156 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
57157 + err = -EACCES;
57158 put_link(nd, &link, cookie);
57159 }
57160 }
57161 @@ -1974,6 +1992,13 @@ static int path_lookupat(int dfd, const char *name,
57162 if (!err)
57163 err = complete_walk(nd);
57164
57165 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
57166 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57167 + path_put(&nd->path);
57168 + err = -ENOENT;
57169 + }
57170 + }
57171 +
57172 if (!err && nd->flags & LOOKUP_DIRECTORY) {
57173 if (!can_lookup(nd->inode)) {
57174 path_put(&nd->path);
57175 @@ -2001,8 +2026,15 @@ static int filename_lookup(int dfd, struct filename *name,
57176 retval = path_lookupat(dfd, name->name,
57177 flags | LOOKUP_REVAL, nd);
57178
57179 - if (likely(!retval))
57180 + if (likely(!retval)) {
57181 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
57182 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
57183 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
57184 + path_put(&nd->path);
57185 + return -ENOENT;
57186 + }
57187 + }
57188 + }
57189 return retval;
57190 }
57191
57192 @@ -2380,6 +2412,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
57193 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
57194 return -EPERM;
57195
57196 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
57197 + return -EPERM;
57198 + if (gr_handle_rawio(inode))
57199 + return -EPERM;
57200 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
57201 + return -EACCES;
57202 +
57203 return 0;
57204 }
57205
57206 @@ -2601,7 +2640,7 @@ looked_up:
57207 * cleared otherwise prior to returning.
57208 */
57209 static int lookup_open(struct nameidata *nd, struct path *path,
57210 - struct file *file,
57211 + struct path *link, struct file *file,
57212 const struct open_flags *op,
57213 bool got_write, int *opened)
57214 {
57215 @@ -2636,6 +2675,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57216 /* Negative dentry, just create the file */
57217 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
57218 umode_t mode = op->mode;
57219 +
57220 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
57221 + error = -EACCES;
57222 + goto out_dput;
57223 + }
57224 +
57225 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
57226 + error = -EACCES;
57227 + goto out_dput;
57228 + }
57229 +
57230 if (!IS_POSIXACL(dir->d_inode))
57231 mode &= ~current_umask();
57232 /*
57233 @@ -2657,6 +2707,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57234 nd->flags & LOOKUP_EXCL);
57235 if (error)
57236 goto out_dput;
57237 + else
57238 + gr_handle_create(dentry, nd->path.mnt);
57239 }
57240 out_no_open:
57241 path->dentry = dentry;
57242 @@ -2671,7 +2723,7 @@ out_dput:
57243 /*
57244 * Handle the last step of open()
57245 */
57246 -static int do_last(struct nameidata *nd, struct path *path,
57247 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
57248 struct file *file, const struct open_flags *op,
57249 int *opened, struct filename *name)
57250 {
57251 @@ -2721,6 +2773,15 @@ static int do_last(struct nameidata *nd, struct path *path,
57252 if (error)
57253 return error;
57254
57255 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
57256 + error = -ENOENT;
57257 + goto out;
57258 + }
57259 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57260 + error = -EACCES;
57261 + goto out;
57262 + }
57263 +
57264 audit_inode(name, dir, LOOKUP_PARENT);
57265 error = -EISDIR;
57266 /* trailing slashes? */
57267 @@ -2740,7 +2801,7 @@ retry_lookup:
57268 */
57269 }
57270 mutex_lock(&dir->d_inode->i_mutex);
57271 - error = lookup_open(nd, path, file, op, got_write, opened);
57272 + error = lookup_open(nd, path, link, file, op, got_write, opened);
57273 mutex_unlock(&dir->d_inode->i_mutex);
57274
57275 if (error <= 0) {
57276 @@ -2764,11 +2825,28 @@ retry_lookup:
57277 goto finish_open_created;
57278 }
57279
57280 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
57281 + error = -ENOENT;
57282 + goto exit_dput;
57283 + }
57284 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
57285 + error = -EACCES;
57286 + goto exit_dput;
57287 + }
57288 +
57289 /*
57290 * create/update audit record if it already exists.
57291 */
57292 - if (path->dentry->d_inode)
57293 + if (path->dentry->d_inode) {
57294 + /* only check if O_CREAT is specified, all other checks need to go
57295 + into may_open */
57296 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
57297 + error = -EACCES;
57298 + goto exit_dput;
57299 + }
57300 +
57301 audit_inode(name, path->dentry, 0);
57302 + }
57303
57304 /*
57305 * If atomic_open() acquired write access it is dropped now due to
57306 @@ -2809,6 +2887,11 @@ finish_lookup:
57307 }
57308 }
57309 BUG_ON(inode != path->dentry->d_inode);
57310 + /* if we're resolving a symlink to another symlink */
57311 + if (link && gr_handle_symlink_owner(link, inode)) {
57312 + error = -EACCES;
57313 + goto out;
57314 + }
57315 return 1;
57316 }
57317
57318 @@ -2818,7 +2901,6 @@ finish_lookup:
57319 save_parent.dentry = nd->path.dentry;
57320 save_parent.mnt = mntget(path->mnt);
57321 nd->path.dentry = path->dentry;
57322 -
57323 }
57324 nd->inode = inode;
57325 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
57326 @@ -2828,7 +2910,18 @@ finish_open:
57327 path_put(&save_parent);
57328 return error;
57329 }
57330 +
57331 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57332 + error = -ENOENT;
57333 + goto out;
57334 + }
57335 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57336 + error = -EACCES;
57337 + goto out;
57338 + }
57339 +
57340 audit_inode(name, nd->path.dentry, 0);
57341 +
57342 error = -EISDIR;
57343 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
57344 goto out;
57345 @@ -2991,7 +3084,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57346 if (unlikely(error))
57347 goto out;
57348
57349 - error = do_last(nd, &path, file, op, &opened, pathname);
57350 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
57351 while (unlikely(error > 0)) { /* trailing symlink */
57352 struct path link = path;
57353 void *cookie;
57354 @@ -3009,7 +3102,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57355 error = follow_link(&link, nd, &cookie);
57356 if (unlikely(error))
57357 break;
57358 - error = do_last(nd, &path, file, op, &opened, pathname);
57359 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
57360 put_link(nd, &link, cookie);
57361 }
57362 out:
57363 @@ -3109,8 +3202,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
57364 goto unlock;
57365
57366 error = -EEXIST;
57367 - if (dentry->d_inode)
57368 + if (dentry->d_inode) {
57369 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
57370 + error = -ENOENT;
57371 + }
57372 goto fail;
57373 + }
57374 /*
57375 * Special case - lookup gave negative, but... we had foo/bar/
57376 * From the vfs_mknod() POV we just have a negative dentry -
57377 @@ -3162,6 +3259,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
57378 }
57379 EXPORT_SYMBOL(user_path_create);
57380
57381 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
57382 +{
57383 + struct filename *tmp = getname(pathname);
57384 + struct dentry *res;
57385 + if (IS_ERR(tmp))
57386 + return ERR_CAST(tmp);
57387 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
57388 + if (IS_ERR(res))
57389 + putname(tmp);
57390 + else
57391 + *to = tmp;
57392 + return res;
57393 +}
57394 +
57395 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
57396 {
57397 int error = may_create(dir, dentry);
57398 @@ -3224,6 +3335,17 @@ retry:
57399
57400 if (!IS_POSIXACL(path.dentry->d_inode))
57401 mode &= ~current_umask();
57402 +
57403 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
57404 + error = -EPERM;
57405 + goto out;
57406 + }
57407 +
57408 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
57409 + error = -EACCES;
57410 + goto out;
57411 + }
57412 +
57413 error = security_path_mknod(&path, dentry, mode, dev);
57414 if (error)
57415 goto out;
57416 @@ -3240,6 +3362,8 @@ retry:
57417 break;
57418 }
57419 out:
57420 + if (!error)
57421 + gr_handle_create(dentry, path.mnt);
57422 done_path_create(&path, dentry);
57423 if (retry_estale(error, lookup_flags)) {
57424 lookup_flags |= LOOKUP_REVAL;
57425 @@ -3292,9 +3416,16 @@ retry:
57426
57427 if (!IS_POSIXACL(path.dentry->d_inode))
57428 mode &= ~current_umask();
57429 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
57430 + error = -EACCES;
57431 + goto out;
57432 + }
57433 error = security_path_mkdir(&path, dentry, mode);
57434 if (!error)
57435 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
57436 + if (!error)
57437 + gr_handle_create(dentry, path.mnt);
57438 +out:
57439 done_path_create(&path, dentry);
57440 if (retry_estale(error, lookup_flags)) {
57441 lookup_flags |= LOOKUP_REVAL;
57442 @@ -3375,6 +3506,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
57443 struct filename *name;
57444 struct dentry *dentry;
57445 struct nameidata nd;
57446 + ino_t saved_ino = 0;
57447 + dev_t saved_dev = 0;
57448 unsigned int lookup_flags = 0;
57449 retry:
57450 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57451 @@ -3407,10 +3540,21 @@ retry:
57452 error = -ENOENT;
57453 goto exit3;
57454 }
57455 +
57456 + saved_ino = dentry->d_inode->i_ino;
57457 + saved_dev = gr_get_dev_from_dentry(dentry);
57458 +
57459 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
57460 + error = -EACCES;
57461 + goto exit3;
57462 + }
57463 +
57464 error = security_path_rmdir(&nd.path, dentry);
57465 if (error)
57466 goto exit3;
57467 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
57468 + if (!error && (saved_dev || saved_ino))
57469 + gr_handle_delete(saved_ino, saved_dev);
57470 exit3:
57471 dput(dentry);
57472 exit2:
57473 @@ -3476,6 +3620,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
57474 struct dentry *dentry;
57475 struct nameidata nd;
57476 struct inode *inode = NULL;
57477 + ino_t saved_ino = 0;
57478 + dev_t saved_dev = 0;
57479 unsigned int lookup_flags = 0;
57480 retry:
57481 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57482 @@ -3502,10 +3648,22 @@ retry:
57483 if (!inode)
57484 goto slashes;
57485 ihold(inode);
57486 +
57487 + if (inode->i_nlink <= 1) {
57488 + saved_ino = inode->i_ino;
57489 + saved_dev = gr_get_dev_from_dentry(dentry);
57490 + }
57491 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
57492 + error = -EACCES;
57493 + goto exit2;
57494 + }
57495 +
57496 error = security_path_unlink(&nd.path, dentry);
57497 if (error)
57498 goto exit2;
57499 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
57500 + if (!error && (saved_ino || saved_dev))
57501 + gr_handle_delete(saved_ino, saved_dev);
57502 exit2:
57503 dput(dentry);
57504 }
57505 @@ -3583,9 +3741,17 @@ retry:
57506 if (IS_ERR(dentry))
57507 goto out_putname;
57508
57509 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
57510 + error = -EACCES;
57511 + goto out;
57512 + }
57513 +
57514 error = security_path_symlink(&path, dentry, from->name);
57515 if (!error)
57516 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
57517 + if (!error)
57518 + gr_handle_create(dentry, path.mnt);
57519 +out:
57520 done_path_create(&path, dentry);
57521 if (retry_estale(error, lookup_flags)) {
57522 lookup_flags |= LOOKUP_REVAL;
57523 @@ -3665,6 +3831,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
57524 {
57525 struct dentry *new_dentry;
57526 struct path old_path, new_path;
57527 + struct filename *to = NULL;
57528 int how = 0;
57529 int error;
57530
57531 @@ -3688,7 +3855,7 @@ retry:
57532 if (error)
57533 return error;
57534
57535 - new_dentry = user_path_create(newdfd, newname, &new_path,
57536 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
57537 (how & LOOKUP_REVAL));
57538 error = PTR_ERR(new_dentry);
57539 if (IS_ERR(new_dentry))
57540 @@ -3700,11 +3867,28 @@ retry:
57541 error = may_linkat(&old_path);
57542 if (unlikely(error))
57543 goto out_dput;
57544 +
57545 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
57546 + old_path.dentry->d_inode,
57547 + old_path.dentry->d_inode->i_mode, to)) {
57548 + error = -EACCES;
57549 + goto out_dput;
57550 + }
57551 +
57552 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
57553 + old_path.dentry, old_path.mnt, to)) {
57554 + error = -EACCES;
57555 + goto out_dput;
57556 + }
57557 +
57558 error = security_path_link(old_path.dentry, &new_path, new_dentry);
57559 if (error)
57560 goto out_dput;
57561 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
57562 + if (!error)
57563 + gr_handle_create(new_dentry, new_path.mnt);
57564 out_dput:
57565 + putname(to);
57566 done_path_create(&new_path, new_dentry);
57567 if (retry_estale(error, how)) {
57568 how |= LOOKUP_REVAL;
57569 @@ -3950,12 +4134,21 @@ retry:
57570 if (new_dentry == trap)
57571 goto exit5;
57572
57573 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
57574 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
57575 + to);
57576 + if (error)
57577 + goto exit5;
57578 +
57579 error = security_path_rename(&oldnd.path, old_dentry,
57580 &newnd.path, new_dentry);
57581 if (error)
57582 goto exit5;
57583 error = vfs_rename(old_dir->d_inode, old_dentry,
57584 new_dir->d_inode, new_dentry);
57585 + if (!error)
57586 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
57587 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
57588 exit5:
57589 dput(new_dentry);
57590 exit4:
57591 @@ -3987,6 +4180,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
57592
57593 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
57594 {
57595 + char tmpbuf[64];
57596 + const char *newlink;
57597 int len;
57598
57599 len = PTR_ERR(link);
57600 @@ -3996,7 +4191,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
57601 len = strlen(link);
57602 if (len > (unsigned) buflen)
57603 len = buflen;
57604 - if (copy_to_user(buffer, link, len))
57605 +
57606 + if (len < sizeof(tmpbuf)) {
57607 + memcpy(tmpbuf, link, len);
57608 + newlink = tmpbuf;
57609 + } else
57610 + newlink = link;
57611 +
57612 + if (copy_to_user(buffer, newlink, len))
57613 len = -EFAULT;
57614 out:
57615 return len;
57616 diff --git a/fs/namespace.c b/fs/namespace.c
57617 index a45ba4f..b4c7d07 100644
57618 --- a/fs/namespace.c
57619 +++ b/fs/namespace.c
57620 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
57621 if (!(sb->s_flags & MS_RDONLY))
57622 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
57623 up_write(&sb->s_umount);
57624 +
57625 + gr_log_remount(mnt->mnt_devname, retval);
57626 +
57627 return retval;
57628 }
57629
57630 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
57631 }
57632 br_write_unlock(&vfsmount_lock);
57633 namespace_unlock();
57634 +
57635 + gr_log_unmount(mnt->mnt_devname, retval);
57636 +
57637 return retval;
57638 }
57639
57640 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
57641 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
57642 */
57643
57644 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
57645 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
57646 {
57647 struct path path;
57648 struct mount *mnt;
57649 @@ -1342,7 +1348,7 @@ out:
57650 /*
57651 * The 2.0 compatible umount. No flags.
57652 */
57653 -SYSCALL_DEFINE1(oldumount, char __user *, name)
57654 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
57655 {
57656 return sys_umount(name, 0);
57657 }
57658 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
57659 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
57660 MS_STRICTATIME);
57661
57662 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
57663 + retval = -EPERM;
57664 + goto dput_out;
57665 + }
57666 +
57667 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
57668 + retval = -EPERM;
57669 + goto dput_out;
57670 + }
57671 +
57672 if (flags & MS_REMOUNT)
57673 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
57674 data_page);
57675 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
57676 dev_name, data_page);
57677 dput_out:
57678 path_put(&path);
57679 +
57680 + gr_log_mount(dev_name, dir_name, retval);
57681 +
57682 return retval;
57683 }
57684
57685 @@ -2344,7 +2363,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
57686 * number incrementing at 10Ghz will take 12,427 years to wrap which
57687 * is effectively never, so we can ignore the possibility.
57688 */
57689 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
57690 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
57691
57692 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
57693 {
57694 @@ -2359,7 +2378,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
57695 kfree(new_ns);
57696 return ERR_PTR(ret);
57697 }
57698 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
57699 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
57700 atomic_set(&new_ns->count, 1);
57701 new_ns->root = NULL;
57702 INIT_LIST_HEAD(&new_ns->list);
57703 @@ -2373,7 +2392,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
57704 * Allocate a new namespace structure and populate it with contents
57705 * copied from the namespace of the passed in task structure.
57706 */
57707 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
57708 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
57709 struct user_namespace *user_ns, struct fs_struct *fs)
57710 {
57711 struct mnt_namespace *new_ns;
57712 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
57713 }
57714 EXPORT_SYMBOL(mount_subtree);
57715
57716 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
57717 - char __user *, type, unsigned long, flags, void __user *, data)
57718 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
57719 + const char __user *, type, unsigned long, flags, void __user *, data)
57720 {
57721 int ret;
57722 char *kernel_type;
57723 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
57724 if (error)
57725 goto out2;
57726
57727 + if (gr_handle_chroot_pivot()) {
57728 + error = -EPERM;
57729 + goto out2;
57730 + }
57731 +
57732 get_fs_root(current->fs, &root);
57733 old_mp = lock_mount(&old);
57734 error = PTR_ERR(old_mp);
57735 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
57736 !nsown_capable(CAP_SYS_ADMIN))
57737 return -EPERM;
57738
57739 - if (fs->users != 1)
57740 + if (atomic_read(&fs->users) != 1)
57741 return -EINVAL;
57742
57743 get_mnt_ns(mnt_ns);
57744 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
57745 index f4ccfe6..a5cf064 100644
57746 --- a/fs/nfs/callback_xdr.c
57747 +++ b/fs/nfs/callback_xdr.c
57748 @@ -51,7 +51,7 @@ struct callback_op {
57749 callback_decode_arg_t decode_args;
57750 callback_encode_res_t encode_res;
57751 long res_maxsize;
57752 -};
57753 +} __do_const;
57754
57755 static struct callback_op callback_ops[];
57756
57757 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
57758 index 941246f..17d8724 100644
57759 --- a/fs/nfs/inode.c
57760 +++ b/fs/nfs/inode.c
57761 @@ -1138,16 +1138,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
57762 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
57763 }
57764
57765 -static atomic_long_t nfs_attr_generation_counter;
57766 +static atomic_long_unchecked_t nfs_attr_generation_counter;
57767
57768 static unsigned long nfs_read_attr_generation_counter(void)
57769 {
57770 - return atomic_long_read(&nfs_attr_generation_counter);
57771 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
57772 }
57773
57774 unsigned long nfs_inc_attr_generation_counter(void)
57775 {
57776 - return atomic_long_inc_return(&nfs_attr_generation_counter);
57777 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
57778 }
57779
57780 void nfs_fattr_init(struct nfs_fattr *fattr)
57781 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
57782 index 419572f..5414a23 100644
57783 --- a/fs/nfsd/nfs4proc.c
57784 +++ b/fs/nfsd/nfs4proc.c
57785 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
57786 nfsd4op_rsize op_rsize_bop;
57787 stateid_getter op_get_currentstateid;
57788 stateid_setter op_set_currentstateid;
57789 -};
57790 +} __do_const;
57791
57792 static struct nfsd4_operation nfsd4_ops[];
57793
57794 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
57795 index c2a4701..fd80e29 100644
57796 --- a/fs/nfsd/nfs4xdr.c
57797 +++ b/fs/nfsd/nfs4xdr.c
57798 @@ -1498,7 +1498,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
57799
57800 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
57801
57802 -static nfsd4_dec nfsd4_dec_ops[] = {
57803 +static const nfsd4_dec nfsd4_dec_ops[] = {
57804 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
57805 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
57806 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
57807 @@ -1538,7 +1538,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
57808 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
57809 };
57810
57811 -static nfsd4_dec nfsd41_dec_ops[] = {
57812 +static const nfsd4_dec nfsd41_dec_ops[] = {
57813 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
57814 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
57815 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
57816 @@ -1600,7 +1600,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
57817 };
57818
57819 struct nfsd4_minorversion_ops {
57820 - nfsd4_dec *decoders;
57821 + const nfsd4_dec *decoders;
57822 int nops;
57823 };
57824
57825 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
57826 index e76244e..9fe8f2f1 100644
57827 --- a/fs/nfsd/nfscache.c
57828 +++ b/fs/nfsd/nfscache.c
57829 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
57830 {
57831 struct svc_cacherep *rp = rqstp->rq_cacherep;
57832 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
57833 - int len;
57834 + long len;
57835 size_t bufsize = 0;
57836
57837 if (!rp)
57838 return;
57839
57840 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
57841 - len >>= 2;
57842 + if (statp) {
57843 + len = (char*)statp - (char*)resv->iov_base;
57844 + len = resv->iov_len - len;
57845 + len >>= 2;
57846 + }
57847
57848 /* Don't cache excessive amounts of data and XDR failures */
57849 if (!statp || len > (256 >> 2)) {
57850 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
57851 index c827acb..b253b77 100644
57852 --- a/fs/nfsd/vfs.c
57853 +++ b/fs/nfsd/vfs.c
57854 @@ -968,7 +968,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
57855 } else {
57856 oldfs = get_fs();
57857 set_fs(KERNEL_DS);
57858 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
57859 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
57860 set_fs(oldfs);
57861 }
57862
57863 @@ -1055,7 +1055,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
57864
57865 /* Write the data. */
57866 oldfs = get_fs(); set_fs(KERNEL_DS);
57867 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
57868 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
57869 set_fs(oldfs);
57870 if (host_err < 0)
57871 goto out_nfserr;
57872 @@ -1601,7 +1601,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
57873 */
57874
57875 oldfs = get_fs(); set_fs(KERNEL_DS);
57876 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
57877 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
57878 set_fs(oldfs);
57879
57880 if (host_err < 0)
57881 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
57882 index fea6bd5..8ee9d81 100644
57883 --- a/fs/nls/nls_base.c
57884 +++ b/fs/nls/nls_base.c
57885 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
57886
57887 int register_nls(struct nls_table * nls)
57888 {
57889 - struct nls_table ** tmp = &tables;
57890 + struct nls_table *tmp = tables;
57891
57892 if (nls->next)
57893 return -EBUSY;
57894
57895 spin_lock(&nls_lock);
57896 - while (*tmp) {
57897 - if (nls == *tmp) {
57898 + while (tmp) {
57899 + if (nls == tmp) {
57900 spin_unlock(&nls_lock);
57901 return -EBUSY;
57902 }
57903 - tmp = &(*tmp)->next;
57904 + tmp = tmp->next;
57905 }
57906 - nls->next = tables;
57907 + pax_open_kernel();
57908 + *(struct nls_table **)&nls->next = tables;
57909 + pax_close_kernel();
57910 tables = nls;
57911 spin_unlock(&nls_lock);
57912 return 0;
57913 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
57914
57915 int unregister_nls(struct nls_table * nls)
57916 {
57917 - struct nls_table ** tmp = &tables;
57918 + struct nls_table * const * tmp = &tables;
57919
57920 spin_lock(&nls_lock);
57921 while (*tmp) {
57922 if (nls == *tmp) {
57923 - *tmp = nls->next;
57924 + pax_open_kernel();
57925 + *(struct nls_table **)tmp = nls->next;
57926 + pax_close_kernel();
57927 spin_unlock(&nls_lock);
57928 return 0;
57929 }
57930 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
57931 index 7424929..35f6be5 100644
57932 --- a/fs/nls/nls_euc-jp.c
57933 +++ b/fs/nls/nls_euc-jp.c
57934 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
57935 p_nls = load_nls("cp932");
57936
57937 if (p_nls) {
57938 - table.charset2upper = p_nls->charset2upper;
57939 - table.charset2lower = p_nls->charset2lower;
57940 + pax_open_kernel();
57941 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
57942 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
57943 + pax_close_kernel();
57944 return register_nls(&table);
57945 }
57946
57947 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
57948 index e7bc1d7..06bd4bb 100644
57949 --- a/fs/nls/nls_koi8-ru.c
57950 +++ b/fs/nls/nls_koi8-ru.c
57951 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
57952 p_nls = load_nls("koi8-u");
57953
57954 if (p_nls) {
57955 - table.charset2upper = p_nls->charset2upper;
57956 - table.charset2lower = p_nls->charset2lower;
57957 + pax_open_kernel();
57958 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
57959 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
57960 + pax_close_kernel();
57961 return register_nls(&table);
57962 }
57963
57964 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
57965 index e44cb64..4807084 100644
57966 --- a/fs/notify/fanotify/fanotify_user.c
57967 +++ b/fs/notify/fanotify/fanotify_user.c
57968 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
57969
57970 fd = fanotify_event_metadata.fd;
57971 ret = -EFAULT;
57972 - if (copy_to_user(buf, &fanotify_event_metadata,
57973 - fanotify_event_metadata.event_len))
57974 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
57975 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
57976 goto out_close_fd;
57977
57978 ret = prepare_for_access_response(group, event, fd);
57979 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
57980 index 7b51b05..5ea5ef6 100644
57981 --- a/fs/notify/notification.c
57982 +++ b/fs/notify/notification.c
57983 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
57984 * get set to 0 so it will never get 'freed'
57985 */
57986 static struct fsnotify_event *q_overflow_event;
57987 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
57988 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
57989
57990 /**
57991 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
57992 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
57993 */
57994 u32 fsnotify_get_cookie(void)
57995 {
57996 - return atomic_inc_return(&fsnotify_sync_cookie);
57997 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
57998 }
57999 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58000
58001 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58002 index 9e38daf..5727cae 100644
58003 --- a/fs/ntfs/dir.c
58004 +++ b/fs/ntfs/dir.c
58005 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58006 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58007 ~(s64)(ndir->itype.index.block_size - 1)));
58008 /* Bounds checks. */
58009 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58010 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58011 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58012 "inode 0x%lx or driver bug.", vdir->i_ino);
58013 goto err_out;
58014 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58015 index c5670b8..d590213 100644
58016 --- a/fs/ntfs/file.c
58017 +++ b/fs/ntfs/file.c
58018 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58019 char *addr;
58020 size_t total = 0;
58021 unsigned len;
58022 - int left;
58023 + unsigned left;
58024
58025 do {
58026 len = PAGE_CACHE_SIZE - ofs;
58027 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58028 index 82650d5..db37dcf 100644
58029 --- a/fs/ntfs/super.c
58030 +++ b/fs/ntfs/super.c
58031 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58032 if (!silent)
58033 ntfs_error(sb, "Primary boot sector is invalid.");
58034 } else if (!silent)
58035 - ntfs_error(sb, read_err_str, "primary");
58036 + ntfs_error(sb, read_err_str, "%s", "primary");
58037 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58038 if (bh_primary)
58039 brelse(bh_primary);
58040 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58041 goto hotfix_primary_boot_sector;
58042 brelse(bh_backup);
58043 } else if (!silent)
58044 - ntfs_error(sb, read_err_str, "backup");
58045 + ntfs_error(sb, read_err_str, "%s", "backup");
58046 /* Try to read NT3.51- backup boot sector. */
58047 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58048 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58049 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58050 "sector.");
58051 brelse(bh_backup);
58052 } else if (!silent)
58053 - ntfs_error(sb, read_err_str, "backup");
58054 + ntfs_error(sb, read_err_str, "%s", "backup");
58055 /* We failed. Cleanup and return. */
58056 if (bh_primary)
58057 brelse(bh_primary);
58058 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58059 index aebeacd..0dcdd26 100644
58060 --- a/fs/ocfs2/localalloc.c
58061 +++ b/fs/ocfs2/localalloc.c
58062 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58063 goto bail;
58064 }
58065
58066 - atomic_inc(&osb->alloc_stats.moves);
58067 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58068
58069 bail:
58070 if (handle)
58071 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58072 index 3a90347..c40bef8 100644
58073 --- a/fs/ocfs2/ocfs2.h
58074 +++ b/fs/ocfs2/ocfs2.h
58075 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58076
58077 struct ocfs2_alloc_stats
58078 {
58079 - atomic_t moves;
58080 - atomic_t local_data;
58081 - atomic_t bitmap_data;
58082 - atomic_t bg_allocs;
58083 - atomic_t bg_extends;
58084 + atomic_unchecked_t moves;
58085 + atomic_unchecked_t local_data;
58086 + atomic_unchecked_t bitmap_data;
58087 + atomic_unchecked_t bg_allocs;
58088 + atomic_unchecked_t bg_extends;
58089 };
58090
58091 enum ocfs2_local_alloc_state
58092 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58093 index 5397c07..54afc55 100644
58094 --- a/fs/ocfs2/suballoc.c
58095 +++ b/fs/ocfs2/suballoc.c
58096 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58097 mlog_errno(status);
58098 goto bail;
58099 }
58100 - atomic_inc(&osb->alloc_stats.bg_extends);
58101 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58102
58103 /* You should never ask for this much metadata */
58104 BUG_ON(bits_wanted >
58105 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58106 mlog_errno(status);
58107 goto bail;
58108 }
58109 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58110 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58111
58112 *suballoc_loc = res.sr_bg_blkno;
58113 *suballoc_bit_start = res.sr_bit_offset;
58114 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
58115 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
58116 res->sr_bits);
58117
58118 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58119 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58120
58121 BUG_ON(res->sr_bits != 1);
58122
58123 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
58124 mlog_errno(status);
58125 goto bail;
58126 }
58127 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58128 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58129
58130 BUG_ON(res.sr_bits != 1);
58131
58132 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58133 cluster_start,
58134 num_clusters);
58135 if (!status)
58136 - atomic_inc(&osb->alloc_stats.local_data);
58137 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
58138 } else {
58139 if (min_clusters > (osb->bitmap_cpg - 1)) {
58140 /* The only paths asking for contiguousness
58141 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58142 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
58143 res.sr_bg_blkno,
58144 res.sr_bit_offset);
58145 - atomic_inc(&osb->alloc_stats.bitmap_data);
58146 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
58147 *num_clusters = res.sr_bits;
58148 }
58149 }
58150 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
58151 index 121da2d..a0232bc 100644
58152 --- a/fs/ocfs2/super.c
58153 +++ b/fs/ocfs2/super.c
58154 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
58155 "%10s => GlobalAllocs: %d LocalAllocs: %d "
58156 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
58157 "Stats",
58158 - atomic_read(&osb->alloc_stats.bitmap_data),
58159 - atomic_read(&osb->alloc_stats.local_data),
58160 - atomic_read(&osb->alloc_stats.bg_allocs),
58161 - atomic_read(&osb->alloc_stats.moves),
58162 - atomic_read(&osb->alloc_stats.bg_extends));
58163 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
58164 + atomic_read_unchecked(&osb->alloc_stats.local_data),
58165 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
58166 + atomic_read_unchecked(&osb->alloc_stats.moves),
58167 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
58168
58169 out += snprintf(buf + out, len - out,
58170 "%10s => State: %u Descriptor: %llu Size: %u bits "
58171 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
58172 spin_lock_init(&osb->osb_xattr_lock);
58173 ocfs2_init_steal_slots(osb);
58174
58175 - atomic_set(&osb->alloc_stats.moves, 0);
58176 - atomic_set(&osb->alloc_stats.local_data, 0);
58177 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
58178 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
58179 - atomic_set(&osb->alloc_stats.bg_extends, 0);
58180 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
58181 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
58182 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
58183 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
58184 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
58185
58186 /* Copy the blockcheck stats from the superblock probe */
58187 osb->osb_ecc_stats = *stats;
58188 diff --git a/fs/open.c b/fs/open.c
58189 index 7931f76..7b03f3b 100644
58190 --- a/fs/open.c
58191 +++ b/fs/open.c
58192 @@ -32,6 +32,8 @@
58193 #include <linux/dnotify.h>
58194 #include <linux/compat.h>
58195
58196 +#define CREATE_TRACE_POINTS
58197 +#include <trace/events/fs.h>
58198 #include "internal.h"
58199
58200 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
58201 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
58202 error = locks_verify_truncate(inode, NULL, length);
58203 if (!error)
58204 error = security_path_truncate(path);
58205 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
58206 + error = -EACCES;
58207 if (!error)
58208 error = do_truncate(path->dentry, length, 0, NULL);
58209
58210 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
58211 error = locks_verify_truncate(inode, f.file, length);
58212 if (!error)
58213 error = security_path_truncate(&f.file->f_path);
58214 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
58215 + error = -EACCES;
58216 if (!error)
58217 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
58218 sb_end_write(inode->i_sb);
58219 @@ -360,6 +366,9 @@ retry:
58220 if (__mnt_is_readonly(path.mnt))
58221 res = -EROFS;
58222
58223 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
58224 + res = -EACCES;
58225 +
58226 out_path_release:
58227 path_put(&path);
58228 if (retry_estale(res, lookup_flags)) {
58229 @@ -391,6 +400,8 @@ retry:
58230 if (error)
58231 goto dput_and_out;
58232
58233 + gr_log_chdir(path.dentry, path.mnt);
58234 +
58235 set_fs_pwd(current->fs, &path);
58236
58237 dput_and_out:
58238 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
58239 goto out_putf;
58240
58241 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
58242 +
58243 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
58244 + error = -EPERM;
58245 +
58246 + if (!error)
58247 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
58248 +
58249 if (!error)
58250 set_fs_pwd(current->fs, &f.file->f_path);
58251 out_putf:
58252 @@ -449,7 +467,13 @@ retry:
58253 if (error)
58254 goto dput_and_out;
58255
58256 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
58257 + goto dput_and_out;
58258 +
58259 set_fs_root(current->fs, &path);
58260 +
58261 + gr_handle_chroot_chdir(&path);
58262 +
58263 error = 0;
58264 dput_and_out:
58265 path_put(&path);
58266 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
58267 if (error)
58268 return error;
58269 mutex_lock(&inode->i_mutex);
58270 +
58271 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
58272 + error = -EACCES;
58273 + goto out_unlock;
58274 + }
58275 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
58276 + error = -EACCES;
58277 + goto out_unlock;
58278 + }
58279 +
58280 error = security_path_chmod(path, mode);
58281 if (error)
58282 goto out_unlock;
58283 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
58284 uid = make_kuid(current_user_ns(), user);
58285 gid = make_kgid(current_user_ns(), group);
58286
58287 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
58288 + return -EACCES;
58289 +
58290 newattrs.ia_valid = ATTR_CTIME;
58291 if (user != (uid_t) -1) {
58292 if (!uid_valid(uid))
58293 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
58294 } else {
58295 fsnotify_open(f);
58296 fd_install(fd, f);
58297 + trace_do_sys_open(tmp->name, flags, mode);
58298 }
58299 }
58300 putname(tmp);
58301 diff --git a/fs/pipe.c b/fs/pipe.c
58302 index d2c45e1..009fe1c 100644
58303 --- a/fs/pipe.c
58304 +++ b/fs/pipe.c
58305 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
58306
58307 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
58308 {
58309 - if (pipe->files)
58310 + if (atomic_read(&pipe->files))
58311 mutex_lock_nested(&pipe->mutex, subclass);
58312 }
58313
58314 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
58315
58316 void pipe_unlock(struct pipe_inode_info *pipe)
58317 {
58318 - if (pipe->files)
58319 + if (atomic_read(&pipe->files))
58320 mutex_unlock(&pipe->mutex);
58321 }
58322 EXPORT_SYMBOL(pipe_unlock);
58323 @@ -449,9 +449,9 @@ redo:
58324 }
58325 if (bufs) /* More to do? */
58326 continue;
58327 - if (!pipe->writers)
58328 + if (!atomic_read(&pipe->writers))
58329 break;
58330 - if (!pipe->waiting_writers) {
58331 + if (!atomic_read(&pipe->waiting_writers)) {
58332 /* syscall merging: Usually we must not sleep
58333 * if O_NONBLOCK is set, or if we got some data.
58334 * But if a writer sleeps in kernel space, then
58335 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
58336 ret = 0;
58337 __pipe_lock(pipe);
58338
58339 - if (!pipe->readers) {
58340 + if (!atomic_read(&pipe->readers)) {
58341 send_sig(SIGPIPE, current, 0);
58342 ret = -EPIPE;
58343 goto out;
58344 @@ -562,7 +562,7 @@ redo1:
58345 for (;;) {
58346 int bufs;
58347
58348 - if (!pipe->readers) {
58349 + if (!atomic_read(&pipe->readers)) {
58350 send_sig(SIGPIPE, current, 0);
58351 if (!ret)
58352 ret = -EPIPE;
58353 @@ -653,9 +653,9 @@ redo2:
58354 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58355 do_wakeup = 0;
58356 }
58357 - pipe->waiting_writers++;
58358 + atomic_inc(&pipe->waiting_writers);
58359 pipe_wait(pipe);
58360 - pipe->waiting_writers--;
58361 + atomic_dec(&pipe->waiting_writers);
58362 }
58363 out:
58364 __pipe_unlock(pipe);
58365 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58366 mask = 0;
58367 if (filp->f_mode & FMODE_READ) {
58368 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
58369 - if (!pipe->writers && filp->f_version != pipe->w_counter)
58370 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
58371 mask |= POLLHUP;
58372 }
58373
58374 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58375 * Most Unices do not set POLLERR for FIFOs but on Linux they
58376 * behave exactly like pipes for poll().
58377 */
58378 - if (!pipe->readers)
58379 + if (!atomic_read(&pipe->readers))
58380 mask |= POLLERR;
58381 }
58382
58383 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
58384
58385 __pipe_lock(pipe);
58386 if (file->f_mode & FMODE_READ)
58387 - pipe->readers--;
58388 + atomic_dec(&pipe->readers);
58389 if (file->f_mode & FMODE_WRITE)
58390 - pipe->writers--;
58391 + atomic_dec(&pipe->writers);
58392
58393 - if (pipe->readers || pipe->writers) {
58394 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
58395 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
58396 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58397 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
58398 }
58399 spin_lock(&inode->i_lock);
58400 - if (!--pipe->files) {
58401 + if (atomic_dec_and_test(&pipe->files)) {
58402 inode->i_pipe = NULL;
58403 kill = 1;
58404 }
58405 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
58406 kfree(pipe);
58407 }
58408
58409 -static struct vfsmount *pipe_mnt __read_mostly;
58410 +struct vfsmount *pipe_mnt __read_mostly;
58411
58412 /*
58413 * pipefs_dname() is called from d_path().
58414 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
58415 goto fail_iput;
58416
58417 inode->i_pipe = pipe;
58418 - pipe->files = 2;
58419 - pipe->readers = pipe->writers = 1;
58420 + atomic_set(&pipe->files, 2);
58421 + atomic_set(&pipe->readers, 1);
58422 + atomic_set(&pipe->writers, 1);
58423 inode->i_fop = &pipefifo_fops;
58424
58425 /*
58426 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
58427 spin_lock(&inode->i_lock);
58428 if (inode->i_pipe) {
58429 pipe = inode->i_pipe;
58430 - pipe->files++;
58431 + atomic_inc(&pipe->files);
58432 spin_unlock(&inode->i_lock);
58433 } else {
58434 spin_unlock(&inode->i_lock);
58435 pipe = alloc_pipe_info();
58436 if (!pipe)
58437 return -ENOMEM;
58438 - pipe->files = 1;
58439 + atomic_set(&pipe->files, 1);
58440 spin_lock(&inode->i_lock);
58441 if (unlikely(inode->i_pipe)) {
58442 - inode->i_pipe->files++;
58443 + atomic_inc(&inode->i_pipe->files);
58444 spin_unlock(&inode->i_lock);
58445 free_pipe_info(pipe);
58446 pipe = inode->i_pipe;
58447 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
58448 * opened, even when there is no process writing the FIFO.
58449 */
58450 pipe->r_counter++;
58451 - if (pipe->readers++ == 0)
58452 + if (atomic_inc_return(&pipe->readers) == 1)
58453 wake_up_partner(pipe);
58454
58455 - if (!is_pipe && !pipe->writers) {
58456 + if (!is_pipe && !atomic_read(&pipe->writers)) {
58457 if ((filp->f_flags & O_NONBLOCK)) {
58458 /* suppress POLLHUP until we have
58459 * seen a writer */
58460 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
58461 * errno=ENXIO when there is no process reading the FIFO.
58462 */
58463 ret = -ENXIO;
58464 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
58465 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
58466 goto err;
58467
58468 pipe->w_counter++;
58469 - if (!pipe->writers++)
58470 + if (atomic_inc_return(&pipe->writers) == 1)
58471 wake_up_partner(pipe);
58472
58473 - if (!is_pipe && !pipe->readers) {
58474 + if (!is_pipe && !atomic_read(&pipe->readers)) {
58475 if (wait_for_partner(pipe, &pipe->r_counter))
58476 goto err_wr;
58477 }
58478 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
58479 * the process can at least talk to itself.
58480 */
58481
58482 - pipe->readers++;
58483 - pipe->writers++;
58484 + atomic_inc(&pipe->readers);
58485 + atomic_inc(&pipe->writers);
58486 pipe->r_counter++;
58487 pipe->w_counter++;
58488 - if (pipe->readers == 1 || pipe->writers == 1)
58489 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
58490 wake_up_partner(pipe);
58491 break;
58492
58493 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
58494 return 0;
58495
58496 err_rd:
58497 - if (!--pipe->readers)
58498 + if (atomic_dec_and_test(&pipe->readers))
58499 wake_up_interruptible(&pipe->wait);
58500 ret = -ERESTARTSYS;
58501 goto err;
58502
58503 err_wr:
58504 - if (!--pipe->writers)
58505 + if (atomic_dec_and_test(&pipe->writers))
58506 wake_up_interruptible(&pipe->wait);
58507 ret = -ERESTARTSYS;
58508 goto err;
58509
58510 err:
58511 spin_lock(&inode->i_lock);
58512 - if (!--pipe->files) {
58513 + if (atomic_dec_and_test(&pipe->files)) {
58514 inode->i_pipe = NULL;
58515 kill = 1;
58516 }
58517 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
58518 index 15af622..0e9f4467 100644
58519 --- a/fs/proc/Kconfig
58520 +++ b/fs/proc/Kconfig
58521 @@ -30,12 +30,12 @@ config PROC_FS
58522
58523 config PROC_KCORE
58524 bool "/proc/kcore support" if !ARM
58525 - depends on PROC_FS && MMU
58526 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
58527
58528 config PROC_VMCORE
58529 bool "/proc/vmcore support"
58530 - depends on PROC_FS && CRASH_DUMP
58531 - default y
58532 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
58533 + default n
58534 help
58535 Exports the dump image of crashed kernel in ELF format.
58536
58537 @@ -59,8 +59,8 @@ config PROC_SYSCTL
58538 limited in memory.
58539
58540 config PROC_PAGE_MONITOR
58541 - default y
58542 - depends on PROC_FS && MMU
58543 + default n
58544 + depends on PROC_FS && MMU && !GRKERNSEC
58545 bool "Enable /proc page monitoring" if EXPERT
58546 help
58547 Various /proc files exist to monitor process memory utilization:
58548 diff --git a/fs/proc/array.c b/fs/proc/array.c
58549 index cbd0f1b..adec3f0 100644
58550 --- a/fs/proc/array.c
58551 +++ b/fs/proc/array.c
58552 @@ -60,6 +60,7 @@
58553 #include <linux/tty.h>
58554 #include <linux/string.h>
58555 #include <linux/mman.h>
58556 +#include <linux/grsecurity.h>
58557 #include <linux/proc_fs.h>
58558 #include <linux/ioport.h>
58559 #include <linux/uaccess.h>
58560 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
58561 seq_putc(m, '\n');
58562 }
58563
58564 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58565 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
58566 +{
58567 + if (p->mm)
58568 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
58569 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
58570 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
58571 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
58572 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
58573 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
58574 + else
58575 + seq_printf(m, "PaX:\t-----\n");
58576 +}
58577 +#endif
58578 +
58579 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58580 struct pid *pid, struct task_struct *task)
58581 {
58582 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
58583 task_cpus_allowed(m, task);
58584 cpuset_task_status_allowed(m, task);
58585 task_context_switch_counts(m, task);
58586 +
58587 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
58588 + task_pax(m, task);
58589 +#endif
58590 +
58591 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
58592 + task_grsec_rbac(m, task);
58593 +#endif
58594 +
58595 return 0;
58596 }
58597
58598 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58599 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
58600 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
58601 + _mm->pax_flags & MF_PAX_SEGMEXEC))
58602 +#endif
58603 +
58604 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58605 struct pid *pid, struct task_struct *task, int whole)
58606 {
58607 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58608 char tcomm[sizeof(task->comm)];
58609 unsigned long flags;
58610
58611 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58612 + if (current->exec_id != m->exec_id) {
58613 + gr_log_badprocpid("stat");
58614 + return 0;
58615 + }
58616 +#endif
58617 +
58618 state = *get_task_state(task);
58619 vsize = eip = esp = 0;
58620 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
58621 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58622 gtime = task_gtime(task);
58623 }
58624
58625 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58626 + if (PAX_RAND_FLAGS(mm)) {
58627 + eip = 0;
58628 + esp = 0;
58629 + wchan = 0;
58630 + }
58631 +#endif
58632 +#ifdef CONFIG_GRKERNSEC_HIDESYM
58633 + wchan = 0;
58634 + eip =0;
58635 + esp =0;
58636 +#endif
58637 +
58638 /* scale priority and nice values from timeslices to -20..20 */
58639 /* to make it look like a "normal" Unix priority/nice value */
58640 priority = task_prio(task);
58641 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58642 seq_put_decimal_ull(m, ' ', vsize);
58643 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
58644 seq_put_decimal_ull(m, ' ', rsslim);
58645 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58646 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
58647 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
58648 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
58649 +#else
58650 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
58651 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
58652 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
58653 +#endif
58654 seq_put_decimal_ull(m, ' ', esp);
58655 seq_put_decimal_ull(m, ' ', eip);
58656 /* The signal information here is obsolete.
58657 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
58658 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
58659 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
58660
58661 - if (mm && permitted) {
58662 + if (mm && permitted
58663 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58664 + && !PAX_RAND_FLAGS(mm)
58665 +#endif
58666 + ) {
58667 seq_put_decimal_ull(m, ' ', mm->start_data);
58668 seq_put_decimal_ull(m, ' ', mm->end_data);
58669 seq_put_decimal_ull(m, ' ', mm->start_brk);
58670 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
58671 struct pid *pid, struct task_struct *task)
58672 {
58673 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
58674 - struct mm_struct *mm = get_task_mm(task);
58675 + struct mm_struct *mm;
58676
58677 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58678 + if (current->exec_id != m->exec_id) {
58679 + gr_log_badprocpid("statm");
58680 + return 0;
58681 + }
58682 +#endif
58683 + mm = get_task_mm(task);
58684 if (mm) {
58685 size = task_statm(mm, &shared, &text, &data, &resident);
58686 mmput(mm);
58687 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
58688 return 0;
58689 }
58690
58691 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
58692 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
58693 +{
58694 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
58695 +}
58696 +#endif
58697 +
58698 #ifdef CONFIG_CHECKPOINT_RESTORE
58699 static struct pid *
58700 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
58701 diff --git a/fs/proc/base.c b/fs/proc/base.c
58702 index 1485e38..8ad4236 100644
58703 --- a/fs/proc/base.c
58704 +++ b/fs/proc/base.c
58705 @@ -113,6 +113,14 @@ struct pid_entry {
58706 union proc_op op;
58707 };
58708
58709 +struct getdents_callback {
58710 + struct linux_dirent __user * current_dir;
58711 + struct linux_dirent __user * previous;
58712 + struct file * file;
58713 + int count;
58714 + int error;
58715 +};
58716 +
58717 #define NOD(NAME, MODE, IOP, FOP, OP) { \
58718 .name = (NAME), \
58719 .len = sizeof(NAME) - 1, \
58720 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
58721 if (!mm->arg_end)
58722 goto out_mm; /* Shh! No looking before we're done */
58723
58724 + if (gr_acl_handle_procpidmem(task))
58725 + goto out_mm;
58726 +
58727 len = mm->arg_end - mm->arg_start;
58728
58729 if (len > PAGE_SIZE)
58730 @@ -237,12 +248,28 @@ out:
58731 return res;
58732 }
58733
58734 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58735 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
58736 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
58737 + _mm->pax_flags & MF_PAX_SEGMEXEC))
58738 +#endif
58739 +
58740 static int proc_pid_auxv(struct task_struct *task, char *buffer)
58741 {
58742 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
58743 int res = PTR_ERR(mm);
58744 if (mm && !IS_ERR(mm)) {
58745 unsigned int nwords = 0;
58746 +
58747 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58748 + /* allow if we're currently ptracing this task */
58749 + if (PAX_RAND_FLAGS(mm) &&
58750 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
58751 + mmput(mm);
58752 + return 0;
58753 + }
58754 +#endif
58755 +
58756 do {
58757 nwords += 2;
58758 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
58759 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
58760 }
58761
58762
58763 -#ifdef CONFIG_KALLSYMS
58764 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
58765 /*
58766 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
58767 * Returns the resolved symbol. If that fails, simply return the address.
58768 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
58769 mutex_unlock(&task->signal->cred_guard_mutex);
58770 }
58771
58772 -#ifdef CONFIG_STACKTRACE
58773 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
58774
58775 #define MAX_STACK_TRACE_DEPTH 64
58776
58777 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
58778 return count;
58779 }
58780
58781 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
58782 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
58783 static int proc_pid_syscall(struct task_struct *task, char *buffer)
58784 {
58785 long nr;
58786 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
58787 /************************************************************************/
58788
58789 /* permission checks */
58790 -static int proc_fd_access_allowed(struct inode *inode)
58791 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
58792 {
58793 struct task_struct *task;
58794 int allowed = 0;
58795 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
58796 */
58797 task = get_proc_task(inode);
58798 if (task) {
58799 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
58800 + if (log)
58801 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
58802 + else
58803 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
58804 put_task_struct(task);
58805 }
58806 return allowed;
58807 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
58808 struct task_struct *task,
58809 int hide_pid_min)
58810 {
58811 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
58812 + return false;
58813 +
58814 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
58815 + rcu_read_lock();
58816 + {
58817 + const struct cred *tmpcred = current_cred();
58818 + const struct cred *cred = __task_cred(task);
58819 +
58820 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
58821 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
58822 + || in_group_p(grsec_proc_gid)
58823 +#endif
58824 + ) {
58825 + rcu_read_unlock();
58826 + return true;
58827 + }
58828 + }
58829 + rcu_read_unlock();
58830 +
58831 + if (!pid->hide_pid)
58832 + return false;
58833 +#endif
58834 +
58835 if (pid->hide_pid < hide_pid_min)
58836 return true;
58837 if (in_group_p(pid->pid_gid))
58838 return true;
58839 +
58840 return ptrace_may_access(task, PTRACE_MODE_READ);
58841 }
58842
58843 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
58844 put_task_struct(task);
58845
58846 if (!has_perms) {
58847 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
58848 + {
58849 +#else
58850 if (pid->hide_pid == 2) {
58851 +#endif
58852 /*
58853 * Let's make getdents(), stat(), and open()
58854 * consistent with each other. If a process
58855 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
58856 if (!task)
58857 return -ESRCH;
58858
58859 + if (gr_acl_handle_procpidmem(task)) {
58860 + put_task_struct(task);
58861 + return -EPERM;
58862 + }
58863 +
58864 mm = mm_access(task, mode);
58865 put_task_struct(task);
58866
58867 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
58868
58869 file->private_data = mm;
58870
58871 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58872 + file->f_version = current->exec_id;
58873 +#endif
58874 +
58875 return 0;
58876 }
58877
58878 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
58879 ssize_t copied;
58880 char *page;
58881
58882 +#ifdef CONFIG_GRKERNSEC
58883 + if (write)
58884 + return -EPERM;
58885 +#endif
58886 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58887 + if (file->f_version != current->exec_id) {
58888 + gr_log_badprocpid("mem");
58889 + return 0;
58890 + }
58891 +#endif
58892 +
58893 if (!mm)
58894 return 0;
58895
58896 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
58897 goto free;
58898
58899 while (count > 0) {
58900 - int this_len = min_t(int, count, PAGE_SIZE);
58901 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
58902
58903 if (write && copy_from_user(page, buf, this_len)) {
58904 copied = -EFAULT;
58905 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
58906 if (!mm)
58907 return 0;
58908
58909 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58910 + if (file->f_version != current->exec_id) {
58911 + gr_log_badprocpid("environ");
58912 + return 0;
58913 + }
58914 +#endif
58915 +
58916 page = (char *)__get_free_page(GFP_TEMPORARY);
58917 if (!page)
58918 return -ENOMEM;
58919 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
58920 goto free;
58921 while (count > 0) {
58922 size_t this_len, max_len;
58923 - int retval;
58924 + ssize_t retval;
58925
58926 if (src >= (mm->env_end - mm->env_start))
58927 break;
58928 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
58929 int error = -EACCES;
58930
58931 /* Are we allowed to snoop on the tasks file descriptors? */
58932 - if (!proc_fd_access_allowed(inode))
58933 + if (!proc_fd_access_allowed(inode, 0))
58934 goto out;
58935
58936 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
58937 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
58938 struct path path;
58939
58940 /* Are we allowed to snoop on the tasks file descriptors? */
58941 - if (!proc_fd_access_allowed(inode))
58942 - goto out;
58943 + /* logging this is needed for learning on chromium to work properly,
58944 + but we don't want to flood the logs from 'ps' which does a readlink
58945 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
58946 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
58947 + */
58948 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
58949 + if (!proc_fd_access_allowed(inode,0))
58950 + goto out;
58951 + } else {
58952 + if (!proc_fd_access_allowed(inode,1))
58953 + goto out;
58954 + }
58955
58956 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
58957 if (error)
58958 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
58959 rcu_read_lock();
58960 cred = __task_cred(task);
58961 inode->i_uid = cred->euid;
58962 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
58963 + inode->i_gid = grsec_proc_gid;
58964 +#else
58965 inode->i_gid = cred->egid;
58966 +#endif
58967 rcu_read_unlock();
58968 }
58969 security_task_to_inode(task, inode);
58970 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
58971 return -ENOENT;
58972 }
58973 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
58974 +#ifdef CONFIG_GRKERNSEC_PROC_USER
58975 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
58976 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
58977 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
58978 +#endif
58979 task_dumpable(task)) {
58980 cred = __task_cred(task);
58981 stat->uid = cred->euid;
58982 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
58983 + stat->gid = grsec_proc_gid;
58984 +#else
58985 stat->gid = cred->egid;
58986 +#endif
58987 }
58988 }
58989 rcu_read_unlock();
58990 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
58991
58992 if (task) {
58993 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
58994 +#ifdef CONFIG_GRKERNSEC_PROC_USER
58995 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
58996 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
58997 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
58998 +#endif
58999 task_dumpable(task)) {
59000 rcu_read_lock();
59001 cred = __task_cred(task);
59002 inode->i_uid = cred->euid;
59003 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59004 + inode->i_gid = grsec_proc_gid;
59005 +#else
59006 inode->i_gid = cred->egid;
59007 +#endif
59008 rcu_read_unlock();
59009 } else {
59010 inode->i_uid = GLOBAL_ROOT_UID;
59011 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59012 if (!task)
59013 goto out_no_task;
59014
59015 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59016 + goto out;
59017 +
59018 /*
59019 * Yes, it does not scale. And it should not. Don't add
59020 * new entries into /proc/<tgid>/ without very good reasons.
59021 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59022 if (!task)
59023 return -ENOENT;
59024
59025 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59026 + goto out;
59027 +
59028 if (!dir_emit_dots(file, ctx))
59029 goto out;
59030
59031 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59032 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59033 #endif
59034 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59035 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59036 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59037 INF("syscall", S_IRUGO, proc_pid_syscall),
59038 #endif
59039 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59040 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59041 #ifdef CONFIG_SECURITY
59042 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59043 #endif
59044 -#ifdef CONFIG_KALLSYMS
59045 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59046 INF("wchan", S_IRUGO, proc_pid_wchan),
59047 #endif
59048 -#ifdef CONFIG_STACKTRACE
59049 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59050 ONE("stack", S_IRUGO, proc_pid_stack),
59051 #endif
59052 #ifdef CONFIG_SCHEDSTATS
59053 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59054 #ifdef CONFIG_HARDWALL
59055 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59056 #endif
59057 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59058 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59059 +#endif
59060 #ifdef CONFIG_USER_NS
59061 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59062 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59063 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59064 if (!inode)
59065 goto out;
59066
59067 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59068 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59069 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59070 + inode->i_gid = grsec_proc_gid;
59071 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59072 +#else
59073 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59074 +#endif
59075 inode->i_op = &proc_tgid_base_inode_operations;
59076 inode->i_fop = &proc_tgid_base_operations;
59077 inode->i_flags|=S_IMMUTABLE;
59078 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59079 if (!task)
59080 goto out;
59081
59082 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59083 + goto out_put_task;
59084 +
59085 result = proc_pid_instantiate(dir, dentry, task, NULL);
59086 +out_put_task:
59087 put_task_struct(task);
59088 out:
59089 return ERR_PTR(result);
59090 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59091 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59092 #endif
59093 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59094 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59095 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59096 INF("syscall", S_IRUGO, proc_pid_syscall),
59097 #endif
59098 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59099 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59100 #ifdef CONFIG_SECURITY
59101 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59102 #endif
59103 -#ifdef CONFIG_KALLSYMS
59104 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59105 INF("wchan", S_IRUGO, proc_pid_wchan),
59106 #endif
59107 -#ifdef CONFIG_STACKTRACE
59108 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59109 ONE("stack", S_IRUGO, proc_pid_stack),
59110 #endif
59111 #ifdef CONFIG_SCHEDSTATS
59112 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
59113 index 82676e3..5f8518a 100644
59114 --- a/fs/proc/cmdline.c
59115 +++ b/fs/proc/cmdline.c
59116 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
59117
59118 static int __init proc_cmdline_init(void)
59119 {
59120 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59121 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
59122 +#else
59123 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
59124 +#endif
59125 return 0;
59126 }
59127 module_init(proc_cmdline_init);
59128 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
59129 index b143471..bb105e5 100644
59130 --- a/fs/proc/devices.c
59131 +++ b/fs/proc/devices.c
59132 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
59133
59134 static int __init proc_devices_init(void)
59135 {
59136 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59137 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
59138 +#else
59139 proc_create("devices", 0, NULL, &proc_devinfo_operations);
59140 +#endif
59141 return 0;
59142 }
59143 module_init(proc_devices_init);
59144 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
59145 index 0ff80f9..a1d7500 100644
59146 --- a/fs/proc/fd.c
59147 +++ b/fs/proc/fd.c
59148 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
59149 if (!task)
59150 return -ENOENT;
59151
59152 - files = get_files_struct(task);
59153 + if (!gr_acl_handle_procpidmem(task))
59154 + files = get_files_struct(task);
59155 put_task_struct(task);
59156
59157 if (files) {
59158 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
59159 */
59160 int proc_fd_permission(struct inode *inode, int mask)
59161 {
59162 + struct task_struct *task;
59163 int rv = generic_permission(inode, mask);
59164 - if (rv == 0)
59165 - return 0;
59166 +
59167 if (task_pid(current) == proc_pid(inode))
59168 rv = 0;
59169 +
59170 + task = get_proc_task(inode);
59171 + if (task == NULL)
59172 + return rv;
59173 +
59174 + if (gr_acl_handle_procpidmem(task))
59175 + rv = -EACCES;
59176 +
59177 + put_task_struct(task);
59178 +
59179 return rv;
59180 }
59181
59182 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
59183 index 073aea6..0630370 100644
59184 --- a/fs/proc/inode.c
59185 +++ b/fs/proc/inode.c
59186 @@ -23,11 +23,17 @@
59187 #include <linux/slab.h>
59188 #include <linux/mount.h>
59189 #include <linux/magic.h>
59190 +#include <linux/grsecurity.h>
59191
59192 #include <asm/uaccess.h>
59193
59194 #include "internal.h"
59195
59196 +#ifdef CONFIG_PROC_SYSCTL
59197 +extern const struct inode_operations proc_sys_inode_operations;
59198 +extern const struct inode_operations proc_sys_dir_operations;
59199 +#endif
59200 +
59201 static void proc_evict_inode(struct inode *inode)
59202 {
59203 struct proc_dir_entry *de;
59204 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
59205 ns = PROC_I(inode)->ns.ns;
59206 if (ns_ops && ns)
59207 ns_ops->put(ns);
59208 +
59209 +#ifdef CONFIG_PROC_SYSCTL
59210 + if (inode->i_op == &proc_sys_inode_operations ||
59211 + inode->i_op == &proc_sys_dir_operations)
59212 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
59213 +#endif
59214 +
59215 }
59216
59217 static struct kmem_cache * proc_inode_cachep;
59218 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
59219 if (de->mode) {
59220 inode->i_mode = de->mode;
59221 inode->i_uid = de->uid;
59222 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59223 + inode->i_gid = grsec_proc_gid;
59224 +#else
59225 inode->i_gid = de->gid;
59226 +#endif
59227 }
59228 if (de->size)
59229 inode->i_size = de->size;
59230 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
59231 index 651d09a..60c73ae 100644
59232 --- a/fs/proc/internal.h
59233 +++ b/fs/proc/internal.h
59234 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
59235 struct pid *, struct task_struct *);
59236 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
59237 struct pid *, struct task_struct *);
59238 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59239 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
59240 +#endif
59241
59242 /*
59243 * base.c
59244 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
59245 index 06ea155..9a798c7 100644
59246 --- a/fs/proc/kcore.c
59247 +++ b/fs/proc/kcore.c
59248 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59249 * the addresses in the elf_phdr on our list.
59250 */
59251 start = kc_offset_to_vaddr(*fpos - elf_buflen);
59252 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
59253 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
59254 + if (tsz > buflen)
59255 tsz = buflen;
59256 -
59257 +
59258 while (buflen) {
59259 struct kcore_list *m;
59260
59261 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59262 kfree(elf_buf);
59263 } else {
59264 if (kern_addr_valid(start)) {
59265 - unsigned long n;
59266 + char *elf_buf;
59267 + mm_segment_t oldfs;
59268
59269 - n = copy_to_user(buffer, (char *)start, tsz);
59270 - /*
59271 - * We cannot distinguish between fault on source
59272 - * and fault on destination. When this happens
59273 - * we clear too and hope it will trigger the
59274 - * EFAULT again.
59275 - */
59276 - if (n) {
59277 - if (clear_user(buffer + tsz - n,
59278 - n))
59279 + elf_buf = kmalloc(tsz, GFP_KERNEL);
59280 + if (!elf_buf)
59281 + return -ENOMEM;
59282 + oldfs = get_fs();
59283 + set_fs(KERNEL_DS);
59284 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
59285 + set_fs(oldfs);
59286 + if (copy_to_user(buffer, elf_buf, tsz)) {
59287 + kfree(elf_buf);
59288 return -EFAULT;
59289 + }
59290 }
59291 + set_fs(oldfs);
59292 + kfree(elf_buf);
59293 } else {
59294 if (clear_user(buffer, tsz))
59295 return -EFAULT;
59296 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59297
59298 static int open_kcore(struct inode *inode, struct file *filp)
59299 {
59300 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
59301 + return -EPERM;
59302 +#endif
59303 if (!capable(CAP_SYS_RAWIO))
59304 return -EPERM;
59305 if (kcore_need_update)
59306 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
59307 index 5aa847a..f77c8d4 100644
59308 --- a/fs/proc/meminfo.c
59309 +++ b/fs/proc/meminfo.c
59310 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
59311 vmi.used >> 10,
59312 vmi.largest_chunk >> 10
59313 #ifdef CONFIG_MEMORY_FAILURE
59314 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59315 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59316 #endif
59317 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
59318 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
59319 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
59320 index ccfd99b..1b7e255 100644
59321 --- a/fs/proc/nommu.c
59322 +++ b/fs/proc/nommu.c
59323 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
59324 if (len < 1)
59325 len = 1;
59326 seq_printf(m, "%*c", len, ' ');
59327 - seq_path(m, &file->f_path, "");
59328 + seq_path(m, &file->f_path, "\n\\");
59329 }
59330
59331 seq_putc(m, '\n');
59332 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
59333 index 4677bb7..408e936 100644
59334 --- a/fs/proc/proc_net.c
59335 +++ b/fs/proc/proc_net.c
59336 @@ -23,6 +23,7 @@
59337 #include <linux/nsproxy.h>
59338 #include <net/net_namespace.h>
59339 #include <linux/seq_file.h>
59340 +#include <linux/grsecurity.h>
59341
59342 #include "internal.h"
59343
59344 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
59345 struct task_struct *task;
59346 struct nsproxy *ns;
59347 struct net *net = NULL;
59348 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59349 + const struct cred *cred = current_cred();
59350 +#endif
59351 +
59352 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59353 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
59354 + return net;
59355 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59356 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
59357 + return net;
59358 +#endif
59359
59360 rcu_read_lock();
59361 task = pid_task(proc_pid(dir), PIDTYPE_PID);
59362 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
59363 index 7129046..f2779c6 100644
59364 --- a/fs/proc/proc_sysctl.c
59365 +++ b/fs/proc/proc_sysctl.c
59366 @@ -13,11 +13,15 @@
59367 #include <linux/module.h>
59368 #include "internal.h"
59369
59370 +extern int gr_handle_chroot_sysctl(const int op);
59371 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
59372 + const int op);
59373 +
59374 static const struct dentry_operations proc_sys_dentry_operations;
59375 static const struct file_operations proc_sys_file_operations;
59376 -static const struct inode_operations proc_sys_inode_operations;
59377 +const struct inode_operations proc_sys_inode_operations;
59378 static const struct file_operations proc_sys_dir_file_operations;
59379 -static const struct inode_operations proc_sys_dir_operations;
59380 +const struct inode_operations proc_sys_dir_operations;
59381
59382 void proc_sys_poll_notify(struct ctl_table_poll *poll)
59383 {
59384 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
59385
59386 err = NULL;
59387 d_set_d_op(dentry, &proc_sys_dentry_operations);
59388 +
59389 + gr_handle_proc_create(dentry, inode);
59390 +
59391 d_add(dentry, inode);
59392
59393 out:
59394 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59395 struct inode *inode = file_inode(filp);
59396 struct ctl_table_header *head = grab_header(inode);
59397 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
59398 + int op = write ? MAY_WRITE : MAY_READ;
59399 ssize_t error;
59400 size_t res;
59401
59402 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59403 * and won't be until we finish.
59404 */
59405 error = -EPERM;
59406 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
59407 + if (sysctl_perm(head, table, op))
59408 goto out;
59409
59410 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
59411 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59412 if (!table->proc_handler)
59413 goto out;
59414
59415 +#ifdef CONFIG_GRKERNSEC
59416 + error = -EPERM;
59417 + if (gr_handle_chroot_sysctl(op))
59418 + goto out;
59419 + dget(filp->f_path.dentry);
59420 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
59421 + dput(filp->f_path.dentry);
59422 + goto out;
59423 + }
59424 + dput(filp->f_path.dentry);
59425 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
59426 + goto out;
59427 + if (write && !capable(CAP_SYS_ADMIN))
59428 + goto out;
59429 +#endif
59430 +
59431 /* careful: calling conventions are nasty here */
59432 res = count;
59433 error = table->proc_handler(table, write, buf, &res, ppos);
59434 @@ -598,6 +622,9 @@ static bool proc_sys_fill_cache(struct file *file,
59435 return false;
59436 } else {
59437 d_set_d_op(child, &proc_sys_dentry_operations);
59438 +
59439 + gr_handle_proc_create(child, inode);
59440 +
59441 d_add(child, inode);
59442 }
59443 } else {
59444 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
59445 if ((*pos)++ < ctx->pos)
59446 return true;
59447
59448 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
59449 + return 0;
59450 +
59451 if (unlikely(S_ISLNK(table->mode)))
59452 res = proc_sys_link_fill_cache(file, ctx, head, table);
59453 else
59454 @@ -734,6 +764,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
59455 if (IS_ERR(head))
59456 return PTR_ERR(head);
59457
59458 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
59459 + return -ENOENT;
59460 +
59461 generic_fillattr(inode, stat);
59462 if (table)
59463 stat->mode = (stat->mode & S_IFMT) | table->mode;
59464 @@ -756,13 +789,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
59465 .llseek = generic_file_llseek,
59466 };
59467
59468 -static const struct inode_operations proc_sys_inode_operations = {
59469 +const struct inode_operations proc_sys_inode_operations = {
59470 .permission = proc_sys_permission,
59471 .setattr = proc_sys_setattr,
59472 .getattr = proc_sys_getattr,
59473 };
59474
59475 -static const struct inode_operations proc_sys_dir_operations = {
59476 +const struct inode_operations proc_sys_dir_operations = {
59477 .lookup = proc_sys_lookup,
59478 .permission = proc_sys_permission,
59479 .setattr = proc_sys_setattr,
59480 @@ -839,7 +872,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
59481 static struct ctl_dir *new_dir(struct ctl_table_set *set,
59482 const char *name, int namelen)
59483 {
59484 - struct ctl_table *table;
59485 + ctl_table_no_const *table;
59486 struct ctl_dir *new;
59487 struct ctl_node *node;
59488 char *new_name;
59489 @@ -851,7 +884,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
59490 return NULL;
59491
59492 node = (struct ctl_node *)(new + 1);
59493 - table = (struct ctl_table *)(node + 1);
59494 + table = (ctl_table_no_const *)(node + 1);
59495 new_name = (char *)(table + 2);
59496 memcpy(new_name, name, namelen);
59497 new_name[namelen] = '\0';
59498 @@ -1020,7 +1053,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
59499 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
59500 struct ctl_table_root *link_root)
59501 {
59502 - struct ctl_table *link_table, *entry, *link;
59503 + ctl_table_no_const *link_table, *link;
59504 + struct ctl_table *entry;
59505 struct ctl_table_header *links;
59506 struct ctl_node *node;
59507 char *link_name;
59508 @@ -1043,7 +1077,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
59509 return NULL;
59510
59511 node = (struct ctl_node *)(links + 1);
59512 - link_table = (struct ctl_table *)(node + nr_entries);
59513 + link_table = (ctl_table_no_const *)(node + nr_entries);
59514 link_name = (char *)&link_table[nr_entries + 1];
59515
59516 for (link = link_table, entry = table; entry->procname; link++, entry++) {
59517 @@ -1291,8 +1325,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59518 struct ctl_table_header ***subheader, struct ctl_table_set *set,
59519 struct ctl_table *table)
59520 {
59521 - struct ctl_table *ctl_table_arg = NULL;
59522 - struct ctl_table *entry, *files;
59523 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
59524 + struct ctl_table *entry;
59525 int nr_files = 0;
59526 int nr_dirs = 0;
59527 int err = -ENOMEM;
59528 @@ -1304,10 +1338,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59529 nr_files++;
59530 }
59531
59532 - files = table;
59533 /* If there are mixed files and directories we need a new table */
59534 if (nr_dirs && nr_files) {
59535 - struct ctl_table *new;
59536 + ctl_table_no_const *new;
59537 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
59538 GFP_KERNEL);
59539 if (!files)
59540 @@ -1325,7 +1358,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
59541 /* Register everything except a directory full of subdirectories */
59542 if (nr_files || !nr_dirs) {
59543 struct ctl_table_header *header;
59544 - header = __register_sysctl_table(set, path, files);
59545 + header = __register_sysctl_table(set, path, files ? files : table);
59546 if (!header) {
59547 kfree(ctl_table_arg);
59548 goto out;
59549 diff --git a/fs/proc/root.c b/fs/proc/root.c
59550 index 0e0e83c..005ba6a 100644
59551 --- a/fs/proc/root.c
59552 +++ b/fs/proc/root.c
59553 @@ -183,7 +183,15 @@ void __init proc_root_init(void)
59554 #ifdef CONFIG_PROC_DEVICETREE
59555 proc_device_tree_init();
59556 #endif
59557 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59558 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59559 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
59560 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59561 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
59562 +#endif
59563 +#else
59564 proc_mkdir("bus", NULL);
59565 +#endif
59566 proc_sys_init();
59567 }
59568
59569 diff --git a/fs/proc/self.c b/fs/proc/self.c
59570 index 6b6a993..807cccc 100644
59571 --- a/fs/proc/self.c
59572 +++ b/fs/proc/self.c
59573 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
59574 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
59575 void *cookie)
59576 {
59577 - char *s = nd_get_link(nd);
59578 + const char *s = nd_get_link(nd);
59579 if (!IS_ERR(s))
59580 kfree(s);
59581 }
59582 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
59583 index 107d026..c715aeb 100644
59584 --- a/fs/proc/task_mmu.c
59585 +++ b/fs/proc/task_mmu.c
59586 @@ -12,12 +12,19 @@
59587 #include <linux/swap.h>
59588 #include <linux/swapops.h>
59589 #include <linux/mmu_notifier.h>
59590 +#include <linux/grsecurity.h>
59591
59592 #include <asm/elf.h>
59593 #include <asm/uaccess.h>
59594 #include <asm/tlbflush.h>
59595 #include "internal.h"
59596
59597 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59598 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59599 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59600 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59601 +#endif
59602 +
59603 void task_mem(struct seq_file *m, struct mm_struct *mm)
59604 {
59605 unsigned long data, text, lib, swap;
59606 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59607 "VmExe:\t%8lu kB\n"
59608 "VmLib:\t%8lu kB\n"
59609 "VmPTE:\t%8lu kB\n"
59610 - "VmSwap:\t%8lu kB\n",
59611 - hiwater_vm << (PAGE_SHIFT-10),
59612 + "VmSwap:\t%8lu kB\n"
59613 +
59614 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59615 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
59616 +#endif
59617 +
59618 + ,hiwater_vm << (PAGE_SHIFT-10),
59619 total_vm << (PAGE_SHIFT-10),
59620 mm->locked_vm << (PAGE_SHIFT-10),
59621 mm->pinned_vm << (PAGE_SHIFT-10),
59622 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59623 data << (PAGE_SHIFT-10),
59624 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
59625 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
59626 - swap << (PAGE_SHIFT-10));
59627 + swap << (PAGE_SHIFT-10)
59628 +
59629 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
59630 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59631 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
59632 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
59633 +#else
59634 + , mm->context.user_cs_base
59635 + , mm->context.user_cs_limit
59636 +#endif
59637 +#endif
59638 +
59639 + );
59640 }
59641
59642 unsigned long task_vsize(struct mm_struct *mm)
59643 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59644 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
59645 }
59646
59647 - /* We don't show the stack guard page in /proc/maps */
59648 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59649 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
59650 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
59651 +#else
59652 start = vma->vm_start;
59653 - if (stack_guard_page_start(vma, start))
59654 - start += PAGE_SIZE;
59655 end = vma->vm_end;
59656 - if (stack_guard_page_end(vma, end))
59657 - end -= PAGE_SIZE;
59658 +#endif
59659
59660 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
59661 start,
59662 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59663 flags & VM_WRITE ? 'w' : '-',
59664 flags & VM_EXEC ? 'x' : '-',
59665 flags & VM_MAYSHARE ? 's' : 'p',
59666 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59667 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
59668 +#else
59669 pgoff,
59670 +#endif
59671 MAJOR(dev), MINOR(dev), ino, &len);
59672
59673 /*
59674 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59675 */
59676 if (file) {
59677 pad_len_spaces(m, len);
59678 - seq_path(m, &file->f_path, "\n");
59679 + seq_path(m, &file->f_path, "\n\\");
59680 goto done;
59681 }
59682
59683 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
59684 * Thread stack in /proc/PID/task/TID/maps or
59685 * the main process stack.
59686 */
59687 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
59688 - vma->vm_end >= mm->start_stack)) {
59689 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
59690 + (vma->vm_start <= mm->start_stack &&
59691 + vma->vm_end >= mm->start_stack)) {
59692 name = "[stack]";
59693 } else {
59694 /* Thread stack in /proc/PID/maps */
59695 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
59696 struct proc_maps_private *priv = m->private;
59697 struct task_struct *task = priv->task;
59698
59699 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59700 + if (current->exec_id != m->exec_id) {
59701 + gr_log_badprocpid("maps");
59702 + return 0;
59703 + }
59704 +#endif
59705 +
59706 show_map_vma(m, vma, is_pid);
59707
59708 if (m->count < m->size) /* vma is copied successfully */
59709 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
59710 .private = &mss,
59711 };
59712
59713 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59714 + if (current->exec_id != m->exec_id) {
59715 + gr_log_badprocpid("smaps");
59716 + return 0;
59717 + }
59718 +#endif
59719 memset(&mss, 0, sizeof mss);
59720 - mss.vma = vma;
59721 - /* mmap_sem is held in m_start */
59722 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
59723 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
59724 -
59725 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59726 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
59727 +#endif
59728 + mss.vma = vma;
59729 + /* mmap_sem is held in m_start */
59730 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
59731 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
59732 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59733 + }
59734 +#endif
59735 show_map_vma(m, vma, is_pid);
59736
59737 seq_printf(m,
59738 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
59739 "KernelPageSize: %8lu kB\n"
59740 "MMUPageSize: %8lu kB\n"
59741 "Locked: %8lu kB\n",
59742 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59743 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
59744 +#else
59745 (vma->vm_end - vma->vm_start) >> 10,
59746 +#endif
59747 mss.resident >> 10,
59748 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
59749 mss.shared_clean >> 10,
59750 @@ -1362,6 +1413,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
59751 int n;
59752 char buffer[50];
59753
59754 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59755 + if (current->exec_id != m->exec_id) {
59756 + gr_log_badprocpid("numa_maps");
59757 + return 0;
59758 + }
59759 +#endif
59760 +
59761 if (!mm)
59762 return 0;
59763
59764 @@ -1379,11 +1437,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
59765 mpol_to_str(buffer, sizeof(buffer), pol);
59766 mpol_cond_put(pol);
59767
59768 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59769 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
59770 +#else
59771 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
59772 +#endif
59773
59774 if (file) {
59775 seq_printf(m, " file=");
59776 - seq_path(m, &file->f_path, "\n\t= ");
59777 + seq_path(m, &file->f_path, "\n\t\\= ");
59778 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
59779 seq_printf(m, " heap");
59780 } else {
59781 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
59782 index 56123a6..5a2f6ec 100644
59783 --- a/fs/proc/task_nommu.c
59784 +++ b/fs/proc/task_nommu.c
59785 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
59786 else
59787 bytes += kobjsize(mm);
59788
59789 - if (current->fs && current->fs->users > 1)
59790 + if (current->fs && atomic_read(&current->fs->users) > 1)
59791 sbytes += kobjsize(current->fs);
59792 else
59793 bytes += kobjsize(current->fs);
59794 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
59795
59796 if (file) {
59797 pad_len_spaces(m, len);
59798 - seq_path(m, &file->f_path, "");
59799 + seq_path(m, &file->f_path, "\n\\");
59800 } else if (mm) {
59801 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
59802
59803 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
59804 index a1a16eb..6be46ed 100644
59805 --- a/fs/proc/vmcore.c
59806 +++ b/fs/proc/vmcore.c
59807 @@ -104,9 +104,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
59808 nr_bytes = count;
59809
59810 /* If pfn is not ram, return zeros for sparse dump files */
59811 - if (pfn_is_ram(pfn) == 0)
59812 - memset(buf, 0, nr_bytes);
59813 - else {
59814 + if (pfn_is_ram(pfn) == 0) {
59815 + if (userbuf) {
59816 + if (clear_user((char __force_user *)buf, nr_bytes))
59817 + return -EFAULT;
59818 + } else
59819 + memset(buf, 0, nr_bytes);
59820 + } else {
59821 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
59822 offset, userbuf);
59823 if (tmp < 0)
59824 @@ -178,7 +182,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
59825 if (*fpos < m->offset + m->size) {
59826 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
59827 start = m->paddr + *fpos - m->offset;
59828 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
59829 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
59830 if (tmp < 0)
59831 return tmp;
59832 buflen -= tsz;
59833 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
59834 index b00fcc9..e0c6381 100644
59835 --- a/fs/qnx6/qnx6.h
59836 +++ b/fs/qnx6/qnx6.h
59837 @@ -74,7 +74,7 @@ enum {
59838 BYTESEX_BE,
59839 };
59840
59841 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
59842 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
59843 {
59844 if (sbi->s_bytesex == BYTESEX_LE)
59845 return le64_to_cpu((__force __le64)n);
59846 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
59847 return (__force __fs64)cpu_to_be64(n);
59848 }
59849
59850 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
59851 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
59852 {
59853 if (sbi->s_bytesex == BYTESEX_LE)
59854 return le32_to_cpu((__force __le32)n);
59855 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
59856 index 16e8abb..2dcf914 100644
59857 --- a/fs/quota/netlink.c
59858 +++ b/fs/quota/netlink.c
59859 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
59860 void quota_send_warning(struct kqid qid, dev_t dev,
59861 const char warntype)
59862 {
59863 - static atomic_t seq;
59864 + static atomic_unchecked_t seq;
59865 struct sk_buff *skb;
59866 void *msg_head;
59867 int ret;
59868 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
59869 "VFS: Not enough memory to send quota warning.\n");
59870 return;
59871 }
59872 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
59873 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
59874 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
59875 if (!msg_head) {
59876 printk(KERN_ERR
59877 diff --git a/fs/read_write.c b/fs/read_write.c
59878 index 122a384..0b7ecf2 100644
59879 --- a/fs/read_write.c
59880 +++ b/fs/read_write.c
59881 @@ -440,7 +440,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
59882
59883 old_fs = get_fs();
59884 set_fs(get_ds());
59885 - p = (__force const char __user *)buf;
59886 + p = (const char __force_user *)buf;
59887 if (count > MAX_RW_COUNT)
59888 count = MAX_RW_COUNT;
59889 if (file->f_op->write)
59890 diff --git a/fs/readdir.c b/fs/readdir.c
59891 index 93d71e5..6a14be8 100644
59892 --- a/fs/readdir.c
59893 +++ b/fs/readdir.c
59894 @@ -17,6 +17,7 @@
59895 #include <linux/security.h>
59896 #include <linux/syscalls.h>
59897 #include <linux/unistd.h>
59898 +#include <linux/namei.h>
59899
59900 #include <asm/uaccess.h>
59901
59902 @@ -69,6 +70,7 @@ struct old_linux_dirent {
59903 struct readdir_callback {
59904 struct dir_context ctx;
59905 struct old_linux_dirent __user * dirent;
59906 + struct file * file;
59907 int result;
59908 };
59909
59910 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
59911 buf->result = -EOVERFLOW;
59912 return -EOVERFLOW;
59913 }
59914 +
59915 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
59916 + return 0;
59917 +
59918 buf->result++;
59919 dirent = buf->dirent;
59920 if (!access_ok(VERIFY_WRITE, dirent,
59921 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
59922 if (!f.file)
59923 return -EBADF;
59924
59925 + buf.file = f.file;
59926 error = iterate_dir(f.file, &buf.ctx);
59927 if (buf.result)
59928 error = buf.result;
59929 @@ -142,6 +149,7 @@ struct getdents_callback {
59930 struct dir_context ctx;
59931 struct linux_dirent __user * current_dir;
59932 struct linux_dirent __user * previous;
59933 + struct file * file;
59934 int count;
59935 int error;
59936 };
59937 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
59938 buf->error = -EOVERFLOW;
59939 return -EOVERFLOW;
59940 }
59941 +
59942 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
59943 + return 0;
59944 +
59945 dirent = buf->previous;
59946 if (dirent) {
59947 if (__put_user(offset, &dirent->d_off))
59948 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
59949 if (!f.file)
59950 return -EBADF;
59951
59952 + buf.file = f.file;
59953 error = iterate_dir(f.file, &buf.ctx);
59954 if (error >= 0)
59955 error = buf.error;
59956 @@ -226,6 +239,7 @@ struct getdents_callback64 {
59957 struct dir_context ctx;
59958 struct linux_dirent64 __user * current_dir;
59959 struct linux_dirent64 __user * previous;
59960 + struct file *file;
59961 int count;
59962 int error;
59963 };
59964 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
59965 buf->error = -EINVAL; /* only used if we fail.. */
59966 if (reclen > buf->count)
59967 return -EINVAL;
59968 +
59969 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
59970 + return 0;
59971 +
59972 dirent = buf->previous;
59973 if (dirent) {
59974 if (__put_user(offset, &dirent->d_off))
59975 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
59976 if (!f.file)
59977 return -EBADF;
59978
59979 + buf.file = f.file;
59980 error = iterate_dir(f.file, &buf.ctx);
59981 if (error >= 0)
59982 error = buf.error;
59983 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
59984 index 2b7882b..1c5ef48 100644
59985 --- a/fs/reiserfs/do_balan.c
59986 +++ b/fs/reiserfs/do_balan.c
59987 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
59988 return;
59989 }
59990
59991 - atomic_inc(&(fs_generation(tb->tb_sb)));
59992 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
59993 do_balance_starts(tb);
59994
59995 /* balance leaf returns 0 except if combining L R and S into
59996 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
59997 index a958444..42b2323 100644
59998 --- a/fs/reiserfs/procfs.c
59999 +++ b/fs/reiserfs/procfs.c
60000 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60001 "SMALL_TAILS " : "NO_TAILS ",
60002 replay_only(sb) ? "REPLAY_ONLY " : "",
60003 convert_reiserfs(sb) ? "CONV " : "",
60004 - atomic_read(&r->s_generation_counter),
60005 + atomic_read_unchecked(&r->s_generation_counter),
60006 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60007 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60008 SF(s_good_search_by_key_reada), SF(s_bmaps),
60009 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60010 index 3df5ce6..8c0f4b0 100644
60011 --- a/fs/reiserfs/reiserfs.h
60012 +++ b/fs/reiserfs/reiserfs.h
60013 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60014 /* Comment? -Hans */
60015 wait_queue_head_t s_wait;
60016 /* To be obsoleted soon by per buffer seals.. -Hans */
60017 - atomic_t s_generation_counter; // increased by one every time the
60018 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60019 // tree gets re-balanced
60020 unsigned long s_properties; /* File system properties. Currently holds
60021 on-disk FS format */
60022 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60023 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60024
60025 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60026 -#define get_generation(s) atomic_read (&fs_generation(s))
60027 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60028 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60029 #define __fs_changed(gen,s) (gen != get_generation (s))
60030 #define fs_changed(gen,s) \
60031 diff --git a/fs/select.c b/fs/select.c
60032 index 35d4adc7..d6c60db 100644
60033 --- a/fs/select.c
60034 +++ b/fs/select.c
60035 @@ -20,6 +20,7 @@
60036 #include <linux/export.h>
60037 #include <linux/slab.h>
60038 #include <linux/poll.h>
60039 +#include <linux/security.h>
60040 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60041 #include <linux/file.h>
60042 #include <linux/fdtable.h>
60043 @@ -881,6 +882,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60044 struct poll_list *walk = head;
60045 unsigned long todo = nfds;
60046
60047 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60048 if (nfds > rlimit(RLIMIT_NOFILE))
60049 return -EINVAL;
60050
60051 diff --git a/fs/seq_file.c b/fs/seq_file.c
60052 index 3135c25..d0395dd 100644
60053 --- a/fs/seq_file.c
60054 +++ b/fs/seq_file.c
60055 @@ -10,6 +10,7 @@
60056 #include <linux/seq_file.h>
60057 #include <linux/slab.h>
60058 #include <linux/cred.h>
60059 +#include <linux/sched.h>
60060
60061 #include <asm/uaccess.h>
60062 #include <asm/page.h>
60063 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60064 #ifdef CONFIG_USER_NS
60065 p->user_ns = file->f_cred->user_ns;
60066 #endif
60067 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60068 + p->exec_id = current->exec_id;
60069 +#endif
60070
60071 /*
60072 * Wrappers around seq_open(e.g. swaps_open) need to be
60073 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60074 return 0;
60075 }
60076 if (!m->buf) {
60077 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60078 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60079 if (!m->buf)
60080 return -ENOMEM;
60081 }
60082 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60083 Eoverflow:
60084 m->op->stop(m, p);
60085 kfree(m->buf);
60086 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60087 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60088 return !m->buf ? -ENOMEM : -EAGAIN;
60089 }
60090
60091 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60092
60093 /* grab buffer if we didn't have one */
60094 if (!m->buf) {
60095 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60096 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60097 if (!m->buf)
60098 goto Enomem;
60099 }
60100 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60101 goto Fill;
60102 m->op->stop(m, p);
60103 kfree(m->buf);
60104 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60105 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60106 if (!m->buf)
60107 goto Enomem;
60108 m->count = 0;
60109 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
60110 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
60111 void *data)
60112 {
60113 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
60114 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
60115 int res = -ENOMEM;
60116
60117 if (op) {
60118 diff --git a/fs/splice.c b/fs/splice.c
60119 index 3b7ee65..87fc2e4 100644
60120 --- a/fs/splice.c
60121 +++ b/fs/splice.c
60122 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60123 pipe_lock(pipe);
60124
60125 for (;;) {
60126 - if (!pipe->readers) {
60127 + if (!atomic_read(&pipe->readers)) {
60128 send_sig(SIGPIPE, current, 0);
60129 if (!ret)
60130 ret = -EPIPE;
60131 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60132 page_nr++;
60133 ret += buf->len;
60134
60135 - if (pipe->files)
60136 + if (atomic_read(&pipe->files))
60137 do_wakeup = 1;
60138
60139 if (!--spd->nr_pages)
60140 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60141 do_wakeup = 0;
60142 }
60143
60144 - pipe->waiting_writers++;
60145 + atomic_inc(&pipe->waiting_writers);
60146 pipe_wait(pipe);
60147 - pipe->waiting_writers--;
60148 + atomic_dec(&pipe->waiting_writers);
60149 }
60150
60151 pipe_unlock(pipe);
60152 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
60153 old_fs = get_fs();
60154 set_fs(get_ds());
60155 /* The cast to a user pointer is valid due to the set_fs() */
60156 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
60157 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
60158 set_fs(old_fs);
60159
60160 return res;
60161 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
60162 old_fs = get_fs();
60163 set_fs(get_ds());
60164 /* The cast to a user pointer is valid due to the set_fs() */
60165 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
60166 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
60167 set_fs(old_fs);
60168
60169 return res;
60170 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
60171 goto err;
60172
60173 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
60174 - vec[i].iov_base = (void __user *) page_address(page);
60175 + vec[i].iov_base = (void __force_user *) page_address(page);
60176 vec[i].iov_len = this_len;
60177 spd.pages[i] = page;
60178 spd.nr_pages++;
60179 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
60180 ops->release(pipe, buf);
60181 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
60182 pipe->nrbufs--;
60183 - if (pipe->files)
60184 + if (atomic_read(&pipe->files))
60185 sd->need_wakeup = true;
60186 }
60187
60188 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
60189 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
60190 {
60191 while (!pipe->nrbufs) {
60192 - if (!pipe->writers)
60193 + if (!atomic_read(&pipe->writers))
60194 return 0;
60195
60196 - if (!pipe->waiting_writers && sd->num_spliced)
60197 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
60198 return 0;
60199
60200 if (sd->flags & SPLICE_F_NONBLOCK)
60201 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
60202 * out of the pipe right after the splice_to_pipe(). So set
60203 * PIPE_READERS appropriately.
60204 */
60205 - pipe->readers = 1;
60206 + atomic_set(&pipe->readers, 1);
60207
60208 current->splice_pipe = pipe;
60209 }
60210 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
60211
60212 partial[buffers].offset = off;
60213 partial[buffers].len = plen;
60214 + partial[buffers].private = 0;
60215
60216 off = 0;
60217 len -= plen;
60218 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60219 ret = -ERESTARTSYS;
60220 break;
60221 }
60222 - if (!pipe->writers)
60223 + if (!atomic_read(&pipe->writers))
60224 break;
60225 - if (!pipe->waiting_writers) {
60226 + if (!atomic_read(&pipe->waiting_writers)) {
60227 if (flags & SPLICE_F_NONBLOCK) {
60228 ret = -EAGAIN;
60229 break;
60230 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60231 pipe_lock(pipe);
60232
60233 while (pipe->nrbufs >= pipe->buffers) {
60234 - if (!pipe->readers) {
60235 + if (!atomic_read(&pipe->readers)) {
60236 send_sig(SIGPIPE, current, 0);
60237 ret = -EPIPE;
60238 break;
60239 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60240 ret = -ERESTARTSYS;
60241 break;
60242 }
60243 - pipe->waiting_writers++;
60244 + atomic_inc(&pipe->waiting_writers);
60245 pipe_wait(pipe);
60246 - pipe->waiting_writers--;
60247 + atomic_dec(&pipe->waiting_writers);
60248 }
60249
60250 pipe_unlock(pipe);
60251 @@ -1862,14 +1863,14 @@ retry:
60252 pipe_double_lock(ipipe, opipe);
60253
60254 do {
60255 - if (!opipe->readers) {
60256 + if (!atomic_read(&opipe->readers)) {
60257 send_sig(SIGPIPE, current, 0);
60258 if (!ret)
60259 ret = -EPIPE;
60260 break;
60261 }
60262
60263 - if (!ipipe->nrbufs && !ipipe->writers)
60264 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
60265 break;
60266
60267 /*
60268 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60269 pipe_double_lock(ipipe, opipe);
60270
60271 do {
60272 - if (!opipe->readers) {
60273 + if (!atomic_read(&opipe->readers)) {
60274 send_sig(SIGPIPE, current, 0);
60275 if (!ret)
60276 ret = -EPIPE;
60277 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60278 * return EAGAIN if we have the potential of some data in the
60279 * future, otherwise just return 0
60280 */
60281 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
60282 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
60283 ret = -EAGAIN;
60284
60285 pipe_unlock(ipipe);
60286 diff --git a/fs/stat.c b/fs/stat.c
60287 index 04ce1ac..a13dd1e 100644
60288 --- a/fs/stat.c
60289 +++ b/fs/stat.c
60290 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
60291 stat->gid = inode->i_gid;
60292 stat->rdev = inode->i_rdev;
60293 stat->size = i_size_read(inode);
60294 - stat->atime = inode->i_atime;
60295 - stat->mtime = inode->i_mtime;
60296 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60297 + stat->atime = inode->i_ctime;
60298 + stat->mtime = inode->i_ctime;
60299 + } else {
60300 + stat->atime = inode->i_atime;
60301 + stat->mtime = inode->i_mtime;
60302 + }
60303 stat->ctime = inode->i_ctime;
60304 stat->blksize = (1 << inode->i_blkbits);
60305 stat->blocks = inode->i_blocks;
60306 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
60307 if (retval)
60308 return retval;
60309
60310 - if (inode->i_op->getattr)
60311 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
60312 + if (inode->i_op->getattr) {
60313 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
60314 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60315 + stat->atime = stat->ctime;
60316 + stat->mtime = stat->ctime;
60317 + }
60318 + return retval;
60319 + }
60320
60321 generic_fillattr(inode, stat);
60322 return 0;
60323 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
60324 index 15c68f9..36a8b3e 100644
60325 --- a/fs/sysfs/bin.c
60326 +++ b/fs/sysfs/bin.c
60327 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
60328 return ret;
60329 }
60330
60331 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
60332 - void *buf, int len, int write)
60333 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
60334 + void *buf, size_t len, int write)
60335 {
60336 struct file *file = vma->vm_file;
60337 struct bin_buffer *bb = file->private_data;
60338 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
60339 - int ret;
60340 + ssize_t ret;
60341
60342 if (!bb->vm_ops)
60343 return -EINVAL;
60344 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
60345 index e068e74..92edeb8 100644
60346 --- a/fs/sysfs/dir.c
60347 +++ b/fs/sysfs/dir.c
60348 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
60349 *
60350 * Returns 31 bit hash of ns + name (so it fits in an off_t )
60351 */
60352 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
60353 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
60354 {
60355 unsigned long hash = init_name_hash();
60356 unsigned int len = strlen(name);
60357 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
60358 struct sysfs_dirent *sd;
60359 int rc;
60360
60361 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
60362 + const char *parent_name = parent_sd->s_name;
60363 +
60364 + mode = S_IFDIR | S_IRWXU;
60365 +
60366 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
60367 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
60368 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
60369 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
60370 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
60371 +#endif
60372 +
60373 /* allocate */
60374 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
60375 if (!sd)
60376 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
60377 index d2bb7ed..fe8c331 100644
60378 --- a/fs/sysfs/file.c
60379 +++ b/fs/sysfs/file.c
60380 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
60381
60382 struct sysfs_open_dirent {
60383 atomic_t refcnt;
60384 - atomic_t event;
60385 + atomic_unchecked_t event;
60386 wait_queue_head_t poll;
60387 struct list_head buffers; /* goes through sysfs_buffer.list */
60388 };
60389 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
60390 if (!sysfs_get_active(attr_sd))
60391 return -ENODEV;
60392
60393 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
60394 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
60395 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
60396
60397 sysfs_put_active(attr_sd);
60398 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
60399 return -ENOMEM;
60400
60401 atomic_set(&new_od->refcnt, 0);
60402 - atomic_set(&new_od->event, 1);
60403 + atomic_set_unchecked(&new_od->event, 1);
60404 init_waitqueue_head(&new_od->poll);
60405 INIT_LIST_HEAD(&new_od->buffers);
60406 goto retry;
60407 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
60408
60409 sysfs_put_active(attr_sd);
60410
60411 - if (buffer->event != atomic_read(&od->event))
60412 + if (buffer->event != atomic_read_unchecked(&od->event))
60413 goto trigger;
60414
60415 return DEFAULT_POLLMASK;
60416 @@ -452,7 +452,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
60417 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
60418 od = sd->s_attr.open;
60419 if (od) {
60420 - atomic_inc(&od->event);
60421 + atomic_inc_unchecked(&od->event);
60422 wake_up_interruptible(&od->poll);
60423 }
60424 }
60425 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
60426 index 8c940df..25b733e 100644
60427 --- a/fs/sysfs/symlink.c
60428 +++ b/fs/sysfs/symlink.c
60429 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
60430
60431 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
60432 {
60433 - char *page = nd_get_link(nd);
60434 + const char *page = nd_get_link(nd);
60435 if (!IS_ERR(page))
60436 free_page((unsigned long)page);
60437 }
60438 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
60439 index 69d4889..a810bd4 100644
60440 --- a/fs/sysv/sysv.h
60441 +++ b/fs/sysv/sysv.h
60442 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
60443 #endif
60444 }
60445
60446 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60447 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60448 {
60449 if (sbi->s_bytesex == BYTESEX_PDP)
60450 return PDP_swab((__force __u32)n);
60451 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
60452 index e18b988..f1d4ad0f 100644
60453 --- a/fs/ubifs/io.c
60454 +++ b/fs/ubifs/io.c
60455 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
60456 return err;
60457 }
60458
60459 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60460 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60461 {
60462 int err;
60463
60464 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
60465 index c175b4d..8f36a16 100644
60466 --- a/fs/udf/misc.c
60467 +++ b/fs/udf/misc.c
60468 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
60469
60470 u8 udf_tag_checksum(const struct tag *t)
60471 {
60472 - u8 *data = (u8 *)t;
60473 + const u8 *data = (const u8 *)t;
60474 u8 checksum = 0;
60475 int i;
60476 for (i = 0; i < sizeof(struct tag); ++i)
60477 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
60478 index 8d974c4..b82f6ec 100644
60479 --- a/fs/ufs/swab.h
60480 +++ b/fs/ufs/swab.h
60481 @@ -22,7 +22,7 @@ enum {
60482 BYTESEX_BE
60483 };
60484
60485 -static inline u64
60486 +static inline u64 __intentional_overflow(-1)
60487 fs64_to_cpu(struct super_block *sbp, __fs64 n)
60488 {
60489 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60490 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
60491 return (__force __fs64)cpu_to_be64(n);
60492 }
60493
60494 -static inline u32
60495 +static inline u32 __intentional_overflow(-1)
60496 fs32_to_cpu(struct super_block *sbp, __fs32 n)
60497 {
60498 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
60499 diff --git a/fs/utimes.c b/fs/utimes.c
60500 index f4fb7ec..3fe03c0 100644
60501 --- a/fs/utimes.c
60502 +++ b/fs/utimes.c
60503 @@ -1,6 +1,7 @@
60504 #include <linux/compiler.h>
60505 #include <linux/file.h>
60506 #include <linux/fs.h>
60507 +#include <linux/security.h>
60508 #include <linux/linkage.h>
60509 #include <linux/mount.h>
60510 #include <linux/namei.h>
60511 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
60512 goto mnt_drop_write_and_out;
60513 }
60514 }
60515 +
60516 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
60517 + error = -EACCES;
60518 + goto mnt_drop_write_and_out;
60519 + }
60520 +
60521 mutex_lock(&inode->i_mutex);
60522 error = notify_change(path->dentry, &newattrs);
60523 mutex_unlock(&inode->i_mutex);
60524 diff --git a/fs/xattr.c b/fs/xattr.c
60525 index 3377dff..4d074d9 100644
60526 --- a/fs/xattr.c
60527 +++ b/fs/xattr.c
60528 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
60529 return rc;
60530 }
60531
60532 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
60533 +ssize_t
60534 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
60535 +{
60536 + struct inode *inode = dentry->d_inode;
60537 + ssize_t error;
60538 +
60539 + error = inode_permission(inode, MAY_EXEC);
60540 + if (error)
60541 + return error;
60542 +
60543 + if (inode->i_op->getxattr)
60544 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
60545 + else
60546 + error = -EOPNOTSUPP;
60547 +
60548 + return error;
60549 +}
60550 +EXPORT_SYMBOL(pax_getxattr);
60551 +#endif
60552 +
60553 ssize_t
60554 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
60555 {
60556 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
60557 * Extended attribute SET operations
60558 */
60559 static long
60560 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
60561 +setxattr(struct path *path, const char __user *name, const void __user *value,
60562 size_t size, int flags)
60563 {
60564 int error;
60565 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
60566 posix_acl_fix_xattr_from_user(kvalue, size);
60567 }
60568
60569 - error = vfs_setxattr(d, kname, kvalue, size, flags);
60570 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
60571 + error = -EACCES;
60572 + goto out;
60573 + }
60574 +
60575 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
60576 out:
60577 if (vvalue)
60578 vfree(vvalue);
60579 @@ -377,7 +403,7 @@ retry:
60580 return error;
60581 error = mnt_want_write(path.mnt);
60582 if (!error) {
60583 - error = setxattr(path.dentry, name, value, size, flags);
60584 + error = setxattr(&path, name, value, size, flags);
60585 mnt_drop_write(path.mnt);
60586 }
60587 path_put(&path);
60588 @@ -401,7 +427,7 @@ retry:
60589 return error;
60590 error = mnt_want_write(path.mnt);
60591 if (!error) {
60592 - error = setxattr(path.dentry, name, value, size, flags);
60593 + error = setxattr(&path, name, value, size, flags);
60594 mnt_drop_write(path.mnt);
60595 }
60596 path_put(&path);
60597 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
60598 const void __user *,value, size_t, size, int, flags)
60599 {
60600 struct fd f = fdget(fd);
60601 - struct dentry *dentry;
60602 int error = -EBADF;
60603
60604 if (!f.file)
60605 return error;
60606 - dentry = f.file->f_path.dentry;
60607 - audit_inode(NULL, dentry, 0);
60608 + audit_inode(NULL, f.file->f_path.dentry, 0);
60609 error = mnt_want_write_file(f.file);
60610 if (!error) {
60611 - error = setxattr(dentry, name, value, size, flags);
60612 + error = setxattr(&f.file->f_path, name, value, size, flags);
60613 mnt_drop_write_file(f.file);
60614 }
60615 fdput(f);
60616 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
60617 index 9fbea87..6b19972 100644
60618 --- a/fs/xattr_acl.c
60619 +++ b/fs/xattr_acl.c
60620 @@ -76,8 +76,8 @@ struct posix_acl *
60621 posix_acl_from_xattr(struct user_namespace *user_ns,
60622 const void *value, size_t size)
60623 {
60624 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
60625 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
60626 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
60627 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
60628 int count;
60629 struct posix_acl *acl;
60630 struct posix_acl_entry *acl_e;
60631 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
60632 index 05c698c..6b918af 100644
60633 --- a/fs/xfs/xfs_bmap.c
60634 +++ b/fs/xfs/xfs_bmap.c
60635 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
60636
60637 #else
60638 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
60639 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
60640 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
60641 #endif /* DEBUG */
60642
60643 /*
60644 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
60645 index 97676a3..399a75d 100644
60646 --- a/fs/xfs/xfs_dir2_sf.c
60647 +++ b/fs/xfs/xfs_dir2_sf.c
60648 @@ -848,7 +848,12 @@ xfs_dir2_sf_getdents(
60649
60650 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
60651 ctx->pos = off & 0x7fffffff;
60652 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
60653 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
60654 + char name[sfep->namelen];
60655 + memcpy(name, sfep->name, sfep->namelen);
60656 + if (!dir_emit(ctx, name, sfep->namelen, ino, DT_UNKNOWN))
60657 + return 0;
60658 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
60659 ino, DT_UNKNOWN))
60660 return 0;
60661 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
60662 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
60663 index 6e2bca5..6ce80d3 100644
60664 --- a/fs/xfs/xfs_ioctl.c
60665 +++ b/fs/xfs/xfs_ioctl.c
60666 @@ -127,7 +127,7 @@ xfs_find_handle(
60667 }
60668
60669 error = -EFAULT;
60670 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
60671 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
60672 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
60673 goto out_put;
60674
60675 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
60676 index 96dda62..d6c6a52 100644
60677 --- a/fs/xfs/xfs_iops.c
60678 +++ b/fs/xfs/xfs_iops.c
60679 @@ -395,7 +395,7 @@ xfs_vn_put_link(
60680 struct nameidata *nd,
60681 void *p)
60682 {
60683 - char *s = nd_get_link(nd);
60684 + const char *s = nd_get_link(nd);
60685
60686 if (!IS_ERR(s))
60687 kfree(s);
60688 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
60689 new file mode 100644
60690 index 0000000..0fd7c82
60691 --- /dev/null
60692 +++ b/grsecurity/Kconfig
60693 @@ -0,0 +1,1080 @@
60694 +#
60695 +# grecurity configuration
60696 +#
60697 +menu "Memory Protections"
60698 +depends on GRKERNSEC
60699 +
60700 +config GRKERNSEC_KMEM
60701 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
60702 + default y if GRKERNSEC_CONFIG_AUTO
60703 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
60704 + help
60705 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
60706 + be written to or read from to modify or leak the contents of the running
60707 + kernel. /dev/port will also not be allowed to be opened and support
60708 + for /dev/cpu/*/msr will be removed. If you have module
60709 + support disabled, enabling this will close up five ways that are
60710 + currently used to insert malicious code into the running kernel.
60711 +
60712 + Even with all these features enabled, we still highly recommend that
60713 + you use the RBAC system, as it is still possible for an attacker to
60714 + modify the running kernel through privileged I/O granted by ioperm/iopl.
60715 +
60716 + If you are not using XFree86, you may be able to stop this additional
60717 + case by enabling the 'Disable privileged I/O' option. Though nothing
60718 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
60719 + but only to video memory, which is the only writing we allow in this
60720 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
60721 + not be allowed to mprotect it with PROT_WRITE later.
60722 + Enabling this feature will prevent the "cpupower" and "powertop" tools
60723 + from working.
60724 +
60725 + It is highly recommended that you say Y here if you meet all the
60726 + conditions above.
60727 +
60728 +config GRKERNSEC_VM86
60729 + bool "Restrict VM86 mode"
60730 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
60731 + depends on X86_32
60732 +
60733 + help
60734 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
60735 + make use of a special execution mode on 32bit x86 processors called
60736 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
60737 + video cards and will still work with this option enabled. The purpose
60738 + of the option is to prevent exploitation of emulation errors in
60739 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
60740 + Nearly all users should be able to enable this option.
60741 +
60742 +config GRKERNSEC_IO
60743 + bool "Disable privileged I/O"
60744 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
60745 + depends on X86
60746 + select RTC_CLASS
60747 + select RTC_INTF_DEV
60748 + select RTC_DRV_CMOS
60749 +
60750 + help
60751 + If you say Y here, all ioperm and iopl calls will return an error.
60752 + Ioperm and iopl can be used to modify the running kernel.
60753 + Unfortunately, some programs need this access to operate properly,
60754 + the most notable of which are XFree86 and hwclock. hwclock can be
60755 + remedied by having RTC support in the kernel, so real-time
60756 + clock support is enabled if this option is enabled, to ensure
60757 + that hwclock operates correctly. XFree86 still will not
60758 + operate correctly with this option enabled, so DO NOT CHOOSE Y
60759 + IF YOU USE XFree86. If you use XFree86 and you still want to
60760 + protect your kernel against modification, use the RBAC system.
60761 +
60762 +config GRKERNSEC_JIT_HARDEN
60763 + bool "Harden BPF JIT against spray attacks"
60764 + default y if GRKERNSEC_CONFIG_AUTO
60765 + depends on BPF_JIT
60766 + help
60767 + If you say Y here, the native code generated by the kernel's Berkeley
60768 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
60769 + attacks that attempt to fit attacker-beneficial instructions in
60770 + 32bit immediate fields of JIT-generated native instructions. The
60771 + attacker will generally aim to cause an unintended instruction sequence
60772 + of JIT-generated native code to execute by jumping into the middle of
60773 + a generated instruction. This feature effectively randomizes the 32bit
60774 + immediate constants present in the generated code to thwart such attacks.
60775 +
60776 + If you're using KERNEXEC, it's recommended that you enable this option
60777 + to supplement the hardening of the kernel.
60778 +
60779 +config GRKERNSEC_PERF_HARDEN
60780 + bool "Disable unprivileged PERF_EVENTS usage by default"
60781 + default y if GRKERNSEC_CONFIG_AUTO
60782 + depends on PERF_EVENTS
60783 + help
60784 + If you say Y here, the range of acceptable values for the
60785 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
60786 + default to a new value: 3. When the sysctl is set to this value, no
60787 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
60788 +
60789 + Though PERF_EVENTS can be used legitimately for performance monitoring
60790 + and low-level application profiling, it is forced on regardless of
60791 + configuration, has been at fault for several vulnerabilities, and
60792 + creates new opportunities for side channels and other information leaks.
60793 +
60794 + This feature puts PERF_EVENTS into a secure default state and permits
60795 + the administrator to change out of it temporarily if unprivileged
60796 + application profiling is needed.
60797 +
60798 +config GRKERNSEC_RAND_THREADSTACK
60799 + bool "Insert random gaps between thread stacks"
60800 + default y if GRKERNSEC_CONFIG_AUTO
60801 + depends on PAX_RANDMMAP && !PPC
60802 + help
60803 + If you say Y here, a random-sized gap will be enforced between allocated
60804 + thread stacks. Glibc's NPTL and other threading libraries that
60805 + pass MAP_STACK to the kernel for thread stack allocation are supported.
60806 + The implementation currently provides 8 bits of entropy for the gap.
60807 +
60808 + Many distributions do not compile threaded remote services with the
60809 + -fstack-check argument to GCC, causing the variable-sized stack-based
60810 + allocator, alloca(), to not probe the stack on allocation. This
60811 + permits an unbounded alloca() to skip over any guard page and potentially
60812 + modify another thread's stack reliably. An enforced random gap
60813 + reduces the reliability of such an attack and increases the chance
60814 + that such a read/write to another thread's stack instead lands in
60815 + an unmapped area, causing a crash and triggering grsecurity's
60816 + anti-bruteforcing logic.
60817 +
60818 +config GRKERNSEC_PROC_MEMMAP
60819 + bool "Harden ASLR against information leaks and entropy reduction"
60820 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
60821 + depends on PAX_NOEXEC || PAX_ASLR
60822 + help
60823 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
60824 + give no information about the addresses of its mappings if
60825 + PaX features that rely on random addresses are enabled on the task.
60826 + In addition to sanitizing this information and disabling other
60827 + dangerous sources of information, this option causes reads of sensitive
60828 + /proc/<pid> entries where the file descriptor was opened in a different
60829 + task than the one performing the read. Such attempts are logged.
60830 + This option also limits argv/env strings for suid/sgid binaries
60831 + to 512KB to prevent a complete exhaustion of the stack entropy provided
60832 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
60833 + binaries to prevent alternative mmap layouts from being abused.
60834 +
60835 + If you use PaX it is essential that you say Y here as it closes up
60836 + several holes that make full ASLR useless locally.
60837 +
60838 +config GRKERNSEC_BRUTE
60839 + bool "Deter exploit bruteforcing"
60840 + default y if GRKERNSEC_CONFIG_AUTO
60841 + help
60842 + If you say Y here, attempts to bruteforce exploits against forking
60843 + daemons such as apache or sshd, as well as against suid/sgid binaries
60844 + will be deterred. When a child of a forking daemon is killed by PaX
60845 + or crashes due to an illegal instruction or other suspicious signal,
60846 + the parent process will be delayed 30 seconds upon every subsequent
60847 + fork until the administrator is able to assess the situation and
60848 + restart the daemon.
60849 + In the suid/sgid case, the attempt is logged, the user has all their
60850 + existing instances of the suid/sgid binary terminated and will
60851 + be unable to execute any suid/sgid binaries for 15 minutes.
60852 +
60853 + It is recommended that you also enable signal logging in the auditing
60854 + section so that logs are generated when a process triggers a suspicious
60855 + signal.
60856 + If the sysctl option is enabled, a sysctl option with name
60857 + "deter_bruteforce" is created.
60858 +
60859 +
60860 +config GRKERNSEC_MODHARDEN
60861 + bool "Harden module auto-loading"
60862 + default y if GRKERNSEC_CONFIG_AUTO
60863 + depends on MODULES
60864 + help
60865 + If you say Y here, module auto-loading in response to use of some
60866 + feature implemented by an unloaded module will be restricted to
60867 + root users. Enabling this option helps defend against attacks
60868 + by unprivileged users who abuse the auto-loading behavior to
60869 + cause a vulnerable module to load that is then exploited.
60870 +
60871 + If this option prevents a legitimate use of auto-loading for a
60872 + non-root user, the administrator can execute modprobe manually
60873 + with the exact name of the module mentioned in the alert log.
60874 + Alternatively, the administrator can add the module to the list
60875 + of modules loaded at boot by modifying init scripts.
60876 +
60877 + Modification of init scripts will most likely be needed on
60878 + Ubuntu servers with encrypted home directory support enabled,
60879 + as the first non-root user logging in will cause the ecb(aes),
60880 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
60881 +
60882 +config GRKERNSEC_HIDESYM
60883 + bool "Hide kernel symbols"
60884 + default y if GRKERNSEC_CONFIG_AUTO
60885 + select PAX_USERCOPY_SLABS
60886 + help
60887 + If you say Y here, getting information on loaded modules, and
60888 + displaying all kernel symbols through a syscall will be restricted
60889 + to users with CAP_SYS_MODULE. For software compatibility reasons,
60890 + /proc/kallsyms will be restricted to the root user. The RBAC
60891 + system can hide that entry even from root.
60892 +
60893 + This option also prevents leaking of kernel addresses through
60894 + several /proc entries.
60895 +
60896 + Note that this option is only effective provided the following
60897 + conditions are met:
60898 + 1) The kernel using grsecurity is not precompiled by some distribution
60899 + 2) You have also enabled GRKERNSEC_DMESG
60900 + 3) You are using the RBAC system and hiding other files such as your
60901 + kernel image and System.map. Alternatively, enabling this option
60902 + causes the permissions on /boot, /lib/modules, and the kernel
60903 + source directory to change at compile time to prevent
60904 + reading by non-root users.
60905 + If the above conditions are met, this option will aid in providing a
60906 + useful protection against local kernel exploitation of overflows
60907 + and arbitrary read/write vulnerabilities.
60908 +
60909 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
60910 + in addition to this feature.
60911 +
60912 +config GRKERNSEC_KERN_LOCKOUT
60913 + bool "Active kernel exploit response"
60914 + default y if GRKERNSEC_CONFIG_AUTO
60915 + depends on X86 || ARM || PPC || SPARC
60916 + help
60917 + If you say Y here, when a PaX alert is triggered due to suspicious
60918 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
60919 + or an OOPS occurs due to bad memory accesses, instead of just
60920 + terminating the offending process (and potentially allowing
60921 + a subsequent exploit from the same user), we will take one of two
60922 + actions:
60923 + If the user was root, we will panic the system
60924 + If the user was non-root, we will log the attempt, terminate
60925 + all processes owned by the user, then prevent them from creating
60926 + any new processes until the system is restarted
60927 + This deters repeated kernel exploitation/bruteforcing attempts
60928 + and is useful for later forensics.
60929 +
60930 +endmenu
60931 +menu "Role Based Access Control Options"
60932 +depends on GRKERNSEC
60933 +
60934 +config GRKERNSEC_RBAC_DEBUG
60935 + bool
60936 +
60937 +config GRKERNSEC_NO_RBAC
60938 + bool "Disable RBAC system"
60939 + help
60940 + If you say Y here, the /dev/grsec device will be removed from the kernel,
60941 + preventing the RBAC system from being enabled. You should only say Y
60942 + here if you have no intention of using the RBAC system, so as to prevent
60943 + an attacker with root access from misusing the RBAC system to hide files
60944 + and processes when loadable module support and /dev/[k]mem have been
60945 + locked down.
60946 +
60947 +config GRKERNSEC_ACL_HIDEKERN
60948 + bool "Hide kernel processes"
60949 + help
60950 + If you say Y here, all kernel threads will be hidden to all
60951 + processes but those whose subject has the "view hidden processes"
60952 + flag.
60953 +
60954 +config GRKERNSEC_ACL_MAXTRIES
60955 + int "Maximum tries before password lockout"
60956 + default 3
60957 + help
60958 + This option enforces the maximum number of times a user can attempt
60959 + to authorize themselves with the grsecurity RBAC system before being
60960 + denied the ability to attempt authorization again for a specified time.
60961 + The lower the number, the harder it will be to brute-force a password.
60962 +
60963 +config GRKERNSEC_ACL_TIMEOUT
60964 + int "Time to wait after max password tries, in seconds"
60965 + default 30
60966 + help
60967 + This option specifies the time the user must wait after attempting to
60968 + authorize to the RBAC system with the maximum number of invalid
60969 + passwords. The higher the number, the harder it will be to brute-force
60970 + a password.
60971 +
60972 +endmenu
60973 +menu "Filesystem Protections"
60974 +depends on GRKERNSEC
60975 +
60976 +config GRKERNSEC_PROC
60977 + bool "Proc restrictions"
60978 + default y if GRKERNSEC_CONFIG_AUTO
60979 + help
60980 + If you say Y here, the permissions of the /proc filesystem
60981 + will be altered to enhance system security and privacy. You MUST
60982 + choose either a user only restriction or a user and group restriction.
60983 + Depending upon the option you choose, you can either restrict users to
60984 + see only the processes they themselves run, or choose a group that can
60985 + view all processes and files normally restricted to root if you choose
60986 + the "restrict to user only" option. NOTE: If you're running identd or
60987 + ntpd as a non-root user, you will have to run it as the group you
60988 + specify here.
60989 +
60990 +config GRKERNSEC_PROC_USER
60991 + bool "Restrict /proc to user only"
60992 + depends on GRKERNSEC_PROC
60993 + help
60994 + If you say Y here, non-root users will only be able to view their own
60995 + processes, and restricts them from viewing network-related information,
60996 + and viewing kernel symbol and module information.
60997 +
60998 +config GRKERNSEC_PROC_USERGROUP
60999 + bool "Allow special group"
61000 + default y if GRKERNSEC_CONFIG_AUTO
61001 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61002 + help
61003 + If you say Y here, you will be able to select a group that will be
61004 + able to view all processes and network-related information. If you've
61005 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61006 + remain hidden. This option is useful if you want to run identd as
61007 + a non-root user. The group you select may also be chosen at boot time
61008 + via "grsec_proc_gid=" on the kernel commandline.
61009 +
61010 +config GRKERNSEC_PROC_GID
61011 + int "GID for special group"
61012 + depends on GRKERNSEC_PROC_USERGROUP
61013 + default 1001
61014 +
61015 +config GRKERNSEC_PROC_ADD
61016 + bool "Additional restrictions"
61017 + default y if GRKERNSEC_CONFIG_AUTO
61018 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61019 + help
61020 + If you say Y here, additional restrictions will be placed on
61021 + /proc that keep normal users from viewing device information and
61022 + slabinfo information that could be useful for exploits.
61023 +
61024 +config GRKERNSEC_LINK
61025 + bool "Linking restrictions"
61026 + default y if GRKERNSEC_CONFIG_AUTO
61027 + help
61028 + If you say Y here, /tmp race exploits will be prevented, since users
61029 + will no longer be able to follow symlinks owned by other users in
61030 + world-writable +t directories (e.g. /tmp), unless the owner of the
61031 + symlink is the owner of the directory. users will also not be
61032 + able to hardlink to files they do not own. If the sysctl option is
61033 + enabled, a sysctl option with name "linking_restrictions" is created.
61034 +
61035 +config GRKERNSEC_SYMLINKOWN
61036 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61037 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61038 + help
61039 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61040 + that prevents it from being used as a security feature. As Apache
61041 + verifies the symlink by performing a stat() against the target of
61042 + the symlink before it is followed, an attacker can setup a symlink
61043 + to point to a same-owned file, then replace the symlink with one
61044 + that targets another user's file just after Apache "validates" the
61045 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61046 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61047 + will be in place for the group you specify. If the sysctl option
61048 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61049 + created.
61050 +
61051 +config GRKERNSEC_SYMLINKOWN_GID
61052 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61053 + depends on GRKERNSEC_SYMLINKOWN
61054 + default 1006
61055 + help
61056 + Setting this GID determines what group kernel-enforced
61057 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61058 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61059 +
61060 +config GRKERNSEC_FIFO
61061 + bool "FIFO restrictions"
61062 + default y if GRKERNSEC_CONFIG_AUTO
61063 + help
61064 + If you say Y here, users will not be able to write to FIFOs they don't
61065 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61066 + the FIFO is the same owner of the directory it's held in. If the sysctl
61067 + option is enabled, a sysctl option with name "fifo_restrictions" is
61068 + created.
61069 +
61070 +config GRKERNSEC_SYSFS_RESTRICT
61071 + bool "Sysfs/debugfs restriction"
61072 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61073 + depends on SYSFS
61074 + help
61075 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61076 + any filesystem normally mounted under it (e.g. debugfs) will be
61077 + mostly accessible only by root. These filesystems generally provide access
61078 + to hardware and debug information that isn't appropriate for unprivileged
61079 + users of the system. Sysfs and debugfs have also become a large source
61080 + of new vulnerabilities, ranging from infoleaks to local compromise.
61081 + There has been very little oversight with an eye toward security involved
61082 + in adding new exporters of information to these filesystems, so their
61083 + use is discouraged.
61084 + For reasons of compatibility, a few directories have been whitelisted
61085 + for access by non-root users:
61086 + /sys/fs/selinux
61087 + /sys/fs/fuse
61088 + /sys/devices/system/cpu
61089 +
61090 +config GRKERNSEC_ROFS
61091 + bool "Runtime read-only mount protection"
61092 + depends on SYSCTL
61093 + help
61094 + If you say Y here, a sysctl option with name "romount_protect" will
61095 + be created. By setting this option to 1 at runtime, filesystems
61096 + will be protected in the following ways:
61097 + * No new writable mounts will be allowed
61098 + * Existing read-only mounts won't be able to be remounted read/write
61099 + * Write operations will be denied on all block devices
61100 + This option acts independently of grsec_lock: once it is set to 1,
61101 + it cannot be turned off. Therefore, please be mindful of the resulting
61102 + behavior if this option is enabled in an init script on a read-only
61103 + filesystem. This feature is mainly intended for secure embedded systems.
61104 +
61105 +config GRKERNSEC_DEVICE_SIDECHANNEL
61106 + bool "Eliminate stat/notify-based device sidechannels"
61107 + default y if GRKERNSEC_CONFIG_AUTO
61108 + help
61109 + If you say Y here, timing analyses on block or character
61110 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
61111 + will be thwarted for unprivileged users. If a process without
61112 + CAP_MKNOD stats such a device, the last access and last modify times
61113 + will match the device's create time. No access or modify events
61114 + will be triggered through inotify/dnotify/fanotify for such devices.
61115 + This feature will prevent attacks that may at a minimum
61116 + allow an attacker to determine the administrator's password length.
61117 +
61118 +config GRKERNSEC_CHROOT
61119 + bool "Chroot jail restrictions"
61120 + default y if GRKERNSEC_CONFIG_AUTO
61121 + help
61122 + If you say Y here, you will be able to choose several options that will
61123 + make breaking out of a chrooted jail much more difficult. If you
61124 + encounter no software incompatibilities with the following options, it
61125 + is recommended that you enable each one.
61126 +
61127 +config GRKERNSEC_CHROOT_MOUNT
61128 + bool "Deny mounts"
61129 + default y if GRKERNSEC_CONFIG_AUTO
61130 + depends on GRKERNSEC_CHROOT
61131 + help
61132 + If you say Y here, processes inside a chroot will not be able to
61133 + mount or remount filesystems. If the sysctl option is enabled, a
61134 + sysctl option with name "chroot_deny_mount" is created.
61135 +
61136 +config GRKERNSEC_CHROOT_DOUBLE
61137 + bool "Deny double-chroots"
61138 + default y if GRKERNSEC_CONFIG_AUTO
61139 + depends on GRKERNSEC_CHROOT
61140 + help
61141 + If you say Y here, processes inside a chroot will not be able to chroot
61142 + again outside the chroot. This is a widely used method of breaking
61143 + out of a chroot jail and should not be allowed. If the sysctl
61144 + option is enabled, a sysctl option with name
61145 + "chroot_deny_chroot" is created.
61146 +
61147 +config GRKERNSEC_CHROOT_PIVOT
61148 + bool "Deny pivot_root in chroot"
61149 + default y if GRKERNSEC_CONFIG_AUTO
61150 + depends on GRKERNSEC_CHROOT
61151 + help
61152 + If you say Y here, processes inside a chroot will not be able to use
61153 + a function called pivot_root() that was introduced in Linux 2.3.41. It
61154 + works similar to chroot in that it changes the root filesystem. This
61155 + function could be misused in a chrooted process to attempt to break out
61156 + of the chroot, and therefore should not be allowed. If the sysctl
61157 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
61158 + created.
61159 +
61160 +config GRKERNSEC_CHROOT_CHDIR
61161 + bool "Enforce chdir(\"/\") on all chroots"
61162 + default y if GRKERNSEC_CONFIG_AUTO
61163 + depends on GRKERNSEC_CHROOT
61164 + help
61165 + If you say Y here, the current working directory of all newly-chrooted
61166 + applications will be set to the the root directory of the chroot.
61167 + The man page on chroot(2) states:
61168 + Note that this call does not change the current working
61169 + directory, so that `.' can be outside the tree rooted at
61170 + `/'. In particular, the super-user can escape from a
61171 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
61172 +
61173 + It is recommended that you say Y here, since it's not known to break
61174 + any software. If the sysctl option is enabled, a sysctl option with
61175 + name "chroot_enforce_chdir" is created.
61176 +
61177 +config GRKERNSEC_CHROOT_CHMOD
61178 + bool "Deny (f)chmod +s"
61179 + default y if GRKERNSEC_CONFIG_AUTO
61180 + depends on GRKERNSEC_CHROOT
61181 + help
61182 + If you say Y here, processes inside a chroot will not be able to chmod
61183 + or fchmod files to make them have suid or sgid bits. This protects
61184 + against another published method of breaking a chroot. If the sysctl
61185 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
61186 + created.
61187 +
61188 +config GRKERNSEC_CHROOT_FCHDIR
61189 + bool "Deny fchdir out of chroot"
61190 + default y if GRKERNSEC_CONFIG_AUTO
61191 + depends on GRKERNSEC_CHROOT
61192 + help
61193 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
61194 + to a file descriptor of the chrooting process that points to a directory
61195 + outside the filesystem will be stopped. If the sysctl option
61196 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
61197 +
61198 +config GRKERNSEC_CHROOT_MKNOD
61199 + bool "Deny mknod"
61200 + default y if GRKERNSEC_CONFIG_AUTO
61201 + depends on GRKERNSEC_CHROOT
61202 + help
61203 + If you say Y here, processes inside a chroot will not be allowed to
61204 + mknod. The problem with using mknod inside a chroot is that it
61205 + would allow an attacker to create a device entry that is the same
61206 + as one on the physical root of your system, which could range from
61207 + anything from the console device to a device for your harddrive (which
61208 + they could then use to wipe the drive or steal data). It is recommended
61209 + that you say Y here, unless you run into software incompatibilities.
61210 + If the sysctl option is enabled, a sysctl option with name
61211 + "chroot_deny_mknod" is created.
61212 +
61213 +config GRKERNSEC_CHROOT_SHMAT
61214 + bool "Deny shmat() out of chroot"
61215 + default y if GRKERNSEC_CONFIG_AUTO
61216 + depends on GRKERNSEC_CHROOT
61217 + help
61218 + If you say Y here, processes inside a chroot will not be able to attach
61219 + to shared memory segments that were created outside of the chroot jail.
61220 + It is recommended that you say Y here. If the sysctl option is enabled,
61221 + a sysctl option with name "chroot_deny_shmat" is created.
61222 +
61223 +config GRKERNSEC_CHROOT_UNIX
61224 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
61225 + default y if GRKERNSEC_CONFIG_AUTO
61226 + depends on GRKERNSEC_CHROOT
61227 + help
61228 + If you say Y here, processes inside a chroot will not be able to
61229 + connect to abstract (meaning not belonging to a filesystem) Unix
61230 + domain sockets that were bound outside of a chroot. It is recommended
61231 + that you say Y here. If the sysctl option is enabled, a sysctl option
61232 + with name "chroot_deny_unix" is created.
61233 +
61234 +config GRKERNSEC_CHROOT_FINDTASK
61235 + bool "Protect outside processes"
61236 + default y if GRKERNSEC_CONFIG_AUTO
61237 + depends on GRKERNSEC_CHROOT
61238 + help
61239 + If you say Y here, processes inside a chroot will not be able to
61240 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
61241 + getsid, or view any process outside of the chroot. If the sysctl
61242 + option is enabled, a sysctl option with name "chroot_findtask" is
61243 + created.
61244 +
61245 +config GRKERNSEC_CHROOT_NICE
61246 + bool "Restrict priority changes"
61247 + default y if GRKERNSEC_CONFIG_AUTO
61248 + depends on GRKERNSEC_CHROOT
61249 + help
61250 + If you say Y here, processes inside a chroot will not be able to raise
61251 + the priority of processes in the chroot, or alter the priority of
61252 + processes outside the chroot. This provides more security than simply
61253 + removing CAP_SYS_NICE from the process' capability set. If the
61254 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
61255 + is created.
61256 +
61257 +config GRKERNSEC_CHROOT_SYSCTL
61258 + bool "Deny sysctl writes"
61259 + default y if GRKERNSEC_CONFIG_AUTO
61260 + depends on GRKERNSEC_CHROOT
61261 + help
61262 + If you say Y here, an attacker in a chroot will not be able to
61263 + write to sysctl entries, either by sysctl(2) or through a /proc
61264 + interface. It is strongly recommended that you say Y here. If the
61265 + sysctl option is enabled, a sysctl option with name
61266 + "chroot_deny_sysctl" is created.
61267 +
61268 +config GRKERNSEC_CHROOT_CAPS
61269 + bool "Capability restrictions"
61270 + default y if GRKERNSEC_CONFIG_AUTO
61271 + depends on GRKERNSEC_CHROOT
61272 + help
61273 + If you say Y here, the capabilities on all processes within a
61274 + chroot jail will be lowered to stop module insertion, raw i/o,
61275 + system and net admin tasks, rebooting the system, modifying immutable
61276 + files, modifying IPC owned by another, and changing the system time.
61277 + This is left an option because it can break some apps. Disable this
61278 + if your chrooted apps are having problems performing those kinds of
61279 + tasks. If the sysctl option is enabled, a sysctl option with
61280 + name "chroot_caps" is created.
61281 +
61282 +config GRKERNSEC_CHROOT_INITRD
61283 + bool "Exempt initrd tasks from restrictions"
61284 + default y if GRKERNSEC_CONFIG_AUTO
61285 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
61286 + help
61287 + If you say Y here, tasks started prior to init will be exempted from
61288 + grsecurity's chroot restrictions. This option is mainly meant to
61289 + resolve Plymouth's performing privileged operations unnecessarily
61290 + in a chroot.
61291 +
61292 +endmenu
61293 +menu "Kernel Auditing"
61294 +depends on GRKERNSEC
61295 +
61296 +config GRKERNSEC_AUDIT_GROUP
61297 + bool "Single group for auditing"
61298 + help
61299 + If you say Y here, the exec and chdir logging features will only operate
61300 + on a group you specify. This option is recommended if you only want to
61301 + watch certain users instead of having a large amount of logs from the
61302 + entire system. If the sysctl option is enabled, a sysctl option with
61303 + name "audit_group" is created.
61304 +
61305 +config GRKERNSEC_AUDIT_GID
61306 + int "GID for auditing"
61307 + depends on GRKERNSEC_AUDIT_GROUP
61308 + default 1007
61309 +
61310 +config GRKERNSEC_EXECLOG
61311 + bool "Exec logging"
61312 + help
61313 + If you say Y here, all execve() calls will be logged (since the
61314 + other exec*() calls are frontends to execve(), all execution
61315 + will be logged). Useful for shell-servers that like to keep track
61316 + of their users. If the sysctl option is enabled, a sysctl option with
61317 + name "exec_logging" is created.
61318 + WARNING: This option when enabled will produce a LOT of logs, especially
61319 + on an active system.
61320 +
61321 +config GRKERNSEC_RESLOG
61322 + bool "Resource logging"
61323 + default y if GRKERNSEC_CONFIG_AUTO
61324 + help
61325 + If you say Y here, all attempts to overstep resource limits will
61326 + be logged with the resource name, the requested size, and the current
61327 + limit. It is highly recommended that you say Y here. If the sysctl
61328 + option is enabled, a sysctl option with name "resource_logging" is
61329 + created. If the RBAC system is enabled, the sysctl value is ignored.
61330 +
61331 +config GRKERNSEC_CHROOT_EXECLOG
61332 + bool "Log execs within chroot"
61333 + help
61334 + If you say Y here, all executions inside a chroot jail will be logged
61335 + to syslog. This can cause a large amount of logs if certain
61336 + applications (eg. djb's daemontools) are installed on the system, and
61337 + is therefore left as an option. If the sysctl option is enabled, a
61338 + sysctl option with name "chroot_execlog" is created.
61339 +
61340 +config GRKERNSEC_AUDIT_PTRACE
61341 + bool "Ptrace logging"
61342 + help
61343 + If you say Y here, all attempts to attach to a process via ptrace
61344 + will be logged. If the sysctl option is enabled, a sysctl option
61345 + with name "audit_ptrace" is created.
61346 +
61347 +config GRKERNSEC_AUDIT_CHDIR
61348 + bool "Chdir logging"
61349 + help
61350 + If you say Y here, all chdir() calls will be logged. If the sysctl
61351 + option is enabled, a sysctl option with name "audit_chdir" is created.
61352 +
61353 +config GRKERNSEC_AUDIT_MOUNT
61354 + bool "(Un)Mount logging"
61355 + help
61356 + If you say Y here, all mounts and unmounts will be logged. If the
61357 + sysctl option is enabled, a sysctl option with name "audit_mount" is
61358 + created.
61359 +
61360 +config GRKERNSEC_SIGNAL
61361 + bool "Signal logging"
61362 + default y if GRKERNSEC_CONFIG_AUTO
61363 + help
61364 + If you say Y here, certain important signals will be logged, such as
61365 + SIGSEGV, which will as a result inform you of when a error in a program
61366 + occurred, which in some cases could mean a possible exploit attempt.
61367 + If the sysctl option is enabled, a sysctl option with name
61368 + "signal_logging" is created.
61369 +
61370 +config GRKERNSEC_FORKFAIL
61371 + bool "Fork failure logging"
61372 + help
61373 + If you say Y here, all failed fork() attempts will be logged.
61374 + This could suggest a fork bomb, or someone attempting to overstep
61375 + their process limit. If the sysctl option is enabled, a sysctl option
61376 + with name "forkfail_logging" is created.
61377 +
61378 +config GRKERNSEC_TIME
61379 + bool "Time change logging"
61380 + default y if GRKERNSEC_CONFIG_AUTO
61381 + help
61382 + If you say Y here, any changes of the system clock will be logged.
61383 + If the sysctl option is enabled, a sysctl option with name
61384 + "timechange_logging" is created.
61385 +
61386 +config GRKERNSEC_PROC_IPADDR
61387 + bool "/proc/<pid>/ipaddr support"
61388 + default y if GRKERNSEC_CONFIG_AUTO
61389 + help
61390 + If you say Y here, a new entry will be added to each /proc/<pid>
61391 + directory that contains the IP address of the person using the task.
61392 + The IP is carried across local TCP and AF_UNIX stream sockets.
61393 + This information can be useful for IDS/IPSes to perform remote response
61394 + to a local attack. The entry is readable by only the owner of the
61395 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
61396 + the RBAC system), and thus does not create privacy concerns.
61397 +
61398 +config GRKERNSEC_RWXMAP_LOG
61399 + bool 'Denied RWX mmap/mprotect logging'
61400 + default y if GRKERNSEC_CONFIG_AUTO
61401 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
61402 + help
61403 + If you say Y here, calls to mmap() and mprotect() with explicit
61404 + usage of PROT_WRITE and PROT_EXEC together will be logged when
61405 + denied by the PAX_MPROTECT feature. This feature will also
61406 + log other problematic scenarios that can occur when PAX_MPROTECT
61407 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
61408 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
61409 + is created.
61410 +
61411 +endmenu
61412 +
61413 +menu "Executable Protections"
61414 +depends on GRKERNSEC
61415 +
61416 +config GRKERNSEC_DMESG
61417 + bool "Dmesg(8) restriction"
61418 + default y if GRKERNSEC_CONFIG_AUTO
61419 + help
61420 + If you say Y here, non-root users will not be able to use dmesg(8)
61421 + to view the contents of the kernel's circular log buffer.
61422 + The kernel's log buffer often contains kernel addresses and other
61423 + identifying information useful to an attacker in fingerprinting a
61424 + system for a targeted exploit.
61425 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
61426 + created.
61427 +
61428 +config GRKERNSEC_HARDEN_PTRACE
61429 + bool "Deter ptrace-based process snooping"
61430 + default y if GRKERNSEC_CONFIG_AUTO
61431 + help
61432 + If you say Y here, TTY sniffers and other malicious monitoring
61433 + programs implemented through ptrace will be defeated. If you
61434 + have been using the RBAC system, this option has already been
61435 + enabled for several years for all users, with the ability to make
61436 + fine-grained exceptions.
61437 +
61438 + This option only affects the ability of non-root users to ptrace
61439 + processes that are not a descendent of the ptracing process.
61440 + This means that strace ./binary and gdb ./binary will still work,
61441 + but attaching to arbitrary processes will not. If the sysctl
61442 + option is enabled, a sysctl option with name "harden_ptrace" is
61443 + created.
61444 +
61445 +config GRKERNSEC_PTRACE_READEXEC
61446 + bool "Require read access to ptrace sensitive binaries"
61447 + default y if GRKERNSEC_CONFIG_AUTO
61448 + help
61449 + If you say Y here, unprivileged users will not be able to ptrace unreadable
61450 + binaries. This option is useful in environments that
61451 + remove the read bits (e.g. file mode 4711) from suid binaries to
61452 + prevent infoleaking of their contents. This option adds
61453 + consistency to the use of that file mode, as the binary could normally
61454 + be read out when run without privileges while ptracing.
61455 +
61456 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
61457 + is created.
61458 +
61459 +config GRKERNSEC_SETXID
61460 + bool "Enforce consistent multithreaded privileges"
61461 + default y if GRKERNSEC_CONFIG_AUTO
61462 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
61463 + help
61464 + If you say Y here, a change from a root uid to a non-root uid
61465 + in a multithreaded application will cause the resulting uids,
61466 + gids, supplementary groups, and capabilities in that thread
61467 + to be propagated to the other threads of the process. In most
61468 + cases this is unnecessary, as glibc will emulate this behavior
61469 + on behalf of the application. Other libcs do not act in the
61470 + same way, allowing the other threads of the process to continue
61471 + running with root privileges. If the sysctl option is enabled,
61472 + a sysctl option with name "consistent_setxid" is created.
61473 +
61474 +config GRKERNSEC_TPE
61475 + bool "Trusted Path Execution (TPE)"
61476 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61477 + help
61478 + If you say Y here, you will be able to choose a gid to add to the
61479 + supplementary groups of users you want to mark as "untrusted."
61480 + These users will not be able to execute any files that are not in
61481 + root-owned directories writable only by root. If the sysctl option
61482 + is enabled, a sysctl option with name "tpe" is created.
61483 +
61484 +config GRKERNSEC_TPE_ALL
61485 + bool "Partially restrict all non-root users"
61486 + depends on GRKERNSEC_TPE
61487 + help
61488 + If you say Y here, all non-root users will be covered under
61489 + a weaker TPE restriction. This is separate from, and in addition to,
61490 + the main TPE options that you have selected elsewhere. Thus, if a
61491 + "trusted" GID is chosen, this restriction applies to even that GID.
61492 + Under this restriction, all non-root users will only be allowed to
61493 + execute files in directories they own that are not group or
61494 + world-writable, or in directories owned by root and writable only by
61495 + root. If the sysctl option is enabled, a sysctl option with name
61496 + "tpe_restrict_all" is created.
61497 +
61498 +config GRKERNSEC_TPE_INVERT
61499 + bool "Invert GID option"
61500 + depends on GRKERNSEC_TPE
61501 + help
61502 + If you say Y here, the group you specify in the TPE configuration will
61503 + decide what group TPE restrictions will be *disabled* for. This
61504 + option is useful if you want TPE restrictions to be applied to most
61505 + users on the system. If the sysctl option is enabled, a sysctl option
61506 + with name "tpe_invert" is created. Unlike other sysctl options, this
61507 + entry will default to on for backward-compatibility.
61508 +
61509 +config GRKERNSEC_TPE_GID
61510 + int
61511 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
61512 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
61513 +
61514 +config GRKERNSEC_TPE_UNTRUSTED_GID
61515 + int "GID for TPE-untrusted users"
61516 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
61517 + default 1005
61518 + help
61519 + Setting this GID determines what group TPE restrictions will be
61520 + *enabled* for. If the sysctl option is enabled, a sysctl option
61521 + with name "tpe_gid" is created.
61522 +
61523 +config GRKERNSEC_TPE_TRUSTED_GID
61524 + int "GID for TPE-trusted users"
61525 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
61526 + default 1005
61527 + help
61528 + Setting this GID determines what group TPE restrictions will be
61529 + *disabled* for. If the sysctl option is enabled, a sysctl option
61530 + with name "tpe_gid" is created.
61531 +
61532 +endmenu
61533 +menu "Network Protections"
61534 +depends on GRKERNSEC
61535 +
61536 +config GRKERNSEC_RANDNET
61537 + bool "Larger entropy pools"
61538 + default y if GRKERNSEC_CONFIG_AUTO
61539 + help
61540 + If you say Y here, the entropy pools used for many features of Linux
61541 + and grsecurity will be doubled in size. Since several grsecurity
61542 + features use additional randomness, it is recommended that you say Y
61543 + here. Saying Y here has a similar effect as modifying
61544 + /proc/sys/kernel/random/poolsize.
61545 +
61546 +config GRKERNSEC_BLACKHOLE
61547 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
61548 + default y if GRKERNSEC_CONFIG_AUTO
61549 + depends on NET
61550 + help
61551 + If you say Y here, neither TCP resets nor ICMP
61552 + destination-unreachable packets will be sent in response to packets
61553 + sent to ports for which no associated listening process exists.
61554 + This feature supports both IPV4 and IPV6 and exempts the
61555 + loopback interface from blackholing. Enabling this feature
61556 + makes a host more resilient to DoS attacks and reduces network
61557 + visibility against scanners.
61558 +
61559 + The blackhole feature as-implemented is equivalent to the FreeBSD
61560 + blackhole feature, as it prevents RST responses to all packets, not
61561 + just SYNs. Under most application behavior this causes no
61562 + problems, but applications (like haproxy) may not close certain
61563 + connections in a way that cleanly terminates them on the remote
61564 + end, leaving the remote host in LAST_ACK state. Because of this
61565 + side-effect and to prevent intentional LAST_ACK DoSes, this
61566 + feature also adds automatic mitigation against such attacks.
61567 + The mitigation drastically reduces the amount of time a socket
61568 + can spend in LAST_ACK state. If you're using haproxy and not
61569 + all servers it connects to have this option enabled, consider
61570 + disabling this feature on the haproxy host.
61571 +
61572 + If the sysctl option is enabled, two sysctl options with names
61573 + "ip_blackhole" and "lastack_retries" will be created.
61574 + While "ip_blackhole" takes the standard zero/non-zero on/off
61575 + toggle, "lastack_retries" uses the same kinds of values as
61576 + "tcp_retries1" and "tcp_retries2". The default value of 4
61577 + prevents a socket from lasting more than 45 seconds in LAST_ACK
61578 + state.
61579 +
61580 +config GRKERNSEC_NO_SIMULT_CONNECT
61581 + bool "Disable TCP Simultaneous Connect"
61582 + default y if GRKERNSEC_CONFIG_AUTO
61583 + depends on NET
61584 + help
61585 + If you say Y here, a feature by Willy Tarreau will be enabled that
61586 + removes a weakness in Linux's strict implementation of TCP that
61587 + allows two clients to connect to each other without either entering
61588 + a listening state. The weakness allows an attacker to easily prevent
61589 + a client from connecting to a known server provided the source port
61590 + for the connection is guessed correctly.
61591 +
61592 + As the weakness could be used to prevent an antivirus or IPS from
61593 + fetching updates, or prevent an SSL gateway from fetching a CRL,
61594 + it should be eliminated by enabling this option. Though Linux is
61595 + one of few operating systems supporting simultaneous connect, it
61596 + has no legitimate use in practice and is rarely supported by firewalls.
61597 +
61598 +config GRKERNSEC_SOCKET
61599 + bool "Socket restrictions"
61600 + depends on NET
61601 + help
61602 + If you say Y here, you will be able to choose from several options.
61603 + If you assign a GID on your system and add it to the supplementary
61604 + groups of users you want to restrict socket access to, this patch
61605 + will perform up to three things, based on the option(s) you choose.
61606 +
61607 +config GRKERNSEC_SOCKET_ALL
61608 + bool "Deny any sockets to group"
61609 + depends on GRKERNSEC_SOCKET
61610 + help
61611 + If you say Y here, you will be able to choose a GID of whose users will
61612 + be unable to connect to other hosts from your machine or run server
61613 + applications from your machine. If the sysctl option is enabled, a
61614 + sysctl option with name "socket_all" is created.
61615 +
61616 +config GRKERNSEC_SOCKET_ALL_GID
61617 + int "GID to deny all sockets for"
61618 + depends on GRKERNSEC_SOCKET_ALL
61619 + default 1004
61620 + help
61621 + Here you can choose the GID to disable socket access for. Remember to
61622 + add the users you want socket access disabled for to the GID
61623 + specified here. If the sysctl option is enabled, a sysctl option
61624 + with name "socket_all_gid" is created.
61625 +
61626 +config GRKERNSEC_SOCKET_CLIENT
61627 + bool "Deny client sockets to group"
61628 + depends on GRKERNSEC_SOCKET
61629 + help
61630 + If you say Y here, you will be able to choose a GID of whose users will
61631 + be unable to connect to other hosts from your machine, but will be
61632 + able to run servers. If this option is enabled, all users in the group
61633 + you specify will have to use passive mode when initiating ftp transfers
61634 + from the shell on your machine. If the sysctl option is enabled, a
61635 + sysctl option with name "socket_client" is created.
61636 +
61637 +config GRKERNSEC_SOCKET_CLIENT_GID
61638 + int "GID to deny client sockets for"
61639 + depends on GRKERNSEC_SOCKET_CLIENT
61640 + default 1003
61641 + help
61642 + Here you can choose the GID to disable client socket access for.
61643 + Remember to add the users you want client socket access disabled for to
61644 + the GID specified here. If the sysctl option is enabled, a sysctl
61645 + option with name "socket_client_gid" is created.
61646 +
61647 +config GRKERNSEC_SOCKET_SERVER
61648 + bool "Deny server sockets to group"
61649 + depends on GRKERNSEC_SOCKET
61650 + help
61651 + If you say Y here, you will be able to choose a GID of whose users will
61652 + be unable to run server applications from your machine. If the sysctl
61653 + option is enabled, a sysctl option with name "socket_server" is created.
61654 +
61655 +config GRKERNSEC_SOCKET_SERVER_GID
61656 + int "GID to deny server sockets for"
61657 + depends on GRKERNSEC_SOCKET_SERVER
61658 + default 1002
61659 + help
61660 + Here you can choose the GID to disable server socket access for.
61661 + Remember to add the users you want server socket access disabled for to
61662 + the GID specified here. If the sysctl option is enabled, a sysctl
61663 + option with name "socket_server_gid" is created.
61664 +
61665 +endmenu
61666 +
61667 +menu "Physical Protections"
61668 +depends on GRKERNSEC
61669 +
61670 +config GRKERNSEC_DENYUSB
61671 + bool "Deny new USB connections after toggle"
61672 + default y if GRKERNSEC_CONFIG_AUTO
61673 + depends on SYSCTL && USB_SUPPORT
61674 + help
61675 + If you say Y here, a new sysctl option with name "deny_new_usb"
61676 + will be created. Setting its value to 1 will prevent any new
61677 + USB devices from being recognized by the OS. Any attempted USB
61678 + device insertion will be logged. This option is intended to be
61679 + used against custom USB devices designed to exploit vulnerabilities
61680 + in various USB device drivers.
61681 +
61682 + For greatest effectiveness, this sysctl should be set after any
61683 + relevant init scripts. This option is safe to enable in distros
61684 + as each user can choose whether or not to toggle the sysctl.
61685 +
61686 +config GRKERNSEC_DENYUSB_FORCE
61687 + bool "Reject all USB devices not connected at boot"
61688 + select USB
61689 + depends on GRKERNSEC_DENYUSB
61690 + help
61691 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
61692 + that doesn't involve a sysctl entry. This option should only be
61693 + enabled if you're sure you want to deny all new USB connections
61694 + at runtime and don't want to modify init scripts. This should not
61695 + be enabled by distros. It forces the core USB code to be built
61696 + into the kernel image so that all devices connected at boot time
61697 + can be recognized and new USB device connections can be prevented
61698 + prior to init running.
61699 +
61700 +endmenu
61701 +
61702 +menu "Sysctl Support"
61703 +depends on GRKERNSEC && SYSCTL
61704 +
61705 +config GRKERNSEC_SYSCTL
61706 + bool "Sysctl support"
61707 + default y if GRKERNSEC_CONFIG_AUTO
61708 + help
61709 + If you say Y here, you will be able to change the options that
61710 + grsecurity runs with at bootup, without having to recompile your
61711 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
61712 + to enable (1) or disable (0) various features. All the sysctl entries
61713 + are mutable until the "grsec_lock" entry is set to a non-zero value.
61714 + All features enabled in the kernel configuration are disabled at boot
61715 + if you do not say Y to the "Turn on features by default" option.
61716 + All options should be set at startup, and the grsec_lock entry should
61717 + be set to a non-zero value after all the options are set.
61718 + *THIS IS EXTREMELY IMPORTANT*
61719 +
61720 +config GRKERNSEC_SYSCTL_DISTRO
61721 + bool "Extra sysctl support for distro makers (READ HELP)"
61722 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
61723 + help
61724 + If you say Y here, additional sysctl options will be created
61725 + for features that affect processes running as root. Therefore,
61726 + it is critical when using this option that the grsec_lock entry be
61727 + enabled after boot. Only distros with prebuilt kernel packages
61728 + with this option enabled that can ensure grsec_lock is enabled
61729 + after boot should use this option.
61730 + *Failure to set grsec_lock after boot makes all grsec features
61731 + this option covers useless*
61732 +
61733 + Currently this option creates the following sysctl entries:
61734 + "Disable Privileged I/O": "disable_priv_io"
61735 +
61736 +config GRKERNSEC_SYSCTL_ON
61737 + bool "Turn on features by default"
61738 + default y if GRKERNSEC_CONFIG_AUTO
61739 + depends on GRKERNSEC_SYSCTL
61740 + help
61741 + If you say Y here, instead of having all features enabled in the
61742 + kernel configuration disabled at boot time, the features will be
61743 + enabled at boot time. It is recommended you say Y here unless
61744 + there is some reason you would want all sysctl-tunable features to
61745 + be disabled by default. As mentioned elsewhere, it is important
61746 + to enable the grsec_lock entry once you have finished modifying
61747 + the sysctl entries.
61748 +
61749 +endmenu
61750 +menu "Logging Options"
61751 +depends on GRKERNSEC
61752 +
61753 +config GRKERNSEC_FLOODTIME
61754 + int "Seconds in between log messages (minimum)"
61755 + default 10
61756 + help
61757 + This option allows you to enforce the number of seconds between
61758 + grsecurity log messages. The default should be suitable for most
61759 + people, however, if you choose to change it, choose a value small enough
61760 + to allow informative logs to be produced, but large enough to
61761 + prevent flooding.
61762 +
61763 +config GRKERNSEC_FLOODBURST
61764 + int "Number of messages in a burst (maximum)"
61765 + default 6
61766 + help
61767 + This option allows you to choose the maximum number of messages allowed
61768 + within the flood time interval you chose in a separate option. The
61769 + default should be suitable for most people, however if you find that
61770 + many of your logs are being interpreted as flooding, you may want to
61771 + raise this value.
61772 +
61773 +endmenu
61774 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
61775 new file mode 100644
61776 index 0000000..b0b77d5
61777 --- /dev/null
61778 +++ b/grsecurity/Makefile
61779 @@ -0,0 +1,43 @@
61780 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
61781 +# during 2001-2009 it has been completely redesigned by Brad Spengler
61782 +# into an RBAC system
61783 +#
61784 +# All code in this directory and various hooks inserted throughout the kernel
61785 +# are copyright Brad Spengler - Open Source Security, Inc., and released
61786 +# under the GPL v2 or higher
61787 +
61788 +KBUILD_CFLAGS += -Werror
61789 +
61790 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
61791 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
61792 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
61793 + grsec_usb.o
61794 +
61795 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
61796 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
61797 + gracl_learn.o grsec_log.o
61798 +ifdef CONFIG_COMPAT
61799 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
61800 +endif
61801 +
61802 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
61803 +
61804 +ifdef CONFIG_NET
61805 +obj-y += grsec_sock.o
61806 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
61807 +endif
61808 +
61809 +ifndef CONFIG_GRKERNSEC
61810 +obj-y += grsec_disabled.o
61811 +endif
61812 +
61813 +ifdef CONFIG_GRKERNSEC_HIDESYM
61814 +extra-y := grsec_hidesym.o
61815 +$(obj)/grsec_hidesym.o:
61816 + @-chmod -f 500 /boot
61817 + @-chmod -f 500 /lib/modules
61818 + @-chmod -f 500 /lib64/modules
61819 + @-chmod -f 500 /lib32/modules
61820 + @-chmod -f 700 .
61821 + @echo ' grsec: protected kernel image paths'
61822 +endif
61823 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
61824 new file mode 100644
61825 index 0000000..c0793fd
61826 --- /dev/null
61827 +++ b/grsecurity/gracl.c
61828 @@ -0,0 +1,4178 @@
61829 +#include <linux/kernel.h>
61830 +#include <linux/module.h>
61831 +#include <linux/sched.h>
61832 +#include <linux/mm.h>
61833 +#include <linux/file.h>
61834 +#include <linux/fs.h>
61835 +#include <linux/namei.h>
61836 +#include <linux/mount.h>
61837 +#include <linux/tty.h>
61838 +#include <linux/proc_fs.h>
61839 +#include <linux/lglock.h>
61840 +#include <linux/slab.h>
61841 +#include <linux/vmalloc.h>
61842 +#include <linux/types.h>
61843 +#include <linux/sysctl.h>
61844 +#include <linux/netdevice.h>
61845 +#include <linux/ptrace.h>
61846 +#include <linux/gracl.h>
61847 +#include <linux/gralloc.h>
61848 +#include <linux/security.h>
61849 +#include <linux/grinternal.h>
61850 +#include <linux/pid_namespace.h>
61851 +#include <linux/stop_machine.h>
61852 +#include <linux/fdtable.h>
61853 +#include <linux/percpu.h>
61854 +#include <linux/lglock.h>
61855 +#include <linux/hugetlb.h>
61856 +#include <linux/posix-timers.h>
61857 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
61858 +#include <linux/magic.h>
61859 +#include <linux/pagemap.h>
61860 +#include "../fs/btrfs/async-thread.h"
61861 +#include "../fs/btrfs/ctree.h"
61862 +#include "../fs/btrfs/btrfs_inode.h"
61863 +#endif
61864 +#include "../fs/mount.h"
61865 +
61866 +#include <asm/uaccess.h>
61867 +#include <asm/errno.h>
61868 +#include <asm/mman.h>
61869 +
61870 +extern struct lglock vfsmount_lock;
61871 +
61872 +static struct acl_role_db acl_role_set;
61873 +static struct name_db name_set;
61874 +static struct inodev_db inodev_set;
61875 +
61876 +/* for keeping track of userspace pointers used for subjects, so we
61877 + can share references in the kernel as well
61878 +*/
61879 +
61880 +static struct path real_root;
61881 +
61882 +static struct acl_subj_map_db subj_map_set;
61883 +
61884 +static struct acl_role_label *default_role;
61885 +
61886 +static struct acl_role_label *role_list;
61887 +
61888 +static u16 acl_sp_role_value;
61889 +
61890 +extern char *gr_shared_page[4];
61891 +static DEFINE_MUTEX(gr_dev_mutex);
61892 +DEFINE_RWLOCK(gr_inode_lock);
61893 +
61894 +struct gr_arg *gr_usermode;
61895 +
61896 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
61897 +
61898 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
61899 +extern void gr_clear_learn_entries(void);
61900 +
61901 +unsigned char *gr_system_salt;
61902 +unsigned char *gr_system_sum;
61903 +
61904 +static struct sprole_pw **acl_special_roles = NULL;
61905 +static __u16 num_sprole_pws = 0;
61906 +
61907 +static struct acl_role_label *kernel_role = NULL;
61908 +
61909 +static unsigned int gr_auth_attempts = 0;
61910 +static unsigned long gr_auth_expires = 0UL;
61911 +
61912 +#ifdef CONFIG_NET
61913 +extern struct vfsmount *sock_mnt;
61914 +#endif
61915 +
61916 +extern struct vfsmount *pipe_mnt;
61917 +extern struct vfsmount *shm_mnt;
61918 +
61919 +#ifdef CONFIG_HUGETLBFS
61920 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
61921 +#endif
61922 +
61923 +static struct acl_object_label *fakefs_obj_rw;
61924 +static struct acl_object_label *fakefs_obj_rwx;
61925 +
61926 +extern int gr_init_uidset(void);
61927 +extern void gr_free_uidset(void);
61928 +extern void gr_remove_uid(uid_t uid);
61929 +extern int gr_find_uid(uid_t uid);
61930 +
61931 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
61932 +{
61933 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
61934 + return -EFAULT;
61935 +
61936 + return 0;
61937 +}
61938 +
61939 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
61940 +{
61941 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
61942 + return -EFAULT;
61943 +
61944 + return 0;
61945 +}
61946 +
61947 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
61948 +{
61949 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
61950 + return -EFAULT;
61951 +
61952 + return 0;
61953 +}
61954 +
61955 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
61956 +{
61957 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
61958 + return -EFAULT;
61959 +
61960 + return 0;
61961 +}
61962 +
61963 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
61964 +{
61965 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
61966 + return -EFAULT;
61967 +
61968 + return 0;
61969 +}
61970 +
61971 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
61972 +{
61973 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
61974 + return -EFAULT;
61975 +
61976 + return 0;
61977 +}
61978 +
61979 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
61980 +{
61981 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
61982 + return -EFAULT;
61983 +
61984 + return 0;
61985 +}
61986 +
61987 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
61988 +{
61989 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
61990 + return -EFAULT;
61991 +
61992 + return 0;
61993 +}
61994 +
61995 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
61996 +{
61997 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
61998 + return -EFAULT;
61999 +
62000 + return 0;
62001 +}
62002 +
62003 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
62004 +{
62005 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
62006 + return -EFAULT;
62007 +
62008 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
62009 + return -EINVAL;
62010 +
62011 + return 0;
62012 +}
62013 +
62014 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
62015 +{
62016 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
62017 + return -EFAULT;
62018 +
62019 + return 0;
62020 +}
62021 +
62022 +static size_t get_gr_arg_wrapper_size_normal(void)
62023 +{
62024 + return sizeof(struct gr_arg_wrapper);
62025 +}
62026 +
62027 +#ifdef CONFIG_COMPAT
62028 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
62029 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
62030 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
62031 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
62032 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
62033 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
62034 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
62035 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
62036 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
62037 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
62038 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
62039 +extern size_t get_gr_arg_wrapper_size_compat(void);
62040 +
62041 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
62042 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
62043 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
62044 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
62045 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
62046 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
62047 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
62048 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
62049 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
62050 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
62051 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
62052 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
62053 +
62054 +#else
62055 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
62056 +#define copy_gr_arg copy_gr_arg_normal
62057 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
62058 +#define copy_acl_object_label copy_acl_object_label_normal
62059 +#define copy_acl_subject_label copy_acl_subject_label_normal
62060 +#define copy_acl_role_label copy_acl_role_label_normal
62061 +#define copy_acl_ip_label copy_acl_ip_label_normal
62062 +#define copy_pointer_from_array copy_pointer_from_array_normal
62063 +#define copy_sprole_pw copy_sprole_pw_normal
62064 +#define copy_role_transition copy_role_transition_normal
62065 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
62066 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
62067 +#endif
62068 +
62069 +__inline__ int
62070 +gr_acl_is_enabled(void)
62071 +{
62072 + return (gr_status & GR_READY);
62073 +}
62074 +
62075 +static inline dev_t __get_dev(const struct dentry *dentry)
62076 +{
62077 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62078 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62079 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62080 + else
62081 +#endif
62082 + return dentry->d_sb->s_dev;
62083 +}
62084 +
62085 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62086 +{
62087 + return __get_dev(dentry);
62088 +}
62089 +
62090 +static char gr_task_roletype_to_char(struct task_struct *task)
62091 +{
62092 + switch (task->role->roletype &
62093 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62094 + GR_ROLE_SPECIAL)) {
62095 + case GR_ROLE_DEFAULT:
62096 + return 'D';
62097 + case GR_ROLE_USER:
62098 + return 'U';
62099 + case GR_ROLE_GROUP:
62100 + return 'G';
62101 + case GR_ROLE_SPECIAL:
62102 + return 'S';
62103 + }
62104 +
62105 + return 'X';
62106 +}
62107 +
62108 +char gr_roletype_to_char(void)
62109 +{
62110 + return gr_task_roletype_to_char(current);
62111 +}
62112 +
62113 +__inline__ int
62114 +gr_acl_tpe_check(void)
62115 +{
62116 + if (unlikely(!(gr_status & GR_READY)))
62117 + return 0;
62118 + if (current->role->roletype & GR_ROLE_TPE)
62119 + return 1;
62120 + else
62121 + return 0;
62122 +}
62123 +
62124 +int
62125 +gr_handle_rawio(const struct inode *inode)
62126 +{
62127 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62128 + if (inode && S_ISBLK(inode->i_mode) &&
62129 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62130 + !capable(CAP_SYS_RAWIO))
62131 + return 1;
62132 +#endif
62133 + return 0;
62134 +}
62135 +
62136 +static int
62137 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62138 +{
62139 + if (likely(lena != lenb))
62140 + return 0;
62141 +
62142 + return !memcmp(a, b, lena);
62143 +}
62144 +
62145 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62146 +{
62147 + *buflen -= namelen;
62148 + if (*buflen < 0)
62149 + return -ENAMETOOLONG;
62150 + *buffer -= namelen;
62151 + memcpy(*buffer, str, namelen);
62152 + return 0;
62153 +}
62154 +
62155 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62156 +{
62157 + return prepend(buffer, buflen, name->name, name->len);
62158 +}
62159 +
62160 +static int prepend_path(const struct path *path, struct path *root,
62161 + char **buffer, int *buflen)
62162 +{
62163 + struct dentry *dentry = path->dentry;
62164 + struct vfsmount *vfsmnt = path->mnt;
62165 + struct mount *mnt = real_mount(vfsmnt);
62166 + bool slash = false;
62167 + int error = 0;
62168 +
62169 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62170 + struct dentry * parent;
62171 +
62172 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62173 + /* Global root? */
62174 + if (!mnt_has_parent(mnt)) {
62175 + goto out;
62176 + }
62177 + dentry = mnt->mnt_mountpoint;
62178 + mnt = mnt->mnt_parent;
62179 + vfsmnt = &mnt->mnt;
62180 + continue;
62181 + }
62182 + parent = dentry->d_parent;
62183 + prefetch(parent);
62184 + spin_lock(&dentry->d_lock);
62185 + error = prepend_name(buffer, buflen, &dentry->d_name);
62186 + spin_unlock(&dentry->d_lock);
62187 + if (!error)
62188 + error = prepend(buffer, buflen, "/", 1);
62189 + if (error)
62190 + break;
62191 +
62192 + slash = true;
62193 + dentry = parent;
62194 + }
62195 +
62196 +out:
62197 + if (!error && !slash)
62198 + error = prepend(buffer, buflen, "/", 1);
62199 +
62200 + return error;
62201 +}
62202 +
62203 +/* this must be called with vfsmount_lock and rename_lock held */
62204 +
62205 +static char *__our_d_path(const struct path *path, struct path *root,
62206 + char *buf, int buflen)
62207 +{
62208 + char *res = buf + buflen;
62209 + int error;
62210 +
62211 + prepend(&res, &buflen, "\0", 1);
62212 + error = prepend_path(path, root, &res, &buflen);
62213 + if (error)
62214 + return ERR_PTR(error);
62215 +
62216 + return res;
62217 +}
62218 +
62219 +static char *
62220 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
62221 +{
62222 + char *retval;
62223 +
62224 + retval = __our_d_path(path, root, buf, buflen);
62225 + if (unlikely(IS_ERR(retval)))
62226 + retval = strcpy(buf, "<path too long>");
62227 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
62228 + retval[1] = '\0';
62229 +
62230 + return retval;
62231 +}
62232 +
62233 +static char *
62234 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62235 + char *buf, int buflen)
62236 +{
62237 + struct path path;
62238 + char *res;
62239 +
62240 + path.dentry = (struct dentry *)dentry;
62241 + path.mnt = (struct vfsmount *)vfsmnt;
62242 +
62243 + /* we can use real_root.dentry, real_root.mnt, because this is only called
62244 + by the RBAC system */
62245 + res = gen_full_path(&path, &real_root, buf, buflen);
62246 +
62247 + return res;
62248 +}
62249 +
62250 +static char *
62251 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62252 + char *buf, int buflen)
62253 +{
62254 + char *res;
62255 + struct path path;
62256 + struct path root;
62257 + struct task_struct *reaper = init_pid_ns.child_reaper;
62258 +
62259 + path.dentry = (struct dentry *)dentry;
62260 + path.mnt = (struct vfsmount *)vfsmnt;
62261 +
62262 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
62263 + get_fs_root(reaper->fs, &root);
62264 +
62265 + br_read_lock(&vfsmount_lock);
62266 + write_seqlock(&rename_lock);
62267 + res = gen_full_path(&path, &root, buf, buflen);
62268 + write_sequnlock(&rename_lock);
62269 + br_read_unlock(&vfsmount_lock);
62270 +
62271 + path_put(&root);
62272 + return res;
62273 +}
62274 +
62275 +static char *
62276 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62277 +{
62278 + char *ret;
62279 + br_read_lock(&vfsmount_lock);
62280 + write_seqlock(&rename_lock);
62281 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62282 + PAGE_SIZE);
62283 + write_sequnlock(&rename_lock);
62284 + br_read_unlock(&vfsmount_lock);
62285 + return ret;
62286 +}
62287 +
62288 +static char *
62289 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62290 +{
62291 + char *ret;
62292 + char *buf;
62293 + int buflen;
62294 +
62295 + br_read_lock(&vfsmount_lock);
62296 + write_seqlock(&rename_lock);
62297 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
62298 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
62299 + buflen = (int)(ret - buf);
62300 + if (buflen >= 5)
62301 + prepend(&ret, &buflen, "/proc", 5);
62302 + else
62303 + ret = strcpy(buf, "<path too long>");
62304 + write_sequnlock(&rename_lock);
62305 + br_read_unlock(&vfsmount_lock);
62306 + return ret;
62307 +}
62308 +
62309 +char *
62310 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
62311 +{
62312 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62313 + PAGE_SIZE);
62314 +}
62315 +
62316 +char *
62317 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
62318 +{
62319 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62320 + PAGE_SIZE);
62321 +}
62322 +
62323 +char *
62324 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
62325 +{
62326 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
62327 + PAGE_SIZE);
62328 +}
62329 +
62330 +char *
62331 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
62332 +{
62333 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
62334 + PAGE_SIZE);
62335 +}
62336 +
62337 +char *
62338 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
62339 +{
62340 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
62341 + PAGE_SIZE);
62342 +}
62343 +
62344 +__inline__ __u32
62345 +to_gr_audit(const __u32 reqmode)
62346 +{
62347 + /* masks off auditable permission flags, then shifts them to create
62348 + auditing flags, and adds the special case of append auditing if
62349 + we're requesting write */
62350 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
62351 +}
62352 +
62353 +struct acl_subject_label *
62354 +lookup_subject_map(const struct acl_subject_label *userp)
62355 +{
62356 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
62357 + struct subject_map *match;
62358 +
62359 + match = subj_map_set.s_hash[index];
62360 +
62361 + while (match && match->user != userp)
62362 + match = match->next;
62363 +
62364 + if (match != NULL)
62365 + return match->kernel;
62366 + else
62367 + return NULL;
62368 +}
62369 +
62370 +static void
62371 +insert_subj_map_entry(struct subject_map *subjmap)
62372 +{
62373 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
62374 + struct subject_map **curr;
62375 +
62376 + subjmap->prev = NULL;
62377 +
62378 + curr = &subj_map_set.s_hash[index];
62379 + if (*curr != NULL)
62380 + (*curr)->prev = subjmap;
62381 +
62382 + subjmap->next = *curr;
62383 + *curr = subjmap;
62384 +
62385 + return;
62386 +}
62387 +
62388 +static struct acl_role_label *
62389 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
62390 + const gid_t gid)
62391 +{
62392 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
62393 + struct acl_role_label *match;
62394 + struct role_allowed_ip *ipp;
62395 + unsigned int x;
62396 + u32 curr_ip = task->signal->curr_ip;
62397 +
62398 + task->signal->saved_ip = curr_ip;
62399 +
62400 + match = acl_role_set.r_hash[index];
62401 +
62402 + while (match) {
62403 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
62404 + for (x = 0; x < match->domain_child_num; x++) {
62405 + if (match->domain_children[x] == uid)
62406 + goto found;
62407 + }
62408 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
62409 + break;
62410 + match = match->next;
62411 + }
62412 +found:
62413 + if (match == NULL) {
62414 + try_group:
62415 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
62416 + match = acl_role_set.r_hash[index];
62417 +
62418 + while (match) {
62419 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
62420 + for (x = 0; x < match->domain_child_num; x++) {
62421 + if (match->domain_children[x] == gid)
62422 + goto found2;
62423 + }
62424 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
62425 + break;
62426 + match = match->next;
62427 + }
62428 +found2:
62429 + if (match == NULL)
62430 + match = default_role;
62431 + if (match->allowed_ips == NULL)
62432 + return match;
62433 + else {
62434 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62435 + if (likely
62436 + ((ntohl(curr_ip) & ipp->netmask) ==
62437 + (ntohl(ipp->addr) & ipp->netmask)))
62438 + return match;
62439 + }
62440 + match = default_role;
62441 + }
62442 + } else if (match->allowed_ips == NULL) {
62443 + return match;
62444 + } else {
62445 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62446 + if (likely
62447 + ((ntohl(curr_ip) & ipp->netmask) ==
62448 + (ntohl(ipp->addr) & ipp->netmask)))
62449 + return match;
62450 + }
62451 + goto try_group;
62452 + }
62453 +
62454 + return match;
62455 +}
62456 +
62457 +struct acl_subject_label *
62458 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
62459 + const struct acl_role_label *role)
62460 +{
62461 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62462 + struct acl_subject_label *match;
62463 +
62464 + match = role->subj_hash[index];
62465 +
62466 + while (match && (match->inode != ino || match->device != dev ||
62467 + (match->mode & GR_DELETED))) {
62468 + match = match->next;
62469 + }
62470 +
62471 + if (match && !(match->mode & GR_DELETED))
62472 + return match;
62473 + else
62474 + return NULL;
62475 +}
62476 +
62477 +struct acl_subject_label *
62478 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
62479 + const struct acl_role_label *role)
62480 +{
62481 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62482 + struct acl_subject_label *match;
62483 +
62484 + match = role->subj_hash[index];
62485 +
62486 + while (match && (match->inode != ino || match->device != dev ||
62487 + !(match->mode & GR_DELETED))) {
62488 + match = match->next;
62489 + }
62490 +
62491 + if (match && (match->mode & GR_DELETED))
62492 + return match;
62493 + else
62494 + return NULL;
62495 +}
62496 +
62497 +static struct acl_object_label *
62498 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
62499 + const struct acl_subject_label *subj)
62500 +{
62501 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62502 + struct acl_object_label *match;
62503 +
62504 + match = subj->obj_hash[index];
62505 +
62506 + while (match && (match->inode != ino || match->device != dev ||
62507 + (match->mode & GR_DELETED))) {
62508 + match = match->next;
62509 + }
62510 +
62511 + if (match && !(match->mode & GR_DELETED))
62512 + return match;
62513 + else
62514 + return NULL;
62515 +}
62516 +
62517 +static struct acl_object_label *
62518 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
62519 + const struct acl_subject_label *subj)
62520 +{
62521 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
62522 + struct acl_object_label *match;
62523 +
62524 + match = subj->obj_hash[index];
62525 +
62526 + while (match && (match->inode != ino || match->device != dev ||
62527 + !(match->mode & GR_DELETED))) {
62528 + match = match->next;
62529 + }
62530 +
62531 + if (match && (match->mode & GR_DELETED))
62532 + return match;
62533 +
62534 + match = subj->obj_hash[index];
62535 +
62536 + while (match && (match->inode != ino || match->device != dev ||
62537 + (match->mode & GR_DELETED))) {
62538 + match = match->next;
62539 + }
62540 +
62541 + if (match && !(match->mode & GR_DELETED))
62542 + return match;
62543 + else
62544 + return NULL;
62545 +}
62546 +
62547 +static struct name_entry *
62548 +lookup_name_entry(const char *name)
62549 +{
62550 + unsigned int len = strlen(name);
62551 + unsigned int key = full_name_hash(name, len);
62552 + unsigned int index = key % name_set.n_size;
62553 + struct name_entry *match;
62554 +
62555 + match = name_set.n_hash[index];
62556 +
62557 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
62558 + match = match->next;
62559 +
62560 + return match;
62561 +}
62562 +
62563 +static struct name_entry *
62564 +lookup_name_entry_create(const char *name)
62565 +{
62566 + unsigned int len = strlen(name);
62567 + unsigned int key = full_name_hash(name, len);
62568 + unsigned int index = key % name_set.n_size;
62569 + struct name_entry *match;
62570 +
62571 + match = name_set.n_hash[index];
62572 +
62573 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62574 + !match->deleted))
62575 + match = match->next;
62576 +
62577 + if (match && match->deleted)
62578 + return match;
62579 +
62580 + match = name_set.n_hash[index];
62581 +
62582 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
62583 + match->deleted))
62584 + match = match->next;
62585 +
62586 + if (match && !match->deleted)
62587 + return match;
62588 + else
62589 + return NULL;
62590 +}
62591 +
62592 +static struct inodev_entry *
62593 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
62594 +{
62595 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
62596 + struct inodev_entry *match;
62597 +
62598 + match = inodev_set.i_hash[index];
62599 +
62600 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
62601 + match = match->next;
62602 +
62603 + return match;
62604 +}
62605 +
62606 +static void
62607 +insert_inodev_entry(struct inodev_entry *entry)
62608 +{
62609 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
62610 + inodev_set.i_size);
62611 + struct inodev_entry **curr;
62612 +
62613 + entry->prev = NULL;
62614 +
62615 + curr = &inodev_set.i_hash[index];
62616 + if (*curr != NULL)
62617 + (*curr)->prev = entry;
62618 +
62619 + entry->next = *curr;
62620 + *curr = entry;
62621 +
62622 + return;
62623 +}
62624 +
62625 +static void
62626 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
62627 +{
62628 + unsigned int index =
62629 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
62630 + struct acl_role_label **curr;
62631 + struct acl_role_label *tmp, *tmp2;
62632 +
62633 + curr = &acl_role_set.r_hash[index];
62634 +
62635 + /* simple case, slot is empty, just set it to our role */
62636 + if (*curr == NULL) {
62637 + *curr = role;
62638 + } else {
62639 + /* example:
62640 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
62641 + 2 -> 3
62642 + */
62643 + /* first check to see if we can already be reached via this slot */
62644 + tmp = *curr;
62645 + while (tmp && tmp != role)
62646 + tmp = tmp->next;
62647 + if (tmp == role) {
62648 + /* we don't need to add ourselves to this slot's chain */
62649 + return;
62650 + }
62651 + /* we need to add ourselves to this chain, two cases */
62652 + if (role->next == NULL) {
62653 + /* simple case, append the current chain to our role */
62654 + role->next = *curr;
62655 + *curr = role;
62656 + } else {
62657 + /* 1 -> 2 -> 3 -> 4
62658 + 2 -> 3 -> 4
62659 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
62660 + */
62661 + /* trickier case: walk our role's chain until we find
62662 + the role for the start of the current slot's chain */
62663 + tmp = role;
62664 + tmp2 = *curr;
62665 + while (tmp->next && tmp->next != tmp2)
62666 + tmp = tmp->next;
62667 + if (tmp->next == tmp2) {
62668 + /* from example above, we found 3, so just
62669 + replace this slot's chain with ours */
62670 + *curr = role;
62671 + } else {
62672 + /* we didn't find a subset of our role's chain
62673 + in the current slot's chain, so append their
62674 + chain to ours, and set us as the first role in
62675 + the slot's chain
62676 +
62677 + we could fold this case with the case above,
62678 + but making it explicit for clarity
62679 + */
62680 + tmp->next = tmp2;
62681 + *curr = role;
62682 + }
62683 + }
62684 + }
62685 +
62686 + return;
62687 +}
62688 +
62689 +static void
62690 +insert_acl_role_label(struct acl_role_label *role)
62691 +{
62692 + int i;
62693 +
62694 + if (role_list == NULL) {
62695 + role_list = role;
62696 + role->prev = NULL;
62697 + } else {
62698 + role->prev = role_list;
62699 + role_list = role;
62700 + }
62701 +
62702 + /* used for hash chains */
62703 + role->next = NULL;
62704 +
62705 + if (role->roletype & GR_ROLE_DOMAIN) {
62706 + for (i = 0; i < role->domain_child_num; i++)
62707 + __insert_acl_role_label(role, role->domain_children[i]);
62708 + } else
62709 + __insert_acl_role_label(role, role->uidgid);
62710 +}
62711 +
62712 +static int
62713 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
62714 +{
62715 + struct name_entry **curr, *nentry;
62716 + struct inodev_entry *ientry;
62717 + unsigned int len = strlen(name);
62718 + unsigned int key = full_name_hash(name, len);
62719 + unsigned int index = key % name_set.n_size;
62720 +
62721 + curr = &name_set.n_hash[index];
62722 +
62723 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
62724 + curr = &((*curr)->next);
62725 +
62726 + if (*curr != NULL)
62727 + return 1;
62728 +
62729 + nentry = acl_alloc(sizeof (struct name_entry));
62730 + if (nentry == NULL)
62731 + return 0;
62732 + ientry = acl_alloc(sizeof (struct inodev_entry));
62733 + if (ientry == NULL)
62734 + return 0;
62735 + ientry->nentry = nentry;
62736 +
62737 + nentry->key = key;
62738 + nentry->name = name;
62739 + nentry->inode = inode;
62740 + nentry->device = device;
62741 + nentry->len = len;
62742 + nentry->deleted = deleted;
62743 +
62744 + nentry->prev = NULL;
62745 + curr = &name_set.n_hash[index];
62746 + if (*curr != NULL)
62747 + (*curr)->prev = nentry;
62748 + nentry->next = *curr;
62749 + *curr = nentry;
62750 +
62751 + /* insert us into the table searchable by inode/dev */
62752 + insert_inodev_entry(ientry);
62753 +
62754 + return 1;
62755 +}
62756 +
62757 +static void
62758 +insert_acl_obj_label(struct acl_object_label *obj,
62759 + struct acl_subject_label *subj)
62760 +{
62761 + unsigned int index =
62762 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
62763 + struct acl_object_label **curr;
62764 +
62765 +
62766 + obj->prev = NULL;
62767 +
62768 + curr = &subj->obj_hash[index];
62769 + if (*curr != NULL)
62770 + (*curr)->prev = obj;
62771 +
62772 + obj->next = *curr;
62773 + *curr = obj;
62774 +
62775 + return;
62776 +}
62777 +
62778 +static void
62779 +insert_acl_subj_label(struct acl_subject_label *obj,
62780 + struct acl_role_label *role)
62781 +{
62782 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
62783 + struct acl_subject_label **curr;
62784 +
62785 + obj->prev = NULL;
62786 +
62787 + curr = &role->subj_hash[index];
62788 + if (*curr != NULL)
62789 + (*curr)->prev = obj;
62790 +
62791 + obj->next = *curr;
62792 + *curr = obj;
62793 +
62794 + return;
62795 +}
62796 +
62797 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
62798 +
62799 +static void *
62800 +create_table(__u32 * len, int elementsize)
62801 +{
62802 + unsigned int table_sizes[] = {
62803 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
62804 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
62805 + 4194301, 8388593, 16777213, 33554393, 67108859
62806 + };
62807 + void *newtable = NULL;
62808 + unsigned int pwr = 0;
62809 +
62810 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
62811 + table_sizes[pwr] <= *len)
62812 + pwr++;
62813 +
62814 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
62815 + return newtable;
62816 +
62817 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
62818 + newtable =
62819 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
62820 + else
62821 + newtable = vmalloc(table_sizes[pwr] * elementsize);
62822 +
62823 + *len = table_sizes[pwr];
62824 +
62825 + return newtable;
62826 +}
62827 +
62828 +static int
62829 +init_variables(const struct gr_arg *arg)
62830 +{
62831 + struct task_struct *reaper = init_pid_ns.child_reaper;
62832 + unsigned int stacksize;
62833 +
62834 + subj_map_set.s_size = arg->role_db.num_subjects;
62835 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
62836 + name_set.n_size = arg->role_db.num_objects;
62837 + inodev_set.i_size = arg->role_db.num_objects;
62838 +
62839 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
62840 + !name_set.n_size || !inodev_set.i_size)
62841 + return 1;
62842 +
62843 + if (!gr_init_uidset())
62844 + return 1;
62845 +
62846 + /* set up the stack that holds allocation info */
62847 +
62848 + stacksize = arg->role_db.num_pointers + 5;
62849 +
62850 + if (!acl_alloc_stack_init(stacksize))
62851 + return 1;
62852 +
62853 + /* grab reference for the real root dentry and vfsmount */
62854 + get_fs_root(reaper->fs, &real_root);
62855 +
62856 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
62857 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
62858 +#endif
62859 +
62860 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
62861 + if (fakefs_obj_rw == NULL)
62862 + return 1;
62863 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
62864 +
62865 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
62866 + if (fakefs_obj_rwx == NULL)
62867 + return 1;
62868 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
62869 +
62870 + subj_map_set.s_hash =
62871 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
62872 + acl_role_set.r_hash =
62873 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
62874 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
62875 + inodev_set.i_hash =
62876 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
62877 +
62878 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
62879 + !name_set.n_hash || !inodev_set.i_hash)
62880 + return 1;
62881 +
62882 + memset(subj_map_set.s_hash, 0,
62883 + sizeof(struct subject_map *) * subj_map_set.s_size);
62884 + memset(acl_role_set.r_hash, 0,
62885 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
62886 + memset(name_set.n_hash, 0,
62887 + sizeof (struct name_entry *) * name_set.n_size);
62888 + memset(inodev_set.i_hash, 0,
62889 + sizeof (struct inodev_entry *) * inodev_set.i_size);
62890 +
62891 + return 0;
62892 +}
62893 +
62894 +/* free information not needed after startup
62895 + currently contains user->kernel pointer mappings for subjects
62896 +*/
62897 +
62898 +static void
62899 +free_init_variables(void)
62900 +{
62901 + __u32 i;
62902 +
62903 + if (subj_map_set.s_hash) {
62904 + for (i = 0; i < subj_map_set.s_size; i++) {
62905 + if (subj_map_set.s_hash[i]) {
62906 + kfree(subj_map_set.s_hash[i]);
62907 + subj_map_set.s_hash[i] = NULL;
62908 + }
62909 + }
62910 +
62911 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
62912 + PAGE_SIZE)
62913 + kfree(subj_map_set.s_hash);
62914 + else
62915 + vfree(subj_map_set.s_hash);
62916 + }
62917 +
62918 + return;
62919 +}
62920 +
62921 +static void
62922 +free_variables(void)
62923 +{
62924 + struct acl_subject_label *s;
62925 + struct acl_role_label *r;
62926 + struct task_struct *task, *task2;
62927 + unsigned int x;
62928 +
62929 + gr_clear_learn_entries();
62930 +
62931 + read_lock(&tasklist_lock);
62932 + do_each_thread(task2, task) {
62933 + task->acl_sp_role = 0;
62934 + task->acl_role_id = 0;
62935 + task->acl = NULL;
62936 + task->role = NULL;
62937 + } while_each_thread(task2, task);
62938 + read_unlock(&tasklist_lock);
62939 +
62940 + /* release the reference to the real root dentry and vfsmount */
62941 + path_put(&real_root);
62942 + memset(&real_root, 0, sizeof(real_root));
62943 +
62944 + /* free all object hash tables */
62945 +
62946 + FOR_EACH_ROLE_START(r)
62947 + if (r->subj_hash == NULL)
62948 + goto next_role;
62949 + FOR_EACH_SUBJECT_START(r, s, x)
62950 + if (s->obj_hash == NULL)
62951 + break;
62952 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
62953 + kfree(s->obj_hash);
62954 + else
62955 + vfree(s->obj_hash);
62956 + FOR_EACH_SUBJECT_END(s, x)
62957 + FOR_EACH_NESTED_SUBJECT_START(r, s)
62958 + if (s->obj_hash == NULL)
62959 + break;
62960 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
62961 + kfree(s->obj_hash);
62962 + else
62963 + vfree(s->obj_hash);
62964 + FOR_EACH_NESTED_SUBJECT_END(s)
62965 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
62966 + kfree(r->subj_hash);
62967 + else
62968 + vfree(r->subj_hash);
62969 + r->subj_hash = NULL;
62970 +next_role:
62971 + FOR_EACH_ROLE_END(r)
62972 +
62973 + acl_free_all();
62974 +
62975 + if (acl_role_set.r_hash) {
62976 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
62977 + PAGE_SIZE)
62978 + kfree(acl_role_set.r_hash);
62979 + else
62980 + vfree(acl_role_set.r_hash);
62981 + }
62982 + if (name_set.n_hash) {
62983 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
62984 + PAGE_SIZE)
62985 + kfree(name_set.n_hash);
62986 + else
62987 + vfree(name_set.n_hash);
62988 + }
62989 +
62990 + if (inodev_set.i_hash) {
62991 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
62992 + PAGE_SIZE)
62993 + kfree(inodev_set.i_hash);
62994 + else
62995 + vfree(inodev_set.i_hash);
62996 + }
62997 +
62998 + gr_free_uidset();
62999 +
63000 + memset(&name_set, 0, sizeof (struct name_db));
63001 + memset(&inodev_set, 0, sizeof (struct inodev_db));
63002 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
63003 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
63004 +
63005 + default_role = NULL;
63006 + kernel_role = NULL;
63007 + role_list = NULL;
63008 +
63009 + return;
63010 +}
63011 +
63012 +static struct acl_subject_label *
63013 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
63014 +
63015 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
63016 +{
63017 + unsigned int len = strnlen_user(*name, maxlen);
63018 + char *tmp;
63019 +
63020 + if (!len || len >= maxlen)
63021 + return -EINVAL;
63022 +
63023 + if ((tmp = (char *) acl_alloc(len)) == NULL)
63024 + return -ENOMEM;
63025 +
63026 + if (copy_from_user(tmp, *name, len))
63027 + return -EFAULT;
63028 +
63029 + tmp[len-1] = '\0';
63030 + *name = tmp;
63031 +
63032 + return 0;
63033 +}
63034 +
63035 +static int
63036 +copy_user_glob(struct acl_object_label *obj)
63037 +{
63038 + struct acl_object_label *g_tmp, **guser;
63039 + int error;
63040 +
63041 + if (obj->globbed == NULL)
63042 + return 0;
63043 +
63044 + guser = &obj->globbed;
63045 + while (*guser) {
63046 + g_tmp = (struct acl_object_label *)
63047 + acl_alloc(sizeof (struct acl_object_label));
63048 + if (g_tmp == NULL)
63049 + return -ENOMEM;
63050 +
63051 + if (copy_acl_object_label(g_tmp, *guser))
63052 + return -EFAULT;
63053 +
63054 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
63055 + if (error)
63056 + return error;
63057 +
63058 + *guser = g_tmp;
63059 + guser = &(g_tmp->next);
63060 + }
63061 +
63062 + return 0;
63063 +}
63064 +
63065 +static int
63066 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
63067 + struct acl_role_label *role)
63068 +{
63069 + struct acl_object_label *o_tmp;
63070 + int ret;
63071 +
63072 + while (userp) {
63073 + if ((o_tmp = (struct acl_object_label *)
63074 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
63075 + return -ENOMEM;
63076 +
63077 + if (copy_acl_object_label(o_tmp, userp))
63078 + return -EFAULT;
63079 +
63080 + userp = o_tmp->prev;
63081 +
63082 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
63083 + if (ret)
63084 + return ret;
63085 +
63086 + insert_acl_obj_label(o_tmp, subj);
63087 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
63088 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
63089 + return -ENOMEM;
63090 +
63091 + ret = copy_user_glob(o_tmp);
63092 + if (ret)
63093 + return ret;
63094 +
63095 + if (o_tmp->nested) {
63096 + int already_copied;
63097 +
63098 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
63099 + if (IS_ERR(o_tmp->nested))
63100 + return PTR_ERR(o_tmp->nested);
63101 +
63102 + /* insert into nested subject list if we haven't copied this one yet
63103 + to prevent duplicate entries */
63104 + if (!already_copied) {
63105 + o_tmp->nested->next = role->hash->first;
63106 + role->hash->first = o_tmp->nested;
63107 + }
63108 + }
63109 + }
63110 +
63111 + return 0;
63112 +}
63113 +
63114 +static __u32
63115 +count_user_subjs(struct acl_subject_label *userp)
63116 +{
63117 + struct acl_subject_label s_tmp;
63118 + __u32 num = 0;
63119 +
63120 + while (userp) {
63121 + if (copy_acl_subject_label(&s_tmp, userp))
63122 + break;
63123 +
63124 + userp = s_tmp.prev;
63125 + }
63126 +
63127 + return num;
63128 +}
63129 +
63130 +static int
63131 +copy_user_allowedips(struct acl_role_label *rolep)
63132 +{
63133 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
63134 +
63135 + ruserip = rolep->allowed_ips;
63136 +
63137 + while (ruserip) {
63138 + rlast = rtmp;
63139 +
63140 + if ((rtmp = (struct role_allowed_ip *)
63141 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
63142 + return -ENOMEM;
63143 +
63144 + if (copy_role_allowed_ip(rtmp, ruserip))
63145 + return -EFAULT;
63146 +
63147 + ruserip = rtmp->prev;
63148 +
63149 + if (!rlast) {
63150 + rtmp->prev = NULL;
63151 + rolep->allowed_ips = rtmp;
63152 + } else {
63153 + rlast->next = rtmp;
63154 + rtmp->prev = rlast;
63155 + }
63156 +
63157 + if (!ruserip)
63158 + rtmp->next = NULL;
63159 + }
63160 +
63161 + return 0;
63162 +}
63163 +
63164 +static int
63165 +copy_user_transitions(struct acl_role_label *rolep)
63166 +{
63167 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
63168 + int error;
63169 +
63170 + rusertp = rolep->transitions;
63171 +
63172 + while (rusertp) {
63173 + rlast = rtmp;
63174 +
63175 + if ((rtmp = (struct role_transition *)
63176 + acl_alloc(sizeof (struct role_transition))) == NULL)
63177 + return -ENOMEM;
63178 +
63179 + if (copy_role_transition(rtmp, rusertp))
63180 + return -EFAULT;
63181 +
63182 + rusertp = rtmp->prev;
63183 +
63184 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
63185 + if (error)
63186 + return error;
63187 +
63188 + if (!rlast) {
63189 + rtmp->prev = NULL;
63190 + rolep->transitions = rtmp;
63191 + } else {
63192 + rlast->next = rtmp;
63193 + rtmp->prev = rlast;
63194 + }
63195 +
63196 + if (!rusertp)
63197 + rtmp->next = NULL;
63198 + }
63199 +
63200 + return 0;
63201 +}
63202 +
63203 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
63204 +{
63205 + struct acl_object_label o_tmp;
63206 + __u32 num = 0;
63207 +
63208 + while (userp) {
63209 + if (copy_acl_object_label(&o_tmp, userp))
63210 + break;
63211 +
63212 + userp = o_tmp.prev;
63213 + num++;
63214 + }
63215 +
63216 + return num;
63217 +}
63218 +
63219 +static struct acl_subject_label *
63220 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
63221 +{
63222 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
63223 + __u32 num_objs;
63224 + struct acl_ip_label **i_tmp, *i_utmp2;
63225 + struct gr_hash_struct ghash;
63226 + struct subject_map *subjmap;
63227 + unsigned int i_num;
63228 + int err;
63229 +
63230 + if (already_copied != NULL)
63231 + *already_copied = 0;
63232 +
63233 + s_tmp = lookup_subject_map(userp);
63234 +
63235 + /* we've already copied this subject into the kernel, just return
63236 + the reference to it, and don't copy it over again
63237 + */
63238 + if (s_tmp) {
63239 + if (already_copied != NULL)
63240 + *already_copied = 1;
63241 + return(s_tmp);
63242 + }
63243 +
63244 + if ((s_tmp = (struct acl_subject_label *)
63245 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
63246 + return ERR_PTR(-ENOMEM);
63247 +
63248 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
63249 + if (subjmap == NULL)
63250 + return ERR_PTR(-ENOMEM);
63251 +
63252 + subjmap->user = userp;
63253 + subjmap->kernel = s_tmp;
63254 + insert_subj_map_entry(subjmap);
63255 +
63256 + if (copy_acl_subject_label(s_tmp, userp))
63257 + return ERR_PTR(-EFAULT);
63258 +
63259 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
63260 + if (err)
63261 + return ERR_PTR(err);
63262 +
63263 + if (!strcmp(s_tmp->filename, "/"))
63264 + role->root_label = s_tmp;
63265 +
63266 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
63267 + return ERR_PTR(-EFAULT);
63268 +
63269 + /* copy user and group transition tables */
63270 +
63271 + if (s_tmp->user_trans_num) {
63272 + uid_t *uidlist;
63273 +
63274 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
63275 + if (uidlist == NULL)
63276 + return ERR_PTR(-ENOMEM);
63277 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
63278 + return ERR_PTR(-EFAULT);
63279 +
63280 + s_tmp->user_transitions = uidlist;
63281 + }
63282 +
63283 + if (s_tmp->group_trans_num) {
63284 + gid_t *gidlist;
63285 +
63286 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
63287 + if (gidlist == NULL)
63288 + return ERR_PTR(-ENOMEM);
63289 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
63290 + return ERR_PTR(-EFAULT);
63291 +
63292 + s_tmp->group_transitions = gidlist;
63293 + }
63294 +
63295 + /* set up object hash table */
63296 + num_objs = count_user_objs(ghash.first);
63297 +
63298 + s_tmp->obj_hash_size = num_objs;
63299 + s_tmp->obj_hash =
63300 + (struct acl_object_label **)
63301 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
63302 +
63303 + if (!s_tmp->obj_hash)
63304 + return ERR_PTR(-ENOMEM);
63305 +
63306 + memset(s_tmp->obj_hash, 0,
63307 + s_tmp->obj_hash_size *
63308 + sizeof (struct acl_object_label *));
63309 +
63310 + /* add in objects */
63311 + err = copy_user_objs(ghash.first, s_tmp, role);
63312 +
63313 + if (err)
63314 + return ERR_PTR(err);
63315 +
63316 + /* set pointer for parent subject */
63317 + if (s_tmp->parent_subject) {
63318 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
63319 +
63320 + if (IS_ERR(s_tmp2))
63321 + return s_tmp2;
63322 +
63323 + s_tmp->parent_subject = s_tmp2;
63324 + }
63325 +
63326 + /* add in ip acls */
63327 +
63328 + if (!s_tmp->ip_num) {
63329 + s_tmp->ips = NULL;
63330 + goto insert;
63331 + }
63332 +
63333 + i_tmp =
63334 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
63335 + sizeof (struct acl_ip_label *));
63336 +
63337 + if (!i_tmp)
63338 + return ERR_PTR(-ENOMEM);
63339 +
63340 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
63341 + *(i_tmp + i_num) =
63342 + (struct acl_ip_label *)
63343 + acl_alloc(sizeof (struct acl_ip_label));
63344 + if (!*(i_tmp + i_num))
63345 + return ERR_PTR(-ENOMEM);
63346 +
63347 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
63348 + return ERR_PTR(-EFAULT);
63349 +
63350 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
63351 + return ERR_PTR(-EFAULT);
63352 +
63353 + if ((*(i_tmp + i_num))->iface == NULL)
63354 + continue;
63355 +
63356 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
63357 + if (err)
63358 + return ERR_PTR(err);
63359 + }
63360 +
63361 + s_tmp->ips = i_tmp;
63362 +
63363 +insert:
63364 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
63365 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
63366 + return ERR_PTR(-ENOMEM);
63367 +
63368 + return s_tmp;
63369 +}
63370 +
63371 +static int
63372 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
63373 +{
63374 + struct acl_subject_label s_pre;
63375 + struct acl_subject_label * ret;
63376 + int err;
63377 +
63378 + while (userp) {
63379 + if (copy_acl_subject_label(&s_pre, userp))
63380 + return -EFAULT;
63381 +
63382 + ret = do_copy_user_subj(userp, role, NULL);
63383 +
63384 + err = PTR_ERR(ret);
63385 + if (IS_ERR(ret))
63386 + return err;
63387 +
63388 + insert_acl_subj_label(ret, role);
63389 +
63390 + userp = s_pre.prev;
63391 + }
63392 +
63393 + return 0;
63394 +}
63395 +
63396 +static int
63397 +copy_user_acl(struct gr_arg *arg)
63398 +{
63399 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
63400 + struct acl_subject_label *subj_list;
63401 + struct sprole_pw *sptmp;
63402 + struct gr_hash_struct *ghash;
63403 + uid_t *domainlist;
63404 + unsigned int r_num;
63405 + int err = 0;
63406 + __u16 i;
63407 + __u32 num_subjs;
63408 +
63409 + /* we need a default and kernel role */
63410 + if (arg->role_db.num_roles < 2)
63411 + return -EINVAL;
63412 +
63413 + /* copy special role authentication info from userspace */
63414 +
63415 + num_sprole_pws = arg->num_sprole_pws;
63416 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
63417 +
63418 + if (!acl_special_roles && num_sprole_pws)
63419 + return -ENOMEM;
63420 +
63421 + for (i = 0; i < num_sprole_pws; i++) {
63422 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
63423 + if (!sptmp)
63424 + return -ENOMEM;
63425 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
63426 + return -EFAULT;
63427 +
63428 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
63429 + if (err)
63430 + return err;
63431 +
63432 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63433 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
63434 +#endif
63435 +
63436 + acl_special_roles[i] = sptmp;
63437 + }
63438 +
63439 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
63440 +
63441 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
63442 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
63443 +
63444 + if (!r_tmp)
63445 + return -ENOMEM;
63446 +
63447 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
63448 + return -EFAULT;
63449 +
63450 + if (copy_acl_role_label(r_tmp, r_utmp2))
63451 + return -EFAULT;
63452 +
63453 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
63454 + if (err)
63455 + return err;
63456 +
63457 + if (!strcmp(r_tmp->rolename, "default")
63458 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
63459 + default_role = r_tmp;
63460 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
63461 + kernel_role = r_tmp;
63462 + }
63463 +
63464 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
63465 + return -ENOMEM;
63466 +
63467 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
63468 + return -EFAULT;
63469 +
63470 + r_tmp->hash = ghash;
63471 +
63472 + num_subjs = count_user_subjs(r_tmp->hash->first);
63473 +
63474 + r_tmp->subj_hash_size = num_subjs;
63475 + r_tmp->subj_hash =
63476 + (struct acl_subject_label **)
63477 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
63478 +
63479 + if (!r_tmp->subj_hash)
63480 + return -ENOMEM;
63481 +
63482 + err = copy_user_allowedips(r_tmp);
63483 + if (err)
63484 + return err;
63485 +
63486 + /* copy domain info */
63487 + if (r_tmp->domain_children != NULL) {
63488 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
63489 + if (domainlist == NULL)
63490 + return -ENOMEM;
63491 +
63492 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
63493 + return -EFAULT;
63494 +
63495 + r_tmp->domain_children = domainlist;
63496 + }
63497 +
63498 + err = copy_user_transitions(r_tmp);
63499 + if (err)
63500 + return err;
63501 +
63502 + memset(r_tmp->subj_hash, 0,
63503 + r_tmp->subj_hash_size *
63504 + sizeof (struct acl_subject_label *));
63505 +
63506 + /* acquire the list of subjects, then NULL out
63507 + the list prior to parsing the subjects for this role,
63508 + as during this parsing the list is replaced with a list
63509 + of *nested* subjects for the role
63510 + */
63511 + subj_list = r_tmp->hash->first;
63512 +
63513 + /* set nested subject list to null */
63514 + r_tmp->hash->first = NULL;
63515 +
63516 + err = copy_user_subjs(subj_list, r_tmp);
63517 +
63518 + if (err)
63519 + return err;
63520 +
63521 + insert_acl_role_label(r_tmp);
63522 + }
63523 +
63524 + if (default_role == NULL || kernel_role == NULL)
63525 + return -EINVAL;
63526 +
63527 + return err;
63528 +}
63529 +
63530 +static int
63531 +gracl_init(struct gr_arg *args)
63532 +{
63533 + int error = 0;
63534 +
63535 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
63536 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
63537 +
63538 + if (init_variables(args)) {
63539 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
63540 + error = -ENOMEM;
63541 + free_variables();
63542 + goto out;
63543 + }
63544 +
63545 + error = copy_user_acl(args);
63546 + free_init_variables();
63547 + if (error) {
63548 + free_variables();
63549 + goto out;
63550 + }
63551 +
63552 + if ((error = gr_set_acls(0))) {
63553 + free_variables();
63554 + goto out;
63555 + }
63556 +
63557 + pax_open_kernel();
63558 + gr_status |= GR_READY;
63559 + pax_close_kernel();
63560 +
63561 + out:
63562 + return error;
63563 +}
63564 +
63565 +/* derived from glibc fnmatch() 0: match, 1: no match*/
63566 +
63567 +static int
63568 +glob_match(const char *p, const char *n)
63569 +{
63570 + char c;
63571 +
63572 + while ((c = *p++) != '\0') {
63573 + switch (c) {
63574 + case '?':
63575 + if (*n == '\0')
63576 + return 1;
63577 + else if (*n == '/')
63578 + return 1;
63579 + break;
63580 + case '\\':
63581 + if (*n != c)
63582 + return 1;
63583 + break;
63584 + case '*':
63585 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
63586 + if (*n == '/')
63587 + return 1;
63588 + else if (c == '?') {
63589 + if (*n == '\0')
63590 + return 1;
63591 + else
63592 + ++n;
63593 + }
63594 + }
63595 + if (c == '\0') {
63596 + return 0;
63597 + } else {
63598 + const char *endp;
63599 +
63600 + if ((endp = strchr(n, '/')) == NULL)
63601 + endp = n + strlen(n);
63602 +
63603 + if (c == '[') {
63604 + for (--p; n < endp; ++n)
63605 + if (!glob_match(p, n))
63606 + return 0;
63607 + } else if (c == '/') {
63608 + while (*n != '\0' && *n != '/')
63609 + ++n;
63610 + if (*n == '/' && !glob_match(p, n + 1))
63611 + return 0;
63612 + } else {
63613 + for (--p; n < endp; ++n)
63614 + if (*n == c && !glob_match(p, n))
63615 + return 0;
63616 + }
63617 +
63618 + return 1;
63619 + }
63620 + case '[':
63621 + {
63622 + int not;
63623 + char cold;
63624 +
63625 + if (*n == '\0' || *n == '/')
63626 + return 1;
63627 +
63628 + not = (*p == '!' || *p == '^');
63629 + if (not)
63630 + ++p;
63631 +
63632 + c = *p++;
63633 + for (;;) {
63634 + unsigned char fn = (unsigned char)*n;
63635 +
63636 + if (c == '\0')
63637 + return 1;
63638 + else {
63639 + if (c == fn)
63640 + goto matched;
63641 + cold = c;
63642 + c = *p++;
63643 +
63644 + if (c == '-' && *p != ']') {
63645 + unsigned char cend = *p++;
63646 +
63647 + if (cend == '\0')
63648 + return 1;
63649 +
63650 + if (cold <= fn && fn <= cend)
63651 + goto matched;
63652 +
63653 + c = *p++;
63654 + }
63655 + }
63656 +
63657 + if (c == ']')
63658 + break;
63659 + }
63660 + if (!not)
63661 + return 1;
63662 + break;
63663 + matched:
63664 + while (c != ']') {
63665 + if (c == '\0')
63666 + return 1;
63667 +
63668 + c = *p++;
63669 + }
63670 + if (not)
63671 + return 1;
63672 + }
63673 + break;
63674 + default:
63675 + if (c != *n)
63676 + return 1;
63677 + }
63678 +
63679 + ++n;
63680 + }
63681 +
63682 + if (*n == '\0')
63683 + return 0;
63684 +
63685 + if (*n == '/')
63686 + return 0;
63687 +
63688 + return 1;
63689 +}
63690 +
63691 +static struct acl_object_label *
63692 +chk_glob_label(struct acl_object_label *globbed,
63693 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
63694 +{
63695 + struct acl_object_label *tmp;
63696 +
63697 + if (*path == NULL)
63698 + *path = gr_to_filename_nolock(dentry, mnt);
63699 +
63700 + tmp = globbed;
63701 +
63702 + while (tmp) {
63703 + if (!glob_match(tmp->filename, *path))
63704 + return tmp;
63705 + tmp = tmp->next;
63706 + }
63707 +
63708 + return NULL;
63709 +}
63710 +
63711 +static struct acl_object_label *
63712 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63713 + const ino_t curr_ino, const dev_t curr_dev,
63714 + const struct acl_subject_label *subj, char **path, const int checkglob)
63715 +{
63716 + struct acl_subject_label *tmpsubj;
63717 + struct acl_object_label *retval;
63718 + struct acl_object_label *retval2;
63719 +
63720 + tmpsubj = (struct acl_subject_label *) subj;
63721 + read_lock(&gr_inode_lock);
63722 + do {
63723 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
63724 + if (retval) {
63725 + if (checkglob && retval->globbed) {
63726 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
63727 + if (retval2)
63728 + retval = retval2;
63729 + }
63730 + break;
63731 + }
63732 + } while ((tmpsubj = tmpsubj->parent_subject));
63733 + read_unlock(&gr_inode_lock);
63734 +
63735 + return retval;
63736 +}
63737 +
63738 +static __inline__ struct acl_object_label *
63739 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63740 + struct dentry *curr_dentry,
63741 + const struct acl_subject_label *subj, char **path, const int checkglob)
63742 +{
63743 + int newglob = checkglob;
63744 + ino_t inode;
63745 + dev_t device;
63746 +
63747 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
63748 + as we don't want a / * rule to match instead of the / object
63749 + don't do this for create lookups that call this function though, since they're looking up
63750 + on the parent and thus need globbing checks on all paths
63751 + */
63752 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
63753 + newglob = GR_NO_GLOB;
63754 +
63755 + spin_lock(&curr_dentry->d_lock);
63756 + inode = curr_dentry->d_inode->i_ino;
63757 + device = __get_dev(curr_dentry);
63758 + spin_unlock(&curr_dentry->d_lock);
63759 +
63760 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
63761 +}
63762 +
63763 +#ifdef CONFIG_HUGETLBFS
63764 +static inline bool
63765 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
63766 +{
63767 + int i;
63768 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
63769 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
63770 + return true;
63771 + }
63772 +
63773 + return false;
63774 +}
63775 +#endif
63776 +
63777 +static struct acl_object_label *
63778 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63779 + const struct acl_subject_label *subj, char *path, const int checkglob)
63780 +{
63781 + struct dentry *dentry = (struct dentry *) l_dentry;
63782 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63783 + struct mount *real_mnt = real_mount(mnt);
63784 + struct acl_object_label *retval;
63785 + struct dentry *parent;
63786 +
63787 + br_read_lock(&vfsmount_lock);
63788 + write_seqlock(&rename_lock);
63789 +
63790 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
63791 +#ifdef CONFIG_NET
63792 + mnt == sock_mnt ||
63793 +#endif
63794 +#ifdef CONFIG_HUGETLBFS
63795 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
63796 +#endif
63797 + /* ignore Eric Biederman */
63798 + IS_PRIVATE(l_dentry->d_inode))) {
63799 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
63800 + goto out;
63801 + }
63802 +
63803 + for (;;) {
63804 + if (dentry == real_root.dentry && mnt == real_root.mnt)
63805 + break;
63806 +
63807 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
63808 + if (!mnt_has_parent(real_mnt))
63809 + break;
63810 +
63811 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63812 + if (retval != NULL)
63813 + goto out;
63814 +
63815 + dentry = real_mnt->mnt_mountpoint;
63816 + real_mnt = real_mnt->mnt_parent;
63817 + mnt = &real_mnt->mnt;
63818 + continue;
63819 + }
63820 +
63821 + parent = dentry->d_parent;
63822 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63823 + if (retval != NULL)
63824 + goto out;
63825 +
63826 + dentry = parent;
63827 + }
63828 +
63829 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63830 +
63831 + /* real_root is pinned so we don't have to hold a reference */
63832 + if (retval == NULL)
63833 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
63834 +out:
63835 + write_sequnlock(&rename_lock);
63836 + br_read_unlock(&vfsmount_lock);
63837 +
63838 + BUG_ON(retval == NULL);
63839 +
63840 + return retval;
63841 +}
63842 +
63843 +static __inline__ struct acl_object_label *
63844 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63845 + const struct acl_subject_label *subj)
63846 +{
63847 + char *path = NULL;
63848 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
63849 +}
63850 +
63851 +static __inline__ struct acl_object_label *
63852 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63853 + const struct acl_subject_label *subj)
63854 +{
63855 + char *path = NULL;
63856 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
63857 +}
63858 +
63859 +static __inline__ struct acl_object_label *
63860 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63861 + const struct acl_subject_label *subj, char *path)
63862 +{
63863 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
63864 +}
63865 +
63866 +static struct acl_subject_label *
63867 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63868 + const struct acl_role_label *role)
63869 +{
63870 + struct dentry *dentry = (struct dentry *) l_dentry;
63871 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63872 + struct mount *real_mnt = real_mount(mnt);
63873 + struct acl_subject_label *retval;
63874 + struct dentry *parent;
63875 +
63876 + br_read_lock(&vfsmount_lock);
63877 + write_seqlock(&rename_lock);
63878 +
63879 + for (;;) {
63880 + if (dentry == real_root.dentry && mnt == real_root.mnt)
63881 + break;
63882 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
63883 + if (!mnt_has_parent(real_mnt))
63884 + break;
63885 +
63886 + spin_lock(&dentry->d_lock);
63887 + read_lock(&gr_inode_lock);
63888 + retval =
63889 + lookup_acl_subj_label(dentry->d_inode->i_ino,
63890 + __get_dev(dentry), role);
63891 + read_unlock(&gr_inode_lock);
63892 + spin_unlock(&dentry->d_lock);
63893 + if (retval != NULL)
63894 + goto out;
63895 +
63896 + dentry = real_mnt->mnt_mountpoint;
63897 + real_mnt = real_mnt->mnt_parent;
63898 + mnt = &real_mnt->mnt;
63899 + continue;
63900 + }
63901 +
63902 + spin_lock(&dentry->d_lock);
63903 + read_lock(&gr_inode_lock);
63904 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
63905 + __get_dev(dentry), role);
63906 + read_unlock(&gr_inode_lock);
63907 + parent = dentry->d_parent;
63908 + spin_unlock(&dentry->d_lock);
63909 +
63910 + if (retval != NULL)
63911 + goto out;
63912 +
63913 + dentry = parent;
63914 + }
63915 +
63916 + spin_lock(&dentry->d_lock);
63917 + read_lock(&gr_inode_lock);
63918 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
63919 + __get_dev(dentry), role);
63920 + read_unlock(&gr_inode_lock);
63921 + spin_unlock(&dentry->d_lock);
63922 +
63923 + if (unlikely(retval == NULL)) {
63924 + /* real_root is pinned, we don't need to hold a reference */
63925 + read_lock(&gr_inode_lock);
63926 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
63927 + __get_dev(real_root.dentry), role);
63928 + read_unlock(&gr_inode_lock);
63929 + }
63930 +out:
63931 + write_sequnlock(&rename_lock);
63932 + br_read_unlock(&vfsmount_lock);
63933 +
63934 + BUG_ON(retval == NULL);
63935 +
63936 + return retval;
63937 +}
63938 +
63939 +static void
63940 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
63941 +{
63942 + struct task_struct *task = current;
63943 + const struct cred *cred = current_cred();
63944 +
63945 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
63946 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63947 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63948 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
63949 +
63950 + return;
63951 +}
63952 +
63953 +static void
63954 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
63955 +{
63956 + struct task_struct *task = current;
63957 + const struct cred *cred = current_cred();
63958 +
63959 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
63960 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63961 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63962 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
63963 +
63964 + return;
63965 +}
63966 +
63967 +static void
63968 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
63969 +{
63970 + struct task_struct *task = current;
63971 + const struct cred *cred = current_cred();
63972 +
63973 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
63974 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
63975 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
63976 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
63977 +
63978 + return;
63979 +}
63980 +
63981 +__u32
63982 +gr_search_file(const struct dentry * dentry, const __u32 mode,
63983 + const struct vfsmount * mnt)
63984 +{
63985 + __u32 retval = mode;
63986 + struct acl_subject_label *curracl;
63987 + struct acl_object_label *currobj;
63988 +
63989 + if (unlikely(!(gr_status & GR_READY)))
63990 + return (mode & ~GR_AUDITS);
63991 +
63992 + curracl = current->acl;
63993 +
63994 + currobj = chk_obj_label(dentry, mnt, curracl);
63995 + retval = currobj->mode & mode;
63996 +
63997 + /* if we're opening a specified transfer file for writing
63998 + (e.g. /dev/initctl), then transfer our role to init
63999 + */
64000 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64001 + current->role->roletype & GR_ROLE_PERSIST)) {
64002 + struct task_struct *task = init_pid_ns.child_reaper;
64003 +
64004 + if (task->role != current->role) {
64005 + task->acl_sp_role = 0;
64006 + task->acl_role_id = current->acl_role_id;
64007 + task->role = current->role;
64008 + rcu_read_lock();
64009 + read_lock(&grsec_exec_file_lock);
64010 + gr_apply_subject_to_task(task);
64011 + read_unlock(&grsec_exec_file_lock);
64012 + rcu_read_unlock();
64013 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64014 + }
64015 + }
64016 +
64017 + if (unlikely
64018 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64019 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64020 + __u32 new_mode = mode;
64021 +
64022 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64023 +
64024 + retval = new_mode;
64025 +
64026 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64027 + new_mode |= GR_INHERIT;
64028 +
64029 + if (!(mode & GR_NOLEARN))
64030 + gr_log_learn(dentry, mnt, new_mode);
64031 + }
64032 +
64033 + return retval;
64034 +}
64035 +
64036 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64037 + const struct dentry *parent,
64038 + const struct vfsmount *mnt)
64039 +{
64040 + struct name_entry *match;
64041 + struct acl_object_label *matchpo;
64042 + struct acl_subject_label *curracl;
64043 + char *path;
64044 +
64045 + if (unlikely(!(gr_status & GR_READY)))
64046 + return NULL;
64047 +
64048 + preempt_disable();
64049 + path = gr_to_filename_rbac(new_dentry, mnt);
64050 + match = lookup_name_entry_create(path);
64051 +
64052 + curracl = current->acl;
64053 +
64054 + if (match) {
64055 + read_lock(&gr_inode_lock);
64056 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64057 + read_unlock(&gr_inode_lock);
64058 +
64059 + if (matchpo) {
64060 + preempt_enable();
64061 + return matchpo;
64062 + }
64063 + }
64064 +
64065 + // lookup parent
64066 +
64067 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64068 +
64069 + preempt_enable();
64070 + return matchpo;
64071 +}
64072 +
64073 +__u32
64074 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64075 + const struct vfsmount * mnt, const __u32 mode)
64076 +{
64077 + struct acl_object_label *matchpo;
64078 + __u32 retval;
64079 +
64080 + if (unlikely(!(gr_status & GR_READY)))
64081 + return (mode & ~GR_AUDITS);
64082 +
64083 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64084 +
64085 + retval = matchpo->mode & mode;
64086 +
64087 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64088 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64089 + __u32 new_mode = mode;
64090 +
64091 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64092 +
64093 + gr_log_learn(new_dentry, mnt, new_mode);
64094 + return new_mode;
64095 + }
64096 +
64097 + return retval;
64098 +}
64099 +
64100 +__u32
64101 +gr_check_link(const struct dentry * new_dentry,
64102 + const struct dentry * parent_dentry,
64103 + const struct vfsmount * parent_mnt,
64104 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64105 +{
64106 + struct acl_object_label *obj;
64107 + __u32 oldmode, newmode;
64108 + __u32 needmode;
64109 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64110 + GR_DELETE | GR_INHERIT;
64111 +
64112 + if (unlikely(!(gr_status & GR_READY)))
64113 + return (GR_CREATE | GR_LINK);
64114 +
64115 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64116 + oldmode = obj->mode;
64117 +
64118 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64119 + newmode = obj->mode;
64120 +
64121 + needmode = newmode & checkmodes;
64122 +
64123 + // old name for hardlink must have at least the permissions of the new name
64124 + if ((oldmode & needmode) != needmode)
64125 + goto bad;
64126 +
64127 + // if old name had restrictions/auditing, make sure the new name does as well
64128 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64129 +
64130 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64131 + if (is_privileged_binary(old_dentry))
64132 + needmode |= GR_SETID;
64133 +
64134 + if ((newmode & needmode) != needmode)
64135 + goto bad;
64136 +
64137 + // enforce minimum permissions
64138 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64139 + return newmode;
64140 +bad:
64141 + needmode = oldmode;
64142 + if (is_privileged_binary(old_dentry))
64143 + needmode |= GR_SETID;
64144 +
64145 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64146 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64147 + return (GR_CREATE | GR_LINK);
64148 + } else if (newmode & GR_SUPPRESS)
64149 + return GR_SUPPRESS;
64150 + else
64151 + return 0;
64152 +}
64153 +
64154 +int
64155 +gr_check_hidden_task(const struct task_struct *task)
64156 +{
64157 + if (unlikely(!(gr_status & GR_READY)))
64158 + return 0;
64159 +
64160 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64161 + return 1;
64162 +
64163 + return 0;
64164 +}
64165 +
64166 +int
64167 +gr_check_protected_task(const struct task_struct *task)
64168 +{
64169 + if (unlikely(!(gr_status & GR_READY) || !task))
64170 + return 0;
64171 +
64172 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64173 + task->acl != current->acl)
64174 + return 1;
64175 +
64176 + return 0;
64177 +}
64178 +
64179 +int
64180 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64181 +{
64182 + struct task_struct *p;
64183 + int ret = 0;
64184 +
64185 + if (unlikely(!(gr_status & GR_READY) || !pid))
64186 + return ret;
64187 +
64188 + read_lock(&tasklist_lock);
64189 + do_each_pid_task(pid, type, p) {
64190 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64191 + p->acl != current->acl) {
64192 + ret = 1;
64193 + goto out;
64194 + }
64195 + } while_each_pid_task(pid, type, p);
64196 +out:
64197 + read_unlock(&tasklist_lock);
64198 +
64199 + return ret;
64200 +}
64201 +
64202 +void
64203 +gr_copy_label(struct task_struct *tsk)
64204 +{
64205 + tsk->signal->used_accept = 0;
64206 + tsk->acl_sp_role = 0;
64207 + tsk->acl_role_id = current->acl_role_id;
64208 + tsk->acl = current->acl;
64209 + tsk->role = current->role;
64210 + tsk->signal->curr_ip = current->signal->curr_ip;
64211 + tsk->signal->saved_ip = current->signal->saved_ip;
64212 + if (current->exec_file)
64213 + get_file(current->exec_file);
64214 + tsk->exec_file = current->exec_file;
64215 + tsk->is_writable = current->is_writable;
64216 + if (unlikely(current->signal->used_accept)) {
64217 + current->signal->curr_ip = 0;
64218 + current->signal->saved_ip = 0;
64219 + }
64220 +
64221 + return;
64222 +}
64223 +
64224 +static void
64225 +gr_set_proc_res(struct task_struct *task)
64226 +{
64227 + struct acl_subject_label *proc;
64228 + unsigned short i;
64229 +
64230 + proc = task->acl;
64231 +
64232 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64233 + return;
64234 +
64235 + for (i = 0; i < RLIM_NLIMITS; i++) {
64236 + if (!(proc->resmask & (1U << i)))
64237 + continue;
64238 +
64239 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64240 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64241 +
64242 + if (i == RLIMIT_CPU)
64243 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64244 + }
64245 +
64246 + return;
64247 +}
64248 +
64249 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64250 +
64251 +int
64252 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64253 +{
64254 + unsigned int i;
64255 + __u16 num;
64256 + uid_t *uidlist;
64257 + uid_t curuid;
64258 + int realok = 0;
64259 + int effectiveok = 0;
64260 + int fsok = 0;
64261 + uid_t globalreal, globaleffective, globalfs;
64262 +
64263 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64264 + struct user_struct *user;
64265 +
64266 + if (!uid_valid(real))
64267 + goto skipit;
64268 +
64269 + /* find user based on global namespace */
64270 +
64271 + globalreal = GR_GLOBAL_UID(real);
64272 +
64273 + user = find_user(make_kuid(&init_user_ns, globalreal));
64274 + if (user == NULL)
64275 + goto skipit;
64276 +
64277 + if (gr_process_kernel_setuid_ban(user)) {
64278 + /* for find_user */
64279 + free_uid(user);
64280 + return 1;
64281 + }
64282 +
64283 + /* for find_user */
64284 + free_uid(user);
64285 +
64286 +skipit:
64287 +#endif
64288 +
64289 + if (unlikely(!(gr_status & GR_READY)))
64290 + return 0;
64291 +
64292 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64293 + gr_log_learn_uid_change(real, effective, fs);
64294 +
64295 + num = current->acl->user_trans_num;
64296 + uidlist = current->acl->user_transitions;
64297 +
64298 + if (uidlist == NULL)
64299 + return 0;
64300 +
64301 + if (!uid_valid(real)) {
64302 + realok = 1;
64303 + globalreal = (uid_t)-1;
64304 + } else {
64305 + globalreal = GR_GLOBAL_UID(real);
64306 + }
64307 + if (!uid_valid(effective)) {
64308 + effectiveok = 1;
64309 + globaleffective = (uid_t)-1;
64310 + } else {
64311 + globaleffective = GR_GLOBAL_UID(effective);
64312 + }
64313 + if (!uid_valid(fs)) {
64314 + fsok = 1;
64315 + globalfs = (uid_t)-1;
64316 + } else {
64317 + globalfs = GR_GLOBAL_UID(fs);
64318 + }
64319 +
64320 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64321 + for (i = 0; i < num; i++) {
64322 + curuid = uidlist[i];
64323 + if (globalreal == curuid)
64324 + realok = 1;
64325 + if (globaleffective == curuid)
64326 + effectiveok = 1;
64327 + if (globalfs == curuid)
64328 + fsok = 1;
64329 + }
64330 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64331 + for (i = 0; i < num; i++) {
64332 + curuid = uidlist[i];
64333 + if (globalreal == curuid)
64334 + break;
64335 + if (globaleffective == curuid)
64336 + break;
64337 + if (globalfs == curuid)
64338 + break;
64339 + }
64340 + /* not in deny list */
64341 + if (i == num) {
64342 + realok = 1;
64343 + effectiveok = 1;
64344 + fsok = 1;
64345 + }
64346 + }
64347 +
64348 + if (realok && effectiveok && fsok)
64349 + return 0;
64350 + else {
64351 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64352 + return 1;
64353 + }
64354 +}
64355 +
64356 +int
64357 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64358 +{
64359 + unsigned int i;
64360 + __u16 num;
64361 + gid_t *gidlist;
64362 + gid_t curgid;
64363 + int realok = 0;
64364 + int effectiveok = 0;
64365 + int fsok = 0;
64366 + gid_t globalreal, globaleffective, globalfs;
64367 +
64368 + if (unlikely(!(gr_status & GR_READY)))
64369 + return 0;
64370 +
64371 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64372 + gr_log_learn_gid_change(real, effective, fs);
64373 +
64374 + num = current->acl->group_trans_num;
64375 + gidlist = current->acl->group_transitions;
64376 +
64377 + if (gidlist == NULL)
64378 + return 0;
64379 +
64380 + if (!gid_valid(real)) {
64381 + realok = 1;
64382 + globalreal = (gid_t)-1;
64383 + } else {
64384 + globalreal = GR_GLOBAL_GID(real);
64385 + }
64386 + if (!gid_valid(effective)) {
64387 + effectiveok = 1;
64388 + globaleffective = (gid_t)-1;
64389 + } else {
64390 + globaleffective = GR_GLOBAL_GID(effective);
64391 + }
64392 + if (!gid_valid(fs)) {
64393 + fsok = 1;
64394 + globalfs = (gid_t)-1;
64395 + } else {
64396 + globalfs = GR_GLOBAL_GID(fs);
64397 + }
64398 +
64399 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64400 + for (i = 0; i < num; i++) {
64401 + curgid = gidlist[i];
64402 + if (globalreal == curgid)
64403 + realok = 1;
64404 + if (globaleffective == curgid)
64405 + effectiveok = 1;
64406 + if (globalfs == curgid)
64407 + fsok = 1;
64408 + }
64409 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64410 + for (i = 0; i < num; i++) {
64411 + curgid = gidlist[i];
64412 + if (globalreal == curgid)
64413 + break;
64414 + if (globaleffective == curgid)
64415 + break;
64416 + if (globalfs == curgid)
64417 + break;
64418 + }
64419 + /* not in deny list */
64420 + if (i == num) {
64421 + realok = 1;
64422 + effectiveok = 1;
64423 + fsok = 1;
64424 + }
64425 + }
64426 +
64427 + if (realok && effectiveok && fsok)
64428 + return 0;
64429 + else {
64430 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64431 + return 1;
64432 + }
64433 +}
64434 +
64435 +extern int gr_acl_is_capable(const int cap);
64436 +
64437 +void
64438 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64439 +{
64440 + struct acl_role_label *role = task->role;
64441 + struct acl_subject_label *subj = NULL;
64442 + struct acl_object_label *obj;
64443 + struct file *filp;
64444 + uid_t uid;
64445 + gid_t gid;
64446 +
64447 + if (unlikely(!(gr_status & GR_READY)))
64448 + return;
64449 +
64450 + uid = GR_GLOBAL_UID(kuid);
64451 + gid = GR_GLOBAL_GID(kgid);
64452 +
64453 + filp = task->exec_file;
64454 +
64455 + /* kernel process, we'll give them the kernel role */
64456 + if (unlikely(!filp)) {
64457 + task->role = kernel_role;
64458 + task->acl = kernel_role->root_label;
64459 + return;
64460 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
64461 + role = lookup_acl_role_label(task, uid, gid);
64462 +
64463 + /* don't change the role if we're not a privileged process */
64464 + if (role && task->role != role &&
64465 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64466 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64467 + return;
64468 +
64469 + /* perform subject lookup in possibly new role
64470 + we can use this result below in the case where role == task->role
64471 + */
64472 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
64473 +
64474 + /* if we changed uid/gid, but result in the same role
64475 + and are using inheritance, don't lose the inherited subject
64476 + if current subject is other than what normal lookup
64477 + would result in, we arrived via inheritance, don't
64478 + lose subject
64479 + */
64480 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
64481 + (subj == task->acl)))
64482 + task->acl = subj;
64483 +
64484 + task->role = role;
64485 +
64486 + task->is_writable = 0;
64487 +
64488 + /* ignore additional mmap checks for processes that are writable
64489 + by the default ACL */
64490 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64491 + if (unlikely(obj->mode & GR_WRITE))
64492 + task->is_writable = 1;
64493 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64494 + if (unlikely(obj->mode & GR_WRITE))
64495 + task->is_writable = 1;
64496 +
64497 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64498 + 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);
64499 +#endif
64500 +
64501 + gr_set_proc_res(task);
64502 +
64503 + return;
64504 +}
64505 +
64506 +int
64507 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64508 + const int unsafe_flags)
64509 +{
64510 + struct task_struct *task = current;
64511 + struct acl_subject_label *newacl;
64512 + struct acl_object_label *obj;
64513 + __u32 retmode;
64514 +
64515 + if (unlikely(!(gr_status & GR_READY)))
64516 + return 0;
64517 +
64518 + newacl = chk_subj_label(dentry, mnt, task->role);
64519 +
64520 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
64521 + did an exec
64522 + */
64523 + rcu_read_lock();
64524 + read_lock(&tasklist_lock);
64525 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
64526 + (task->parent->acl->mode & GR_POVERRIDE))) {
64527 + read_unlock(&tasklist_lock);
64528 + rcu_read_unlock();
64529 + goto skip_check;
64530 + }
64531 + read_unlock(&tasklist_lock);
64532 + rcu_read_unlock();
64533 +
64534 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
64535 + !(task->role->roletype & GR_ROLE_GOD) &&
64536 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
64537 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64538 + if (unsafe_flags & LSM_UNSAFE_SHARE)
64539 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
64540 + else
64541 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
64542 + return -EACCES;
64543 + }
64544 +
64545 +skip_check:
64546 +
64547 + obj = chk_obj_label(dentry, mnt, task->acl);
64548 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
64549 +
64550 + if (!(task->acl->mode & GR_INHERITLEARN) &&
64551 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
64552 + if (obj->nested)
64553 + task->acl = obj->nested;
64554 + else
64555 + task->acl = newacl;
64556 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
64557 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
64558 +
64559 + task->is_writable = 0;
64560 +
64561 + /* ignore additional mmap checks for processes that are writable
64562 + by the default ACL */
64563 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
64564 + if (unlikely(obj->mode & GR_WRITE))
64565 + task->is_writable = 1;
64566 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
64567 + if (unlikely(obj->mode & GR_WRITE))
64568 + task->is_writable = 1;
64569 +
64570 + gr_set_proc_res(task);
64571 +
64572 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64573 + 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);
64574 +#endif
64575 + return 0;
64576 +}
64577 +
64578 +/* always called with valid inodev ptr */
64579 +static void
64580 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
64581 +{
64582 + struct acl_object_label *matchpo;
64583 + struct acl_subject_label *matchps;
64584 + struct acl_subject_label *subj;
64585 + struct acl_role_label *role;
64586 + unsigned int x;
64587 +
64588 + FOR_EACH_ROLE_START(role)
64589 + FOR_EACH_SUBJECT_START(role, subj, x)
64590 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64591 + matchpo->mode |= GR_DELETED;
64592 + FOR_EACH_SUBJECT_END(subj,x)
64593 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64594 + /* nested subjects aren't in the role's subj_hash table */
64595 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64596 + matchpo->mode |= GR_DELETED;
64597 + FOR_EACH_NESTED_SUBJECT_END(subj)
64598 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
64599 + matchps->mode |= GR_DELETED;
64600 + FOR_EACH_ROLE_END(role)
64601 +
64602 + inodev->nentry->deleted = 1;
64603 +
64604 + return;
64605 +}
64606 +
64607 +void
64608 +gr_handle_delete(const ino_t ino, const dev_t dev)
64609 +{
64610 + struct inodev_entry *inodev;
64611 +
64612 + if (unlikely(!(gr_status & GR_READY)))
64613 + return;
64614 +
64615 + write_lock(&gr_inode_lock);
64616 + inodev = lookup_inodev_entry(ino, dev);
64617 + if (inodev != NULL)
64618 + do_handle_delete(inodev, ino, dev);
64619 + write_unlock(&gr_inode_lock);
64620 +
64621 + return;
64622 +}
64623 +
64624 +static void
64625 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
64626 + const ino_t newinode, const dev_t newdevice,
64627 + struct acl_subject_label *subj)
64628 +{
64629 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
64630 + struct acl_object_label *match;
64631 +
64632 + match = subj->obj_hash[index];
64633 +
64634 + while (match && (match->inode != oldinode ||
64635 + match->device != olddevice ||
64636 + !(match->mode & GR_DELETED)))
64637 + match = match->next;
64638 +
64639 + if (match && (match->inode == oldinode)
64640 + && (match->device == olddevice)
64641 + && (match->mode & GR_DELETED)) {
64642 + if (match->prev == NULL) {
64643 + subj->obj_hash[index] = match->next;
64644 + if (match->next != NULL)
64645 + match->next->prev = NULL;
64646 + } else {
64647 + match->prev->next = match->next;
64648 + if (match->next != NULL)
64649 + match->next->prev = match->prev;
64650 + }
64651 + match->prev = NULL;
64652 + match->next = NULL;
64653 + match->inode = newinode;
64654 + match->device = newdevice;
64655 + match->mode &= ~GR_DELETED;
64656 +
64657 + insert_acl_obj_label(match, subj);
64658 + }
64659 +
64660 + return;
64661 +}
64662 +
64663 +static void
64664 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
64665 + const ino_t newinode, const dev_t newdevice,
64666 + struct acl_role_label *role)
64667 +{
64668 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
64669 + struct acl_subject_label *match;
64670 +
64671 + match = role->subj_hash[index];
64672 +
64673 + while (match && (match->inode != oldinode ||
64674 + match->device != olddevice ||
64675 + !(match->mode & GR_DELETED)))
64676 + match = match->next;
64677 +
64678 + if (match && (match->inode == oldinode)
64679 + && (match->device == olddevice)
64680 + && (match->mode & GR_DELETED)) {
64681 + if (match->prev == NULL) {
64682 + role->subj_hash[index] = match->next;
64683 + if (match->next != NULL)
64684 + match->next->prev = NULL;
64685 + } else {
64686 + match->prev->next = match->next;
64687 + if (match->next != NULL)
64688 + match->next->prev = match->prev;
64689 + }
64690 + match->prev = NULL;
64691 + match->next = NULL;
64692 + match->inode = newinode;
64693 + match->device = newdevice;
64694 + match->mode &= ~GR_DELETED;
64695 +
64696 + insert_acl_subj_label(match, role);
64697 + }
64698 +
64699 + return;
64700 +}
64701 +
64702 +static void
64703 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
64704 + const ino_t newinode, const dev_t newdevice)
64705 +{
64706 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
64707 + struct inodev_entry *match;
64708 +
64709 + match = inodev_set.i_hash[index];
64710 +
64711 + while (match && (match->nentry->inode != oldinode ||
64712 + match->nentry->device != olddevice || !match->nentry->deleted))
64713 + match = match->next;
64714 +
64715 + if (match && (match->nentry->inode == oldinode)
64716 + && (match->nentry->device == olddevice) &&
64717 + match->nentry->deleted) {
64718 + if (match->prev == NULL) {
64719 + inodev_set.i_hash[index] = match->next;
64720 + if (match->next != NULL)
64721 + match->next->prev = NULL;
64722 + } else {
64723 + match->prev->next = match->next;
64724 + if (match->next != NULL)
64725 + match->next->prev = match->prev;
64726 + }
64727 + match->prev = NULL;
64728 + match->next = NULL;
64729 + match->nentry->inode = newinode;
64730 + match->nentry->device = newdevice;
64731 + match->nentry->deleted = 0;
64732 +
64733 + insert_inodev_entry(match);
64734 + }
64735 +
64736 + return;
64737 +}
64738 +
64739 +static void
64740 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
64741 +{
64742 + struct acl_subject_label *subj;
64743 + struct acl_role_label *role;
64744 + unsigned int x;
64745 +
64746 + FOR_EACH_ROLE_START(role)
64747 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
64748 +
64749 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64750 + if ((subj->inode == ino) && (subj->device == dev)) {
64751 + subj->inode = ino;
64752 + subj->device = dev;
64753 + }
64754 + /* nested subjects aren't in the role's subj_hash table */
64755 + update_acl_obj_label(matchn->inode, matchn->device,
64756 + ino, dev, subj);
64757 + FOR_EACH_NESTED_SUBJECT_END(subj)
64758 + FOR_EACH_SUBJECT_START(role, subj, x)
64759 + update_acl_obj_label(matchn->inode, matchn->device,
64760 + ino, dev, subj);
64761 + FOR_EACH_SUBJECT_END(subj,x)
64762 + FOR_EACH_ROLE_END(role)
64763 +
64764 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
64765 +
64766 + return;
64767 +}
64768 +
64769 +static void
64770 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
64771 + const struct vfsmount *mnt)
64772 +{
64773 + ino_t ino = dentry->d_inode->i_ino;
64774 + dev_t dev = __get_dev(dentry);
64775 +
64776 + __do_handle_create(matchn, ino, dev);
64777 +
64778 + return;
64779 +}
64780 +
64781 +void
64782 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64783 +{
64784 + struct name_entry *matchn;
64785 +
64786 + if (unlikely(!(gr_status & GR_READY)))
64787 + return;
64788 +
64789 + preempt_disable();
64790 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
64791 +
64792 + if (unlikely((unsigned long)matchn)) {
64793 + write_lock(&gr_inode_lock);
64794 + do_handle_create(matchn, dentry, mnt);
64795 + write_unlock(&gr_inode_lock);
64796 + }
64797 + preempt_enable();
64798 +
64799 + return;
64800 +}
64801 +
64802 +void
64803 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64804 +{
64805 + struct name_entry *matchn;
64806 +
64807 + if (unlikely(!(gr_status & GR_READY)))
64808 + return;
64809 +
64810 + preempt_disable();
64811 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
64812 +
64813 + if (unlikely((unsigned long)matchn)) {
64814 + write_lock(&gr_inode_lock);
64815 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
64816 + write_unlock(&gr_inode_lock);
64817 + }
64818 + preempt_enable();
64819 +
64820 + return;
64821 +}
64822 +
64823 +void
64824 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64825 + struct dentry *old_dentry,
64826 + struct dentry *new_dentry,
64827 + struct vfsmount *mnt, const __u8 replace)
64828 +{
64829 + struct name_entry *matchn;
64830 + struct inodev_entry *inodev;
64831 + struct inode *inode = new_dentry->d_inode;
64832 + ino_t old_ino = old_dentry->d_inode->i_ino;
64833 + dev_t old_dev = __get_dev(old_dentry);
64834 +
64835 + /* vfs_rename swaps the name and parent link for old_dentry and
64836 + new_dentry
64837 + at this point, old_dentry has the new name, parent link, and inode
64838 + for the renamed file
64839 + if a file is being replaced by a rename, new_dentry has the inode
64840 + and name for the replaced file
64841 + */
64842 +
64843 + if (unlikely(!(gr_status & GR_READY)))
64844 + return;
64845 +
64846 + preempt_disable();
64847 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
64848 +
64849 + /* we wouldn't have to check d_inode if it weren't for
64850 + NFS silly-renaming
64851 + */
64852 +
64853 + write_lock(&gr_inode_lock);
64854 + if (unlikely(replace && inode)) {
64855 + ino_t new_ino = inode->i_ino;
64856 + dev_t new_dev = __get_dev(new_dentry);
64857 +
64858 + inodev = lookup_inodev_entry(new_ino, new_dev);
64859 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
64860 + do_handle_delete(inodev, new_ino, new_dev);
64861 + }
64862 +
64863 + inodev = lookup_inodev_entry(old_ino, old_dev);
64864 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
64865 + do_handle_delete(inodev, old_ino, old_dev);
64866 +
64867 + if (unlikely((unsigned long)matchn))
64868 + do_handle_create(matchn, old_dentry, mnt);
64869 +
64870 + write_unlock(&gr_inode_lock);
64871 + preempt_enable();
64872 +
64873 + return;
64874 +}
64875 +
64876 +static int
64877 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
64878 + unsigned char **sum)
64879 +{
64880 + struct acl_role_label *r;
64881 + struct role_allowed_ip *ipp;
64882 + struct role_transition *trans;
64883 + unsigned int i;
64884 + int found = 0;
64885 + u32 curr_ip = current->signal->curr_ip;
64886 +
64887 + current->signal->saved_ip = curr_ip;
64888 +
64889 + /* check transition table */
64890 +
64891 + for (trans = current->role->transitions; trans; trans = trans->next) {
64892 + if (!strcmp(rolename, trans->rolename)) {
64893 + found = 1;
64894 + break;
64895 + }
64896 + }
64897 +
64898 + if (!found)
64899 + return 0;
64900 +
64901 + /* handle special roles that do not require authentication
64902 + and check ip */
64903 +
64904 + FOR_EACH_ROLE_START(r)
64905 + if (!strcmp(rolename, r->rolename) &&
64906 + (r->roletype & GR_ROLE_SPECIAL)) {
64907 + found = 0;
64908 + if (r->allowed_ips != NULL) {
64909 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
64910 + if ((ntohl(curr_ip) & ipp->netmask) ==
64911 + (ntohl(ipp->addr) & ipp->netmask))
64912 + found = 1;
64913 + }
64914 + } else
64915 + found = 2;
64916 + if (!found)
64917 + return 0;
64918 +
64919 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
64920 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
64921 + *salt = NULL;
64922 + *sum = NULL;
64923 + return 1;
64924 + }
64925 + }
64926 + FOR_EACH_ROLE_END(r)
64927 +
64928 + for (i = 0; i < num_sprole_pws; i++) {
64929 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
64930 + *salt = acl_special_roles[i]->salt;
64931 + *sum = acl_special_roles[i]->sum;
64932 + return 1;
64933 + }
64934 + }
64935 +
64936 + return 0;
64937 +}
64938 +
64939 +static void
64940 +assign_special_role(char *rolename)
64941 +{
64942 + struct acl_object_label *obj;
64943 + struct acl_role_label *r;
64944 + struct acl_role_label *assigned = NULL;
64945 + struct task_struct *tsk;
64946 + struct file *filp;
64947 +
64948 + FOR_EACH_ROLE_START(r)
64949 + if (!strcmp(rolename, r->rolename) &&
64950 + (r->roletype & GR_ROLE_SPECIAL)) {
64951 + assigned = r;
64952 + break;
64953 + }
64954 + FOR_EACH_ROLE_END(r)
64955 +
64956 + if (!assigned)
64957 + return;
64958 +
64959 + read_lock(&tasklist_lock);
64960 + read_lock(&grsec_exec_file_lock);
64961 +
64962 + tsk = current->real_parent;
64963 + if (tsk == NULL)
64964 + goto out_unlock;
64965 +
64966 + filp = tsk->exec_file;
64967 + if (filp == NULL)
64968 + goto out_unlock;
64969 +
64970 + tsk->is_writable = 0;
64971 +
64972 + tsk->acl_sp_role = 1;
64973 + tsk->acl_role_id = ++acl_sp_role_value;
64974 + tsk->role = assigned;
64975 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
64976 +
64977 + /* ignore additional mmap checks for processes that are writable
64978 + by the default ACL */
64979 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64980 + if (unlikely(obj->mode & GR_WRITE))
64981 + tsk->is_writable = 1;
64982 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
64983 + if (unlikely(obj->mode & GR_WRITE))
64984 + tsk->is_writable = 1;
64985 +
64986 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64987 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename, tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
64988 +#endif
64989 +
64990 +out_unlock:
64991 + read_unlock(&grsec_exec_file_lock);
64992 + read_unlock(&tasklist_lock);
64993 + return;
64994 +}
64995 +
64996 +int gr_check_secure_terminal(struct task_struct *task)
64997 +{
64998 + struct task_struct *p, *p2, *p3;
64999 + struct files_struct *files;
65000 + struct fdtable *fdt;
65001 + struct file *our_file = NULL, *file;
65002 + int i;
65003 +
65004 + if (task->signal->tty == NULL)
65005 + return 1;
65006 +
65007 + files = get_files_struct(task);
65008 + if (files != NULL) {
65009 + rcu_read_lock();
65010 + fdt = files_fdtable(files);
65011 + for (i=0; i < fdt->max_fds; i++) {
65012 + file = fcheck_files(files, i);
65013 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
65014 + get_file(file);
65015 + our_file = file;
65016 + }
65017 + }
65018 + rcu_read_unlock();
65019 + put_files_struct(files);
65020 + }
65021 +
65022 + if (our_file == NULL)
65023 + return 1;
65024 +
65025 + read_lock(&tasklist_lock);
65026 + do_each_thread(p2, p) {
65027 + files = get_files_struct(p);
65028 + if (files == NULL ||
65029 + (p->signal && p->signal->tty == task->signal->tty)) {
65030 + if (files != NULL)
65031 + put_files_struct(files);
65032 + continue;
65033 + }
65034 + rcu_read_lock();
65035 + fdt = files_fdtable(files);
65036 + for (i=0; i < fdt->max_fds; i++) {
65037 + file = fcheck_files(files, i);
65038 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
65039 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
65040 + p3 = task;
65041 + while (task_pid_nr(p3) > 0) {
65042 + if (p3 == p)
65043 + break;
65044 + p3 = p3->real_parent;
65045 + }
65046 + if (p3 == p)
65047 + break;
65048 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
65049 + gr_handle_alertkill(p);
65050 + rcu_read_unlock();
65051 + put_files_struct(files);
65052 + read_unlock(&tasklist_lock);
65053 + fput(our_file);
65054 + return 0;
65055 + }
65056 + }
65057 + rcu_read_unlock();
65058 + put_files_struct(files);
65059 + } while_each_thread(p2, p);
65060 + read_unlock(&tasklist_lock);
65061 +
65062 + fput(our_file);
65063 + return 1;
65064 +}
65065 +
65066 +static int gr_rbac_disable(void *unused)
65067 +{
65068 + pax_open_kernel();
65069 + gr_status &= ~GR_READY;
65070 + pax_close_kernel();
65071 +
65072 + return 0;
65073 +}
65074 +
65075 +ssize_t
65076 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
65077 +{
65078 + struct gr_arg_wrapper uwrap;
65079 + unsigned char *sprole_salt = NULL;
65080 + unsigned char *sprole_sum = NULL;
65081 + int error = 0;
65082 + int error2 = 0;
65083 + size_t req_count = 0;
65084 +
65085 + mutex_lock(&gr_dev_mutex);
65086 +
65087 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
65088 + error = -EPERM;
65089 + goto out;
65090 + }
65091 +
65092 +#ifdef CONFIG_COMPAT
65093 + pax_open_kernel();
65094 + if (is_compat_task()) {
65095 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
65096 + copy_gr_arg = &copy_gr_arg_compat;
65097 + copy_acl_object_label = &copy_acl_object_label_compat;
65098 + copy_acl_subject_label = &copy_acl_subject_label_compat;
65099 + copy_acl_role_label = &copy_acl_role_label_compat;
65100 + copy_acl_ip_label = &copy_acl_ip_label_compat;
65101 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
65102 + copy_role_transition = &copy_role_transition_compat;
65103 + copy_sprole_pw = &copy_sprole_pw_compat;
65104 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
65105 + copy_pointer_from_array = &copy_pointer_from_array_compat;
65106 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
65107 + } else {
65108 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
65109 + copy_gr_arg = &copy_gr_arg_normal;
65110 + copy_acl_object_label = &copy_acl_object_label_normal;
65111 + copy_acl_subject_label = &copy_acl_subject_label_normal;
65112 + copy_acl_role_label = &copy_acl_role_label_normal;
65113 + copy_acl_ip_label = &copy_acl_ip_label_normal;
65114 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
65115 + copy_role_transition = &copy_role_transition_normal;
65116 + copy_sprole_pw = &copy_sprole_pw_normal;
65117 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
65118 + copy_pointer_from_array = &copy_pointer_from_array_normal;
65119 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
65120 + }
65121 + pax_close_kernel();
65122 +#endif
65123 +
65124 + req_count = get_gr_arg_wrapper_size();
65125 +
65126 + if (count != req_count) {
65127 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
65128 + error = -EINVAL;
65129 + goto out;
65130 + }
65131 +
65132 +
65133 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
65134 + gr_auth_expires = 0;
65135 + gr_auth_attempts = 0;
65136 + }
65137 +
65138 + error = copy_gr_arg_wrapper(buf, &uwrap);
65139 + if (error)
65140 + goto out;
65141 +
65142 + error = copy_gr_arg(uwrap.arg, gr_usermode);
65143 + if (error)
65144 + goto out;
65145 +
65146 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65147 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65148 + time_after(gr_auth_expires, get_seconds())) {
65149 + error = -EBUSY;
65150 + goto out;
65151 + }
65152 +
65153 + /* if non-root trying to do anything other than use a special role,
65154 + do not attempt authentication, do not count towards authentication
65155 + locking
65156 + */
65157 +
65158 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
65159 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65160 + gr_is_global_nonroot(current_uid())) {
65161 + error = -EPERM;
65162 + goto out;
65163 + }
65164 +
65165 + /* ensure pw and special role name are null terminated */
65166 +
65167 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
65168 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
65169 +
65170 + /* Okay.
65171 + * We have our enough of the argument structure..(we have yet
65172 + * to copy_from_user the tables themselves) . Copy the tables
65173 + * only if we need them, i.e. for loading operations. */
65174 +
65175 + switch (gr_usermode->mode) {
65176 + case GR_STATUS:
65177 + if (gr_status & GR_READY) {
65178 + error = 1;
65179 + if (!gr_check_secure_terminal(current))
65180 + error = 3;
65181 + } else
65182 + error = 2;
65183 + goto out;
65184 + case GR_SHUTDOWN:
65185 + if ((gr_status & GR_READY)
65186 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65187 + stop_machine(gr_rbac_disable, NULL, NULL);
65188 + free_variables();
65189 + memset(gr_usermode, 0, sizeof (struct gr_arg));
65190 + memset(gr_system_salt, 0, GR_SALT_LEN);
65191 + memset(gr_system_sum, 0, GR_SHA_LEN);
65192 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
65193 + } else if (gr_status & GR_READY) {
65194 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
65195 + error = -EPERM;
65196 + } else {
65197 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
65198 + error = -EAGAIN;
65199 + }
65200 + break;
65201 + case GR_ENABLE:
65202 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
65203 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
65204 + else {
65205 + if (gr_status & GR_READY)
65206 + error = -EAGAIN;
65207 + else
65208 + error = error2;
65209 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
65210 + }
65211 + break;
65212 + case GR_RELOAD:
65213 + if (!(gr_status & GR_READY)) {
65214 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
65215 + error = -EAGAIN;
65216 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65217 + stop_machine(gr_rbac_disable, NULL, NULL);
65218 + free_variables();
65219 + error2 = gracl_init(gr_usermode);
65220 + if (!error2)
65221 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
65222 + else {
65223 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65224 + error = error2;
65225 + }
65226 + } else {
65227 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65228 + error = -EPERM;
65229 + }
65230 + break;
65231 + case GR_SEGVMOD:
65232 + if (unlikely(!(gr_status & GR_READY))) {
65233 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
65234 + error = -EAGAIN;
65235 + break;
65236 + }
65237 +
65238 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65239 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
65240 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
65241 + struct acl_subject_label *segvacl;
65242 + segvacl =
65243 + lookup_acl_subj_label(gr_usermode->segv_inode,
65244 + gr_usermode->segv_device,
65245 + current->role);
65246 + if (segvacl) {
65247 + segvacl->crashes = 0;
65248 + segvacl->expires = 0;
65249 + }
65250 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
65251 + gr_remove_uid(gr_usermode->segv_uid);
65252 + }
65253 + } else {
65254 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
65255 + error = -EPERM;
65256 + }
65257 + break;
65258 + case GR_SPROLE:
65259 + case GR_SPROLEPAM:
65260 + if (unlikely(!(gr_status & GR_READY))) {
65261 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
65262 + error = -EAGAIN;
65263 + break;
65264 + }
65265 +
65266 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
65267 + current->role->expires = 0;
65268 + current->role->auth_attempts = 0;
65269 + }
65270 +
65271 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65272 + time_after(current->role->expires, get_seconds())) {
65273 + error = -EBUSY;
65274 + goto out;
65275 + }
65276 +
65277 + if (lookup_special_role_auth
65278 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
65279 + && ((!sprole_salt && !sprole_sum)
65280 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
65281 + char *p = "";
65282 + assign_special_role(gr_usermode->sp_role);
65283 + read_lock(&tasklist_lock);
65284 + if (current->real_parent)
65285 + p = current->real_parent->role->rolename;
65286 + read_unlock(&tasklist_lock);
65287 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
65288 + p, acl_sp_role_value);
65289 + } else {
65290 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
65291 + error = -EPERM;
65292 + if(!(current->role->auth_attempts++))
65293 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65294 +
65295 + goto out;
65296 + }
65297 + break;
65298 + case GR_UNSPROLE:
65299 + if (unlikely(!(gr_status & GR_READY))) {
65300 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
65301 + error = -EAGAIN;
65302 + break;
65303 + }
65304 +
65305 + if (current->role->roletype & GR_ROLE_SPECIAL) {
65306 + char *p = "";
65307 + int i = 0;
65308 +
65309 + read_lock(&tasklist_lock);
65310 + if (current->real_parent) {
65311 + p = current->real_parent->role->rolename;
65312 + i = current->real_parent->acl_role_id;
65313 + }
65314 + read_unlock(&tasklist_lock);
65315 +
65316 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
65317 + gr_set_acls(1);
65318 + } else {
65319 + error = -EPERM;
65320 + goto out;
65321 + }
65322 + break;
65323 + default:
65324 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
65325 + error = -EINVAL;
65326 + break;
65327 + }
65328 +
65329 + if (error != -EPERM)
65330 + goto out;
65331 +
65332 + if(!(gr_auth_attempts++))
65333 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65334 +
65335 + out:
65336 + mutex_unlock(&gr_dev_mutex);
65337 +
65338 + if (!error)
65339 + error = req_count;
65340 +
65341 + return error;
65342 +}
65343 +
65344 +/* must be called with
65345 + rcu_read_lock();
65346 + read_lock(&tasklist_lock);
65347 + read_lock(&grsec_exec_file_lock);
65348 +*/
65349 +int gr_apply_subject_to_task(struct task_struct *task)
65350 +{
65351 + struct acl_object_label *obj;
65352 + char *tmpname;
65353 + struct acl_subject_label *tmpsubj;
65354 + struct file *filp;
65355 + struct name_entry *nmatch;
65356 +
65357 + filp = task->exec_file;
65358 + if (filp == NULL)
65359 + return 0;
65360 +
65361 + /* the following is to apply the correct subject
65362 + on binaries running when the RBAC system
65363 + is enabled, when the binaries have been
65364 + replaced or deleted since their execution
65365 + -----
65366 + when the RBAC system starts, the inode/dev
65367 + from exec_file will be one the RBAC system
65368 + is unaware of. It only knows the inode/dev
65369 + of the present file on disk, or the absence
65370 + of it.
65371 + */
65372 + preempt_disable();
65373 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
65374 +
65375 + nmatch = lookup_name_entry(tmpname);
65376 + preempt_enable();
65377 + tmpsubj = NULL;
65378 + if (nmatch) {
65379 + if (nmatch->deleted)
65380 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
65381 + else
65382 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
65383 + if (tmpsubj != NULL)
65384 + task->acl = tmpsubj;
65385 + }
65386 + if (tmpsubj == NULL)
65387 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
65388 + task->role);
65389 + if (task->acl) {
65390 + task->is_writable = 0;
65391 + /* ignore additional mmap checks for processes that are writable
65392 + by the default ACL */
65393 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65394 + if (unlikely(obj->mode & GR_WRITE))
65395 + task->is_writable = 1;
65396 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65397 + if (unlikely(obj->mode & GR_WRITE))
65398 + task->is_writable = 1;
65399 +
65400 + gr_set_proc_res(task);
65401 +
65402 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65403 + 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);
65404 +#endif
65405 + } else {
65406 + return 1;
65407 + }
65408 +
65409 + return 0;
65410 +}
65411 +
65412 +int
65413 +gr_set_acls(const int type)
65414 +{
65415 + struct task_struct *task, *task2;
65416 + struct acl_role_label *role = current->role;
65417 + __u16 acl_role_id = current->acl_role_id;
65418 + const struct cred *cred;
65419 + int ret;
65420 +
65421 + rcu_read_lock();
65422 + read_lock(&tasklist_lock);
65423 + read_lock(&grsec_exec_file_lock);
65424 + do_each_thread(task2, task) {
65425 + /* check to see if we're called from the exit handler,
65426 + if so, only replace ACLs that have inherited the admin
65427 + ACL */
65428 +
65429 + if (type && (task->role != role ||
65430 + task->acl_role_id != acl_role_id))
65431 + continue;
65432 +
65433 + task->acl_role_id = 0;
65434 + task->acl_sp_role = 0;
65435 +
65436 + if (task->exec_file) {
65437 + cred = __task_cred(task);
65438 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
65439 + ret = gr_apply_subject_to_task(task);
65440 + if (ret) {
65441 + read_unlock(&grsec_exec_file_lock);
65442 + read_unlock(&tasklist_lock);
65443 + rcu_read_unlock();
65444 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
65445 + return ret;
65446 + }
65447 + } else {
65448 + // it's a kernel process
65449 + task->role = kernel_role;
65450 + task->acl = kernel_role->root_label;
65451 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
65452 + task->acl->mode &= ~GR_PROCFIND;
65453 +#endif
65454 + }
65455 + } while_each_thread(task2, task);
65456 + read_unlock(&grsec_exec_file_lock);
65457 + read_unlock(&tasklist_lock);
65458 + rcu_read_unlock();
65459 +
65460 + return 0;
65461 +}
65462 +
65463 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65464 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65465 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65466 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65467 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65468 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65469 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65470 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65471 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
65472 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
65473 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
65474 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
65475 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
65476 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
65477 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
65478 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
65479 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
65480 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
65481 +};
65482 +
65483 +void
65484 +gr_learn_resource(const struct task_struct *task,
65485 + const int res, const unsigned long wanted, const int gt)
65486 +{
65487 + struct acl_subject_label *acl;
65488 + const struct cred *cred;
65489 +
65490 + if (unlikely((gr_status & GR_READY) &&
65491 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
65492 + goto skip_reslog;
65493 +
65494 + gr_log_resource(task, res, wanted, gt);
65495 +skip_reslog:
65496 +
65497 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
65498 + return;
65499 +
65500 + acl = task->acl;
65501 +
65502 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
65503 + !(acl->resmask & (1U << (unsigned short) res))))
65504 + return;
65505 +
65506 + if (wanted >= acl->res[res].rlim_cur) {
65507 + unsigned long res_add;
65508 +
65509 + res_add = wanted + res_learn_bumps[res];
65510 +
65511 + acl->res[res].rlim_cur = res_add;
65512 +
65513 + if (wanted > acl->res[res].rlim_max)
65514 + acl->res[res].rlim_max = res_add;
65515 +
65516 + /* only log the subject filename, since resource logging is supported for
65517 + single-subject learning only */
65518 + rcu_read_lock();
65519 + cred = __task_cred(task);
65520 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65521 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
65522 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
65523 + "", (unsigned long) res, &task->signal->saved_ip);
65524 + rcu_read_unlock();
65525 + }
65526 +
65527 + return;
65528 +}
65529 +EXPORT_SYMBOL(gr_learn_resource);
65530 +#endif
65531 +
65532 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
65533 +void
65534 +pax_set_initial_flags(struct linux_binprm *bprm)
65535 +{
65536 + struct task_struct *task = current;
65537 + struct acl_subject_label *proc;
65538 + unsigned long flags;
65539 +
65540 + if (unlikely(!(gr_status & GR_READY)))
65541 + return;
65542 +
65543 + flags = pax_get_flags(task);
65544 +
65545 + proc = task->acl;
65546 +
65547 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
65548 + flags &= ~MF_PAX_PAGEEXEC;
65549 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
65550 + flags &= ~MF_PAX_SEGMEXEC;
65551 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
65552 + flags &= ~MF_PAX_RANDMMAP;
65553 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
65554 + flags &= ~MF_PAX_EMUTRAMP;
65555 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
65556 + flags &= ~MF_PAX_MPROTECT;
65557 +
65558 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
65559 + flags |= MF_PAX_PAGEEXEC;
65560 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
65561 + flags |= MF_PAX_SEGMEXEC;
65562 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
65563 + flags |= MF_PAX_RANDMMAP;
65564 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
65565 + flags |= MF_PAX_EMUTRAMP;
65566 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
65567 + flags |= MF_PAX_MPROTECT;
65568 +
65569 + pax_set_flags(task, flags);
65570 +
65571 + return;
65572 +}
65573 +#endif
65574 +
65575 +int
65576 +gr_handle_proc_ptrace(struct task_struct *task)
65577 +{
65578 + struct file *filp;
65579 + struct task_struct *tmp = task;
65580 + struct task_struct *curtemp = current;
65581 + __u32 retmode;
65582 +
65583 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65584 + if (unlikely(!(gr_status & GR_READY)))
65585 + return 0;
65586 +#endif
65587 +
65588 + read_lock(&tasklist_lock);
65589 + read_lock(&grsec_exec_file_lock);
65590 + filp = task->exec_file;
65591 +
65592 + while (task_pid_nr(tmp) > 0) {
65593 + if (tmp == curtemp)
65594 + break;
65595 + tmp = tmp->real_parent;
65596 + }
65597 +
65598 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65599 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
65600 + read_unlock(&grsec_exec_file_lock);
65601 + read_unlock(&tasklist_lock);
65602 + return 1;
65603 + }
65604 +
65605 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65606 + if (!(gr_status & GR_READY)) {
65607 + read_unlock(&grsec_exec_file_lock);
65608 + read_unlock(&tasklist_lock);
65609 + return 0;
65610 + }
65611 +#endif
65612 +
65613 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
65614 + read_unlock(&grsec_exec_file_lock);
65615 + read_unlock(&tasklist_lock);
65616 +
65617 + if (retmode & GR_NOPTRACE)
65618 + return 1;
65619 +
65620 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
65621 + && (current->acl != task->acl || (current->acl != current->role->root_label
65622 + && task_pid_nr(current) != task_pid_nr(task))))
65623 + return 1;
65624 +
65625 + return 0;
65626 +}
65627 +
65628 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
65629 +{
65630 + if (unlikely(!(gr_status & GR_READY)))
65631 + return;
65632 +
65633 + if (!(current->role->roletype & GR_ROLE_GOD))
65634 + return;
65635 +
65636 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
65637 + p->role->rolename, gr_task_roletype_to_char(p),
65638 + p->acl->filename);
65639 +}
65640 +
65641 +int
65642 +gr_handle_ptrace(struct task_struct *task, const long request)
65643 +{
65644 + struct task_struct *tmp = task;
65645 + struct task_struct *curtemp = current;
65646 + __u32 retmode;
65647 +
65648 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65649 + if (unlikely(!(gr_status & GR_READY)))
65650 + return 0;
65651 +#endif
65652 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
65653 + read_lock(&tasklist_lock);
65654 + while (task_pid_nr(tmp) > 0) {
65655 + if (tmp == curtemp)
65656 + break;
65657 + tmp = tmp->real_parent;
65658 + }
65659 +
65660 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65661 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
65662 + read_unlock(&tasklist_lock);
65663 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65664 + return 1;
65665 + }
65666 + read_unlock(&tasklist_lock);
65667 + }
65668 +
65669 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65670 + if (!(gr_status & GR_READY))
65671 + return 0;
65672 +#endif
65673 +
65674 + read_lock(&grsec_exec_file_lock);
65675 + if (unlikely(!task->exec_file)) {
65676 + read_unlock(&grsec_exec_file_lock);
65677 + return 0;
65678 + }
65679 +
65680 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
65681 + read_unlock(&grsec_exec_file_lock);
65682 +
65683 + if (retmode & GR_NOPTRACE) {
65684 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65685 + return 1;
65686 + }
65687 +
65688 + if (retmode & GR_PTRACERD) {
65689 + switch (request) {
65690 + case PTRACE_SEIZE:
65691 + case PTRACE_POKETEXT:
65692 + case PTRACE_POKEDATA:
65693 + case PTRACE_POKEUSR:
65694 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
65695 + case PTRACE_SETREGS:
65696 + case PTRACE_SETFPREGS:
65697 +#endif
65698 +#ifdef CONFIG_X86
65699 + case PTRACE_SETFPXREGS:
65700 +#endif
65701 +#ifdef CONFIG_ALTIVEC
65702 + case PTRACE_SETVRREGS:
65703 +#endif
65704 + return 1;
65705 + default:
65706 + return 0;
65707 + }
65708 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
65709 + !(current->role->roletype & GR_ROLE_GOD) &&
65710 + (current->acl != task->acl)) {
65711 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65712 + return 1;
65713 + }
65714 +
65715 + return 0;
65716 +}
65717 +
65718 +static int is_writable_mmap(const struct file *filp)
65719 +{
65720 + struct task_struct *task = current;
65721 + struct acl_object_label *obj, *obj2;
65722 +
65723 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
65724 + !task->is_writable && S_ISREG(filp->f_path.dentry->d_inode->i_mode) && (filp->f_path.mnt != shm_mnt || (filp->f_path.dentry->d_inode->i_nlink > 0))) {
65725 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65726 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
65727 + task->role->root_label);
65728 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
65729 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
65730 + return 1;
65731 + }
65732 + }
65733 + return 0;
65734 +}
65735 +
65736 +int
65737 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
65738 +{
65739 + __u32 mode;
65740 +
65741 + if (unlikely(!file || !(prot & PROT_EXEC)))
65742 + return 1;
65743 +
65744 + if (is_writable_mmap(file))
65745 + return 0;
65746 +
65747 + mode =
65748 + gr_search_file(file->f_path.dentry,
65749 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65750 + file->f_path.mnt);
65751 +
65752 + if (!gr_tpe_allow(file))
65753 + return 0;
65754 +
65755 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65756 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65757 + return 0;
65758 + } else if (unlikely(!(mode & GR_EXEC))) {
65759 + return 0;
65760 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65761 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65762 + return 1;
65763 + }
65764 +
65765 + return 1;
65766 +}
65767 +
65768 +int
65769 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
65770 +{
65771 + __u32 mode;
65772 +
65773 + if (unlikely(!file || !(prot & PROT_EXEC)))
65774 + return 1;
65775 +
65776 + if (is_writable_mmap(file))
65777 + return 0;
65778 +
65779 + mode =
65780 + gr_search_file(file->f_path.dentry,
65781 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65782 + file->f_path.mnt);
65783 +
65784 + if (!gr_tpe_allow(file))
65785 + return 0;
65786 +
65787 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65788 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65789 + return 0;
65790 + } else if (unlikely(!(mode & GR_EXEC))) {
65791 + return 0;
65792 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65793 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65794 + return 1;
65795 + }
65796 +
65797 + return 1;
65798 +}
65799 +
65800 +void
65801 +gr_acl_handle_psacct(struct task_struct *task, const long code)
65802 +{
65803 + unsigned long runtime;
65804 + unsigned long cputime;
65805 + unsigned int wday, cday;
65806 + __u8 whr, chr;
65807 + __u8 wmin, cmin;
65808 + __u8 wsec, csec;
65809 + struct timespec timeval;
65810 +
65811 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
65812 + !(task->acl->mode & GR_PROCACCT)))
65813 + return;
65814 +
65815 + do_posix_clock_monotonic_gettime(&timeval);
65816 + runtime = timeval.tv_sec - task->start_time.tv_sec;
65817 + wday = runtime / (3600 * 24);
65818 + runtime -= wday * (3600 * 24);
65819 + whr = runtime / 3600;
65820 + runtime -= whr * 3600;
65821 + wmin = runtime / 60;
65822 + runtime -= wmin * 60;
65823 + wsec = runtime;
65824 +
65825 + cputime = (task->utime + task->stime) / HZ;
65826 + cday = cputime / (3600 * 24);
65827 + cputime -= cday * (3600 * 24);
65828 + chr = cputime / 3600;
65829 + cputime -= chr * 3600;
65830 + cmin = cputime / 60;
65831 + cputime -= cmin * 60;
65832 + csec = cputime;
65833 +
65834 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
65835 +
65836 + return;
65837 +}
65838 +
65839 +void gr_set_kernel_label(struct task_struct *task)
65840 +{
65841 + if (gr_status & GR_READY) {
65842 + task->role = kernel_role;
65843 + task->acl = kernel_role->root_label;
65844 + }
65845 + return;
65846 +}
65847 +
65848 +#ifdef CONFIG_TASKSTATS
65849 +int gr_is_taskstats_denied(int pid)
65850 +{
65851 + struct task_struct *task;
65852 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65853 + const struct cred *cred;
65854 +#endif
65855 + int ret = 0;
65856 +
65857 + /* restrict taskstats viewing to un-chrooted root users
65858 + who have the 'view' subject flag if the RBAC system is enabled
65859 + */
65860 +
65861 + rcu_read_lock();
65862 + read_lock(&tasklist_lock);
65863 + task = find_task_by_vpid(pid);
65864 + if (task) {
65865 +#ifdef CONFIG_GRKERNSEC_CHROOT
65866 + if (proc_is_chrooted(task))
65867 + ret = -EACCES;
65868 +#endif
65869 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65870 + cred = __task_cred(task);
65871 +#ifdef CONFIG_GRKERNSEC_PROC_USER
65872 + if (gr_is_global_nonroot(cred->uid))
65873 + ret = -EACCES;
65874 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65875 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
65876 + ret = -EACCES;
65877 +#endif
65878 +#endif
65879 + if (gr_status & GR_READY) {
65880 + if (!(task->acl->mode & GR_VIEW))
65881 + ret = -EACCES;
65882 + }
65883 + } else
65884 + ret = -ENOENT;
65885 +
65886 + read_unlock(&tasklist_lock);
65887 + rcu_read_unlock();
65888 +
65889 + return ret;
65890 +}
65891 +#endif
65892 +
65893 +/* AUXV entries are filled via a descendant of search_binary_handler
65894 + after we've already applied the subject for the target
65895 +*/
65896 +int gr_acl_enable_at_secure(void)
65897 +{
65898 + if (unlikely(!(gr_status & GR_READY)))
65899 + return 0;
65900 +
65901 + if (current->acl->mode & GR_ATSECURE)
65902 + return 1;
65903 +
65904 + return 0;
65905 +}
65906 +
65907 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
65908 +{
65909 + struct task_struct *task = current;
65910 + struct dentry *dentry = file->f_path.dentry;
65911 + struct vfsmount *mnt = file->f_path.mnt;
65912 + struct acl_object_label *obj, *tmp;
65913 + struct acl_subject_label *subj;
65914 + unsigned int bufsize;
65915 + int is_not_root;
65916 + char *path;
65917 + dev_t dev = __get_dev(dentry);
65918 +
65919 + if (unlikely(!(gr_status & GR_READY)))
65920 + return 1;
65921 +
65922 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65923 + return 1;
65924 +
65925 + /* ignore Eric Biederman */
65926 + if (IS_PRIVATE(dentry->d_inode))
65927 + return 1;
65928 +
65929 + subj = task->acl;
65930 + read_lock(&gr_inode_lock);
65931 + do {
65932 + obj = lookup_acl_obj_label(ino, dev, subj);
65933 + if (obj != NULL) {
65934 + read_unlock(&gr_inode_lock);
65935 + return (obj->mode & GR_FIND) ? 1 : 0;
65936 + }
65937 + } while ((subj = subj->parent_subject));
65938 + read_unlock(&gr_inode_lock);
65939 +
65940 + /* this is purely an optimization since we're looking for an object
65941 + for the directory we're doing a readdir on
65942 + if it's possible for any globbed object to match the entry we're
65943 + filling into the directory, then the object we find here will be
65944 + an anchor point with attached globbed objects
65945 + */
65946 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
65947 + if (obj->globbed == NULL)
65948 + return (obj->mode & GR_FIND) ? 1 : 0;
65949 +
65950 + is_not_root = ((obj->filename[0] == '/') &&
65951 + (obj->filename[1] == '\0')) ? 0 : 1;
65952 + bufsize = PAGE_SIZE - namelen - is_not_root;
65953 +
65954 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
65955 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
65956 + return 1;
65957 +
65958 + preempt_disable();
65959 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
65960 + bufsize);
65961 +
65962 + bufsize = strlen(path);
65963 +
65964 + /* if base is "/", don't append an additional slash */
65965 + if (is_not_root)
65966 + *(path + bufsize) = '/';
65967 + memcpy(path + bufsize + is_not_root, name, namelen);
65968 + *(path + bufsize + namelen + is_not_root) = '\0';
65969 +
65970 + tmp = obj->globbed;
65971 + while (tmp) {
65972 + if (!glob_match(tmp->filename, path)) {
65973 + preempt_enable();
65974 + return (tmp->mode & GR_FIND) ? 1 : 0;
65975 + }
65976 + tmp = tmp->next;
65977 + }
65978 + preempt_enable();
65979 + return (obj->mode & GR_FIND) ? 1 : 0;
65980 +}
65981 +
65982 +void gr_put_exec_file(struct task_struct *task)
65983 +{
65984 + struct file *filp;
65985 +
65986 + write_lock(&grsec_exec_file_lock);
65987 + filp = task->exec_file;
65988 + task->exec_file = NULL;
65989 + write_unlock(&grsec_exec_file_lock);
65990 +
65991 + if (filp)
65992 + fput(filp);
65993 +
65994 + return;
65995 +}
65996 +
65997 +
65998 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
65999 +EXPORT_SYMBOL(gr_acl_is_enabled);
66000 +#endif
66001 +EXPORT_SYMBOL(gr_set_kernel_label);
66002 +#ifdef CONFIG_SECURITY
66003 +EXPORT_SYMBOL(gr_check_user_change);
66004 +EXPORT_SYMBOL(gr_check_group_change);
66005 +#endif
66006 +
66007 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66008 new file mode 100644
66009 index 0000000..34fefda
66010 --- /dev/null
66011 +++ b/grsecurity/gracl_alloc.c
66012 @@ -0,0 +1,105 @@
66013 +#include <linux/kernel.h>
66014 +#include <linux/mm.h>
66015 +#include <linux/slab.h>
66016 +#include <linux/vmalloc.h>
66017 +#include <linux/gracl.h>
66018 +#include <linux/grsecurity.h>
66019 +
66020 +static unsigned long alloc_stack_next = 1;
66021 +static unsigned long alloc_stack_size = 1;
66022 +static void **alloc_stack;
66023 +
66024 +static __inline__ int
66025 +alloc_pop(void)
66026 +{
66027 + if (alloc_stack_next == 1)
66028 + return 0;
66029 +
66030 + kfree(alloc_stack[alloc_stack_next - 2]);
66031 +
66032 + alloc_stack_next--;
66033 +
66034 + return 1;
66035 +}
66036 +
66037 +static __inline__ int
66038 +alloc_push(void *buf)
66039 +{
66040 + if (alloc_stack_next >= alloc_stack_size)
66041 + return 1;
66042 +
66043 + alloc_stack[alloc_stack_next - 1] = buf;
66044 +
66045 + alloc_stack_next++;
66046 +
66047 + return 0;
66048 +}
66049 +
66050 +void *
66051 +acl_alloc(unsigned long len)
66052 +{
66053 + void *ret = NULL;
66054 +
66055 + if (!len || len > PAGE_SIZE)
66056 + goto out;
66057 +
66058 + ret = kmalloc(len, GFP_KERNEL);
66059 +
66060 + if (ret) {
66061 + if (alloc_push(ret)) {
66062 + kfree(ret);
66063 + ret = NULL;
66064 + }
66065 + }
66066 +
66067 +out:
66068 + return ret;
66069 +}
66070 +
66071 +void *
66072 +acl_alloc_num(unsigned long num, unsigned long len)
66073 +{
66074 + if (!len || (num > (PAGE_SIZE / len)))
66075 + return NULL;
66076 +
66077 + return acl_alloc(num * len);
66078 +}
66079 +
66080 +void
66081 +acl_free_all(void)
66082 +{
66083 + if (gr_acl_is_enabled() || !alloc_stack)
66084 + return;
66085 +
66086 + while (alloc_pop()) ;
66087 +
66088 + if (alloc_stack) {
66089 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66090 + kfree(alloc_stack);
66091 + else
66092 + vfree(alloc_stack);
66093 + }
66094 +
66095 + alloc_stack = NULL;
66096 + alloc_stack_size = 1;
66097 + alloc_stack_next = 1;
66098 +
66099 + return;
66100 +}
66101 +
66102 +int
66103 +acl_alloc_stack_init(unsigned long size)
66104 +{
66105 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66106 + alloc_stack =
66107 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66108 + else
66109 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
66110 +
66111 + alloc_stack_size = size;
66112 +
66113 + if (!alloc_stack)
66114 + return 0;
66115 + else
66116 + return 1;
66117 +}
66118 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66119 new file mode 100644
66120 index 0000000..bdd51ea
66121 --- /dev/null
66122 +++ b/grsecurity/gracl_cap.c
66123 @@ -0,0 +1,110 @@
66124 +#include <linux/kernel.h>
66125 +#include <linux/module.h>
66126 +#include <linux/sched.h>
66127 +#include <linux/gracl.h>
66128 +#include <linux/grsecurity.h>
66129 +#include <linux/grinternal.h>
66130 +
66131 +extern const char *captab_log[];
66132 +extern int captab_log_entries;
66133 +
66134 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66135 +{
66136 + struct acl_subject_label *curracl;
66137 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66138 + kernel_cap_t cap_audit = __cap_empty_set;
66139 +
66140 + if (!gr_acl_is_enabled())
66141 + return 1;
66142 +
66143 + curracl = task->acl;
66144 +
66145 + cap_drop = curracl->cap_lower;
66146 + cap_mask = curracl->cap_mask;
66147 + cap_audit = curracl->cap_invert_audit;
66148 +
66149 + while ((curracl = curracl->parent_subject)) {
66150 + /* if the cap isn't specified in the current computed mask but is specified in the
66151 + current level subject, and is lowered in the current level subject, then add
66152 + it to the set of dropped capabilities
66153 + otherwise, add the current level subject's mask to the current computed mask
66154 + */
66155 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66156 + cap_raise(cap_mask, cap);
66157 + if (cap_raised(curracl->cap_lower, cap))
66158 + cap_raise(cap_drop, cap);
66159 + if (cap_raised(curracl->cap_invert_audit, cap))
66160 + cap_raise(cap_audit, cap);
66161 + }
66162 + }
66163 +
66164 + if (!cap_raised(cap_drop, cap)) {
66165 + if (cap_raised(cap_audit, cap))
66166 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66167 + return 1;
66168 + }
66169 +
66170 + curracl = task->acl;
66171 +
66172 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66173 + && cap_raised(cred->cap_effective, cap)) {
66174 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66175 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66176 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66177 + gr_to_filename(task->exec_file->f_path.dentry,
66178 + task->exec_file->f_path.mnt) : curracl->filename,
66179 + curracl->filename, 0UL,
66180 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66181 + return 1;
66182 + }
66183 +
66184 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66185 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66186 +
66187 + return 0;
66188 +}
66189 +
66190 +int
66191 +gr_acl_is_capable(const int cap)
66192 +{
66193 + return gr_task_acl_is_capable(current, current_cred(), cap);
66194 +}
66195 +
66196 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66197 +{
66198 + struct acl_subject_label *curracl;
66199 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66200 +
66201 + if (!gr_acl_is_enabled())
66202 + return 1;
66203 +
66204 + curracl = task->acl;
66205 +
66206 + cap_drop = curracl->cap_lower;
66207 + cap_mask = curracl->cap_mask;
66208 +
66209 + while ((curracl = curracl->parent_subject)) {
66210 + /* if the cap isn't specified in the current computed mask but is specified in the
66211 + current level subject, and is lowered in the current level subject, then add
66212 + it to the set of dropped capabilities
66213 + otherwise, add the current level subject's mask to the current computed mask
66214 + */
66215 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66216 + cap_raise(cap_mask, cap);
66217 + if (cap_raised(curracl->cap_lower, cap))
66218 + cap_raise(cap_drop, cap);
66219 + }
66220 + }
66221 +
66222 + if (!cap_raised(cap_drop, cap))
66223 + return 1;
66224 +
66225 + return 0;
66226 +}
66227 +
66228 +int
66229 +gr_acl_is_capable_nolog(const int cap)
66230 +{
66231 + return gr_task_acl_is_capable_nolog(current, cap);
66232 +}
66233 +
66234 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66235 new file mode 100644
66236 index 0000000..a43dd06
66237 --- /dev/null
66238 +++ b/grsecurity/gracl_compat.c
66239 @@ -0,0 +1,269 @@
66240 +#include <linux/kernel.h>
66241 +#include <linux/gracl.h>
66242 +#include <linux/compat.h>
66243 +#include <linux/gracl_compat.h>
66244 +
66245 +#include <asm/uaccess.h>
66246 +
66247 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66248 +{
66249 + struct gr_arg_wrapper_compat uwrapcompat;
66250 +
66251 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66252 + return -EFAULT;
66253 +
66254 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
66255 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66256 + return -EINVAL;
66257 +
66258 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66259 + uwrap->version = uwrapcompat.version;
66260 + uwrap->size = sizeof(struct gr_arg);
66261 +
66262 + return 0;
66263 +}
66264 +
66265 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66266 +{
66267 + struct gr_arg_compat argcompat;
66268 +
66269 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66270 + return -EFAULT;
66271 +
66272 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66273 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66274 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66275 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66276 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66277 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66278 +
66279 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66280 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66281 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66282 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66283 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66284 + arg->segv_device = argcompat.segv_device;
66285 + arg->segv_inode = argcompat.segv_inode;
66286 + arg->segv_uid = argcompat.segv_uid;
66287 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66288 + arg->mode = argcompat.mode;
66289 +
66290 + return 0;
66291 +}
66292 +
66293 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66294 +{
66295 + struct acl_object_label_compat objcompat;
66296 +
66297 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66298 + return -EFAULT;
66299 +
66300 + obj->filename = compat_ptr(objcompat.filename);
66301 + obj->inode = objcompat.inode;
66302 + obj->device = objcompat.device;
66303 + obj->mode = objcompat.mode;
66304 +
66305 + obj->nested = compat_ptr(objcompat.nested);
66306 + obj->globbed = compat_ptr(objcompat.globbed);
66307 +
66308 + obj->prev = compat_ptr(objcompat.prev);
66309 + obj->next = compat_ptr(objcompat.next);
66310 +
66311 + return 0;
66312 +}
66313 +
66314 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66315 +{
66316 + unsigned int i;
66317 + struct acl_subject_label_compat subjcompat;
66318 +
66319 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66320 + return -EFAULT;
66321 +
66322 + subj->filename = compat_ptr(subjcompat.filename);
66323 + subj->inode = subjcompat.inode;
66324 + subj->device = subjcompat.device;
66325 + subj->mode = subjcompat.mode;
66326 + subj->cap_mask = subjcompat.cap_mask;
66327 + subj->cap_lower = subjcompat.cap_lower;
66328 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66329 +
66330 + for (i = 0; i < GR_NLIMITS; i++) {
66331 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66332 + subj->res[i].rlim_cur = RLIM_INFINITY;
66333 + else
66334 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66335 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66336 + subj->res[i].rlim_max = RLIM_INFINITY;
66337 + else
66338 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66339 + }
66340 + subj->resmask = subjcompat.resmask;
66341 +
66342 + subj->user_trans_type = subjcompat.user_trans_type;
66343 + subj->group_trans_type = subjcompat.group_trans_type;
66344 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66345 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66346 + subj->user_trans_num = subjcompat.user_trans_num;
66347 + subj->group_trans_num = subjcompat.group_trans_num;
66348 +
66349 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66350 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66351 + subj->ip_type = subjcompat.ip_type;
66352 + subj->ips = compat_ptr(subjcompat.ips);
66353 + subj->ip_num = subjcompat.ip_num;
66354 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66355 +
66356 + subj->crashes = subjcompat.crashes;
66357 + subj->expires = subjcompat.expires;
66358 +
66359 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66360 + subj->hash = compat_ptr(subjcompat.hash);
66361 + subj->prev = compat_ptr(subjcompat.prev);
66362 + subj->next = compat_ptr(subjcompat.next);
66363 +
66364 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66365 + subj->obj_hash_size = subjcompat.obj_hash_size;
66366 + subj->pax_flags = subjcompat.pax_flags;
66367 +
66368 + return 0;
66369 +}
66370 +
66371 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66372 +{
66373 + struct acl_role_label_compat rolecompat;
66374 +
66375 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66376 + return -EFAULT;
66377 +
66378 + role->rolename = compat_ptr(rolecompat.rolename);
66379 + role->uidgid = rolecompat.uidgid;
66380 + role->roletype = rolecompat.roletype;
66381 +
66382 + role->auth_attempts = rolecompat.auth_attempts;
66383 + role->expires = rolecompat.expires;
66384 +
66385 + role->root_label = compat_ptr(rolecompat.root_label);
66386 + role->hash = compat_ptr(rolecompat.hash);
66387 +
66388 + role->prev = compat_ptr(rolecompat.prev);
66389 + role->next = compat_ptr(rolecompat.next);
66390 +
66391 + role->transitions = compat_ptr(rolecompat.transitions);
66392 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
66393 + role->domain_children = compat_ptr(rolecompat.domain_children);
66394 + role->domain_child_num = rolecompat.domain_child_num;
66395 +
66396 + role->umask = rolecompat.umask;
66397 +
66398 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
66399 + role->subj_hash_size = rolecompat.subj_hash_size;
66400 +
66401 + return 0;
66402 +}
66403 +
66404 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66405 +{
66406 + struct role_allowed_ip_compat roleip_compat;
66407 +
66408 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
66409 + return -EFAULT;
66410 +
66411 + roleip->addr = roleip_compat.addr;
66412 + roleip->netmask = roleip_compat.netmask;
66413 +
66414 + roleip->prev = compat_ptr(roleip_compat.prev);
66415 + roleip->next = compat_ptr(roleip_compat.next);
66416 +
66417 + return 0;
66418 +}
66419 +
66420 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
66421 +{
66422 + struct role_transition_compat trans_compat;
66423 +
66424 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
66425 + return -EFAULT;
66426 +
66427 + trans->rolename = compat_ptr(trans_compat.rolename);
66428 +
66429 + trans->prev = compat_ptr(trans_compat.prev);
66430 + trans->next = compat_ptr(trans_compat.next);
66431 +
66432 + return 0;
66433 +
66434 +}
66435 +
66436 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66437 +{
66438 + struct gr_hash_struct_compat hash_compat;
66439 +
66440 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66441 + return -EFAULT;
66442 +
66443 + hash->table = compat_ptr(hash_compat.table);
66444 + hash->nametable = compat_ptr(hash_compat.nametable);
66445 + hash->first = compat_ptr(hash_compat.first);
66446 +
66447 + hash->table_size = hash_compat.table_size;
66448 + hash->used_size = hash_compat.used_size;
66449 +
66450 + hash->type = hash_compat.type;
66451 +
66452 + return 0;
66453 +}
66454 +
66455 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66456 +{
66457 + compat_uptr_t ptrcompat;
66458 +
66459 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66460 + return -EFAULT;
66461 +
66462 + *(void **)ptr = compat_ptr(ptrcompat);
66463 +
66464 + return 0;
66465 +}
66466 +
66467 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66468 +{
66469 + struct acl_ip_label_compat ip_compat;
66470 +
66471 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
66472 + return -EFAULT;
66473 +
66474 + ip->iface = compat_ptr(ip_compat.iface);
66475 + ip->addr = ip_compat.addr;
66476 + ip->netmask = ip_compat.netmask;
66477 + ip->low = ip_compat.low;
66478 + ip->high = ip_compat.high;
66479 + ip->mode = ip_compat.mode;
66480 + ip->type = ip_compat.type;
66481 +
66482 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
66483 +
66484 + ip->prev = compat_ptr(ip_compat.prev);
66485 + ip->next = compat_ptr(ip_compat.next);
66486 +
66487 + return 0;
66488 +}
66489 +
66490 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66491 +{
66492 + struct sprole_pw_compat pw_compat;
66493 +
66494 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
66495 + return -EFAULT;
66496 +
66497 + pw->rolename = compat_ptr(pw_compat.rolename);
66498 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
66499 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
66500 +
66501 + return 0;
66502 +}
66503 +
66504 +size_t get_gr_arg_wrapper_size_compat(void)
66505 +{
66506 + return sizeof(struct gr_arg_wrapper_compat);
66507 +}
66508 +
66509 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
66510 new file mode 100644
66511 index 0000000..a340c17
66512 --- /dev/null
66513 +++ b/grsecurity/gracl_fs.c
66514 @@ -0,0 +1,431 @@
66515 +#include <linux/kernel.h>
66516 +#include <linux/sched.h>
66517 +#include <linux/types.h>
66518 +#include <linux/fs.h>
66519 +#include <linux/file.h>
66520 +#include <linux/stat.h>
66521 +#include <linux/grsecurity.h>
66522 +#include <linux/grinternal.h>
66523 +#include <linux/gracl.h>
66524 +
66525 +umode_t
66526 +gr_acl_umask(void)
66527 +{
66528 + if (unlikely(!gr_acl_is_enabled()))
66529 + return 0;
66530 +
66531 + return current->role->umask;
66532 +}
66533 +
66534 +__u32
66535 +gr_acl_handle_hidden_file(const struct dentry * dentry,
66536 + const struct vfsmount * mnt)
66537 +{
66538 + __u32 mode;
66539 +
66540 + if (unlikely(!dentry->d_inode))
66541 + return GR_FIND;
66542 +
66543 + mode =
66544 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
66545 +
66546 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
66547 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66548 + return mode;
66549 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
66550 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66551 + return 0;
66552 + } else if (unlikely(!(mode & GR_FIND)))
66553 + return 0;
66554 +
66555 + return GR_FIND;
66556 +}
66557 +
66558 +__u32
66559 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
66560 + int acc_mode)
66561 +{
66562 + __u32 reqmode = GR_FIND;
66563 + __u32 mode;
66564 +
66565 + if (unlikely(!dentry->d_inode))
66566 + return reqmode;
66567 +
66568 + if (acc_mode & MAY_APPEND)
66569 + reqmode |= GR_APPEND;
66570 + else if (acc_mode & MAY_WRITE)
66571 + reqmode |= GR_WRITE;
66572 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
66573 + reqmode |= GR_READ;
66574 +
66575 + mode =
66576 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66577 + mnt);
66578 +
66579 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66580 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66581 + reqmode & GR_READ ? " reading" : "",
66582 + reqmode & GR_WRITE ? " writing" : reqmode &
66583 + GR_APPEND ? " appending" : "");
66584 + return reqmode;
66585 + } else
66586 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66587 + {
66588 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66589 + reqmode & GR_READ ? " reading" : "",
66590 + reqmode & GR_WRITE ? " writing" : reqmode &
66591 + GR_APPEND ? " appending" : "");
66592 + return 0;
66593 + } else if (unlikely((mode & reqmode) != reqmode))
66594 + return 0;
66595 +
66596 + return reqmode;
66597 +}
66598 +
66599 +__u32
66600 +gr_acl_handle_creat(const struct dentry * dentry,
66601 + const struct dentry * p_dentry,
66602 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
66603 + const int imode)
66604 +{
66605 + __u32 reqmode = GR_WRITE | GR_CREATE;
66606 + __u32 mode;
66607 +
66608 + if (acc_mode & MAY_APPEND)
66609 + reqmode |= GR_APPEND;
66610 + // if a directory was required or the directory already exists, then
66611 + // don't count this open as a read
66612 + if ((acc_mode & MAY_READ) &&
66613 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
66614 + reqmode |= GR_READ;
66615 + if ((open_flags & O_CREAT) &&
66616 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66617 + reqmode |= GR_SETID;
66618 +
66619 + mode =
66620 + gr_check_create(dentry, p_dentry, p_mnt,
66621 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66622 +
66623 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66624 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66625 + reqmode & GR_READ ? " reading" : "",
66626 + reqmode & GR_WRITE ? " writing" : reqmode &
66627 + GR_APPEND ? " appending" : "");
66628 + return reqmode;
66629 + } else
66630 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66631 + {
66632 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66633 + reqmode & GR_READ ? " reading" : "",
66634 + reqmode & GR_WRITE ? " writing" : reqmode &
66635 + GR_APPEND ? " appending" : "");
66636 + return 0;
66637 + } else if (unlikely((mode & reqmode) != reqmode))
66638 + return 0;
66639 +
66640 + return reqmode;
66641 +}
66642 +
66643 +__u32
66644 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
66645 + const int fmode)
66646 +{
66647 + __u32 mode, reqmode = GR_FIND;
66648 +
66649 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
66650 + reqmode |= GR_EXEC;
66651 + if (fmode & S_IWOTH)
66652 + reqmode |= GR_WRITE;
66653 + if (fmode & S_IROTH)
66654 + reqmode |= GR_READ;
66655 +
66656 + mode =
66657 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66658 + mnt);
66659 +
66660 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66661 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66662 + reqmode & GR_READ ? " reading" : "",
66663 + reqmode & GR_WRITE ? " writing" : "",
66664 + reqmode & GR_EXEC ? " executing" : "");
66665 + return reqmode;
66666 + } else
66667 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66668 + {
66669 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66670 + reqmode & GR_READ ? " reading" : "",
66671 + reqmode & GR_WRITE ? " writing" : "",
66672 + reqmode & GR_EXEC ? " executing" : "");
66673 + return 0;
66674 + } else if (unlikely((mode & reqmode) != reqmode))
66675 + return 0;
66676 +
66677 + return reqmode;
66678 +}
66679 +
66680 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
66681 +{
66682 + __u32 mode;
66683 +
66684 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
66685 +
66686 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66687 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
66688 + return mode;
66689 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66690 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
66691 + return 0;
66692 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66693 + return 0;
66694 +
66695 + return (reqmode);
66696 +}
66697 +
66698 +__u32
66699 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
66700 +{
66701 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
66702 +}
66703 +
66704 +__u32
66705 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
66706 +{
66707 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
66708 +}
66709 +
66710 +__u32
66711 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
66712 +{
66713 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
66714 +}
66715 +
66716 +__u32
66717 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
66718 +{
66719 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
66720 +}
66721 +
66722 +__u32
66723 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
66724 + umode_t *modeptr)
66725 +{
66726 + umode_t mode;
66727 +
66728 + *modeptr &= ~gr_acl_umask();
66729 + mode = *modeptr;
66730 +
66731 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
66732 + return 1;
66733 +
66734 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
66735 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
66736 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
66737 + GR_CHMOD_ACL_MSG);
66738 + } else {
66739 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
66740 + }
66741 +}
66742 +
66743 +__u32
66744 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
66745 +{
66746 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
66747 +}
66748 +
66749 +__u32
66750 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
66751 +{
66752 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
66753 +}
66754 +
66755 +__u32
66756 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
66757 +{
66758 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
66759 +}
66760 +
66761 +__u32
66762 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
66763 +{
66764 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
66765 + GR_UNIXCONNECT_ACL_MSG);
66766 +}
66767 +
66768 +/* hardlinks require at minimum create and link permission,
66769 + any additional privilege required is based on the
66770 + privilege of the file being linked to
66771 +*/
66772 +__u32
66773 +gr_acl_handle_link(const struct dentry * new_dentry,
66774 + const struct dentry * parent_dentry,
66775 + const struct vfsmount * parent_mnt,
66776 + const struct dentry * old_dentry,
66777 + const struct vfsmount * old_mnt, const struct filename *to)
66778 +{
66779 + __u32 mode;
66780 + __u32 needmode = GR_CREATE | GR_LINK;
66781 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
66782 +
66783 + mode =
66784 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
66785 + old_mnt);
66786 +
66787 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
66788 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66789 + return mode;
66790 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66791 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66792 + return 0;
66793 + } else if (unlikely((mode & needmode) != needmode))
66794 + return 0;
66795 +
66796 + return 1;
66797 +}
66798 +
66799 +__u32
66800 +gr_acl_handle_symlink(const struct dentry * new_dentry,
66801 + const struct dentry * parent_dentry,
66802 + const struct vfsmount * parent_mnt, const struct filename *from)
66803 +{
66804 + __u32 needmode = GR_WRITE | GR_CREATE;
66805 + __u32 mode;
66806 +
66807 + mode =
66808 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
66809 + GR_CREATE | GR_AUDIT_CREATE |
66810 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
66811 +
66812 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
66813 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
66814 + return mode;
66815 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66816 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
66817 + return 0;
66818 + } else if (unlikely((mode & needmode) != needmode))
66819 + return 0;
66820 +
66821 + return (GR_WRITE | GR_CREATE);
66822 +}
66823 +
66824 +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)
66825 +{
66826 + __u32 mode;
66827 +
66828 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66829 +
66830 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66831 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
66832 + return mode;
66833 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66834 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
66835 + return 0;
66836 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66837 + return 0;
66838 +
66839 + return (reqmode);
66840 +}
66841 +
66842 +__u32
66843 +gr_acl_handle_mknod(const struct dentry * new_dentry,
66844 + const struct dentry * parent_dentry,
66845 + const struct vfsmount * parent_mnt,
66846 + const int mode)
66847 +{
66848 + __u32 reqmode = GR_WRITE | GR_CREATE;
66849 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66850 + reqmode |= GR_SETID;
66851 +
66852 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
66853 + reqmode, GR_MKNOD_ACL_MSG);
66854 +}
66855 +
66856 +__u32
66857 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
66858 + const struct dentry *parent_dentry,
66859 + const struct vfsmount *parent_mnt)
66860 +{
66861 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
66862 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
66863 +}
66864 +
66865 +#define RENAME_CHECK_SUCCESS(old, new) \
66866 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
66867 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
66868 +
66869 +int
66870 +gr_acl_handle_rename(struct dentry *new_dentry,
66871 + struct dentry *parent_dentry,
66872 + const struct vfsmount *parent_mnt,
66873 + struct dentry *old_dentry,
66874 + struct inode *old_parent_inode,
66875 + struct vfsmount *old_mnt, const struct filename *newname)
66876 +{
66877 + __u32 comp1, comp2;
66878 + int error = 0;
66879 +
66880 + if (unlikely(!gr_acl_is_enabled()))
66881 + return 0;
66882 +
66883 + if (!new_dentry->d_inode) {
66884 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
66885 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
66886 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
66887 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
66888 + GR_DELETE | GR_AUDIT_DELETE |
66889 + GR_AUDIT_READ | GR_AUDIT_WRITE |
66890 + GR_SUPPRESS, old_mnt);
66891 + } else {
66892 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
66893 + GR_CREATE | GR_DELETE |
66894 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
66895 + GR_AUDIT_READ | GR_AUDIT_WRITE |
66896 + GR_SUPPRESS, parent_mnt);
66897 + comp2 =
66898 + gr_search_file(old_dentry,
66899 + GR_READ | GR_WRITE | GR_AUDIT_READ |
66900 + GR_DELETE | GR_AUDIT_DELETE |
66901 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
66902 + }
66903 +
66904 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
66905 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
66906 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
66907 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
66908 + && !(comp2 & GR_SUPPRESS)) {
66909 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
66910 + error = -EACCES;
66911 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
66912 + error = -EACCES;
66913 +
66914 + return error;
66915 +}
66916 +
66917 +void
66918 +gr_acl_handle_exit(void)
66919 +{
66920 + u16 id;
66921 + char *rolename;
66922 +
66923 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
66924 + !(current->role->roletype & GR_ROLE_PERSIST))) {
66925 + id = current->acl_role_id;
66926 + rolename = current->role->rolename;
66927 + gr_set_acls(1);
66928 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
66929 + }
66930 +
66931 + gr_put_exec_file(current);
66932 + return;
66933 +}
66934 +
66935 +int
66936 +gr_acl_handle_procpidmem(const struct task_struct *task)
66937 +{
66938 + if (unlikely(!gr_acl_is_enabled()))
66939 + return 0;
66940 +
66941 + if (task != current && task->acl->mode & GR_PROTPROCFD)
66942 + return -EACCES;
66943 +
66944 + return 0;
66945 +}
66946 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
66947 new file mode 100644
66948 index 0000000..f056b81
66949 --- /dev/null
66950 +++ b/grsecurity/gracl_ip.c
66951 @@ -0,0 +1,386 @@
66952 +#include <linux/kernel.h>
66953 +#include <asm/uaccess.h>
66954 +#include <asm/errno.h>
66955 +#include <net/sock.h>
66956 +#include <linux/file.h>
66957 +#include <linux/fs.h>
66958 +#include <linux/net.h>
66959 +#include <linux/in.h>
66960 +#include <linux/skbuff.h>
66961 +#include <linux/ip.h>
66962 +#include <linux/udp.h>
66963 +#include <linux/types.h>
66964 +#include <linux/sched.h>
66965 +#include <linux/netdevice.h>
66966 +#include <linux/inetdevice.h>
66967 +#include <linux/gracl.h>
66968 +#include <linux/grsecurity.h>
66969 +#include <linux/grinternal.h>
66970 +
66971 +#define GR_BIND 0x01
66972 +#define GR_CONNECT 0x02
66973 +#define GR_INVERT 0x04
66974 +#define GR_BINDOVERRIDE 0x08
66975 +#define GR_CONNECTOVERRIDE 0x10
66976 +#define GR_SOCK_FAMILY 0x20
66977 +
66978 +static const char * gr_protocols[IPPROTO_MAX] = {
66979 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
66980 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
66981 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
66982 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
66983 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
66984 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
66985 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
66986 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
66987 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
66988 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
66989 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
66990 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
66991 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
66992 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
66993 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
66994 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
66995 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
66996 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
66997 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
66998 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
66999 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67000 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67001 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67002 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67003 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67004 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67005 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67006 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67007 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67008 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67009 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67010 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67011 + };
67012 +
67013 +static const char * gr_socktypes[SOCK_MAX] = {
67014 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67015 + "unknown:7", "unknown:8", "unknown:9", "packet"
67016 + };
67017 +
67018 +static const char * gr_sockfamilies[AF_MAX+1] = {
67019 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67020 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67021 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67022 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67023 + };
67024 +
67025 +const char *
67026 +gr_proto_to_name(unsigned char proto)
67027 +{
67028 + return gr_protocols[proto];
67029 +}
67030 +
67031 +const char *
67032 +gr_socktype_to_name(unsigned char type)
67033 +{
67034 + return gr_socktypes[type];
67035 +}
67036 +
67037 +const char *
67038 +gr_sockfamily_to_name(unsigned char family)
67039 +{
67040 + return gr_sockfamilies[family];
67041 +}
67042 +
67043 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
67044 +
67045 +int
67046 +gr_search_socket(const int domain, const int type, const int protocol)
67047 +{
67048 + struct acl_subject_label *curr;
67049 + const struct cred *cred = current_cred();
67050 +
67051 + if (unlikely(!gr_acl_is_enabled()))
67052 + goto exit;
67053 +
67054 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67055 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67056 + goto exit; // let the kernel handle it
67057 +
67058 + curr = current->acl;
67059 +
67060 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67061 + /* the family is allowed, if this is PF_INET allow it only if
67062 + the extra sock type/protocol checks pass */
67063 + if (domain == PF_INET)
67064 + goto inet_check;
67065 + goto exit;
67066 + } else {
67067 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67068 + __u32 fakeip = 0;
67069 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67070 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67071 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67072 + gr_to_filename(current->exec_file->f_path.dentry,
67073 + current->exec_file->f_path.mnt) :
67074 + curr->filename, curr->filename,
67075 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67076 + &current->signal->saved_ip);
67077 + goto exit;
67078 + }
67079 + goto exit_fail;
67080 + }
67081 +
67082 +inet_check:
67083 + /* the rest of this checking is for IPv4 only */
67084 + if (!curr->ips)
67085 + goto exit;
67086 +
67087 + if ((curr->ip_type & (1U << type)) &&
67088 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67089 + goto exit;
67090 +
67091 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67092 + /* we don't place acls on raw sockets , and sometimes
67093 + dgram/ip sockets are opened for ioctl and not
67094 + bind/connect, so we'll fake a bind learn log */
67095 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67096 + __u32 fakeip = 0;
67097 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67098 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67099 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67100 + gr_to_filename(current->exec_file->f_path.dentry,
67101 + current->exec_file->f_path.mnt) :
67102 + curr->filename, curr->filename,
67103 + &fakeip, 0, type,
67104 + protocol, GR_CONNECT, &current->signal->saved_ip);
67105 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67106 + __u32 fakeip = 0;
67107 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67108 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67109 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67110 + gr_to_filename(current->exec_file->f_path.dentry,
67111 + current->exec_file->f_path.mnt) :
67112 + curr->filename, curr->filename,
67113 + &fakeip, 0, type,
67114 + protocol, GR_BIND, &current->signal->saved_ip);
67115 + }
67116 + /* we'll log when they use connect or bind */
67117 + goto exit;
67118 + }
67119 +
67120 +exit_fail:
67121 + if (domain == PF_INET)
67122 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67123 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67124 + else if (rcu_access_pointer(net_families[domain]) != NULL)
67125 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67126 + gr_socktype_to_name(type), protocol);
67127 +
67128 + return 0;
67129 +exit:
67130 + return 1;
67131 +}
67132 +
67133 +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)
67134 +{
67135 + if ((ip->mode & mode) &&
67136 + (ip_port >= ip->low) &&
67137 + (ip_port <= ip->high) &&
67138 + ((ntohl(ip_addr) & our_netmask) ==
67139 + (ntohl(our_addr) & our_netmask))
67140 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67141 + && (ip->type & (1U << type))) {
67142 + if (ip->mode & GR_INVERT)
67143 + return 2; // specifically denied
67144 + else
67145 + return 1; // allowed
67146 + }
67147 +
67148 + return 0; // not specifically allowed, may continue parsing
67149 +}
67150 +
67151 +static int
67152 +gr_search_connectbind(const int full_mode, struct sock *sk,
67153 + struct sockaddr_in *addr, const int type)
67154 +{
67155 + char iface[IFNAMSIZ] = {0};
67156 + struct acl_subject_label *curr;
67157 + struct acl_ip_label *ip;
67158 + struct inet_sock *isk;
67159 + struct net_device *dev;
67160 + struct in_device *idev;
67161 + unsigned long i;
67162 + int ret;
67163 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67164 + __u32 ip_addr = 0;
67165 + __u32 our_addr;
67166 + __u32 our_netmask;
67167 + char *p;
67168 + __u16 ip_port = 0;
67169 + const struct cred *cred = current_cred();
67170 +
67171 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67172 + return 0;
67173 +
67174 + curr = current->acl;
67175 + isk = inet_sk(sk);
67176 +
67177 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67178 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67179 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67180 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67181 + struct sockaddr_in saddr;
67182 + int err;
67183 +
67184 + saddr.sin_family = AF_INET;
67185 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67186 + saddr.sin_port = isk->inet_sport;
67187 +
67188 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67189 + if (err)
67190 + return err;
67191 +
67192 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67193 + if (err)
67194 + return err;
67195 + }
67196 +
67197 + if (!curr->ips)
67198 + return 0;
67199 +
67200 + ip_addr = addr->sin_addr.s_addr;
67201 + ip_port = ntohs(addr->sin_port);
67202 +
67203 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67204 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67205 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67206 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67207 + gr_to_filename(current->exec_file->f_path.dentry,
67208 + current->exec_file->f_path.mnt) :
67209 + curr->filename, curr->filename,
67210 + &ip_addr, ip_port, type,
67211 + sk->sk_protocol, mode, &current->signal->saved_ip);
67212 + return 0;
67213 + }
67214 +
67215 + for (i = 0; i < curr->ip_num; i++) {
67216 + ip = *(curr->ips + i);
67217 + if (ip->iface != NULL) {
67218 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67219 + p = strchr(iface, ':');
67220 + if (p != NULL)
67221 + *p = '\0';
67222 + dev = dev_get_by_name(sock_net(sk), iface);
67223 + if (dev == NULL)
67224 + continue;
67225 + idev = in_dev_get(dev);
67226 + if (idev == NULL) {
67227 + dev_put(dev);
67228 + continue;
67229 + }
67230 + rcu_read_lock();
67231 + for_ifa(idev) {
67232 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67233 + our_addr = ifa->ifa_address;
67234 + our_netmask = 0xffffffff;
67235 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67236 + if (ret == 1) {
67237 + rcu_read_unlock();
67238 + in_dev_put(idev);
67239 + dev_put(dev);
67240 + return 0;
67241 + } else if (ret == 2) {
67242 + rcu_read_unlock();
67243 + in_dev_put(idev);
67244 + dev_put(dev);
67245 + goto denied;
67246 + }
67247 + }
67248 + } endfor_ifa(idev);
67249 + rcu_read_unlock();
67250 + in_dev_put(idev);
67251 + dev_put(dev);
67252 + } else {
67253 + our_addr = ip->addr;
67254 + our_netmask = ip->netmask;
67255 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67256 + if (ret == 1)
67257 + return 0;
67258 + else if (ret == 2)
67259 + goto denied;
67260 + }
67261 + }
67262 +
67263 +denied:
67264 + if (mode == GR_BIND)
67265 + 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));
67266 + else if (mode == GR_CONNECT)
67267 + 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));
67268 +
67269 + return -EACCES;
67270 +}
67271 +
67272 +int
67273 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67274 +{
67275 + /* always allow disconnection of dgram sockets with connect */
67276 + if (addr->sin_family == AF_UNSPEC)
67277 + return 0;
67278 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67279 +}
67280 +
67281 +int
67282 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67283 +{
67284 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67285 +}
67286 +
67287 +int gr_search_listen(struct socket *sock)
67288 +{
67289 + struct sock *sk = sock->sk;
67290 + struct sockaddr_in addr;
67291 +
67292 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67293 + addr.sin_port = inet_sk(sk)->inet_sport;
67294 +
67295 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67296 +}
67297 +
67298 +int gr_search_accept(struct socket *sock)
67299 +{
67300 + struct sock *sk = sock->sk;
67301 + struct sockaddr_in addr;
67302 +
67303 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67304 + addr.sin_port = inet_sk(sk)->inet_sport;
67305 +
67306 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67307 +}
67308 +
67309 +int
67310 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67311 +{
67312 + if (addr)
67313 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67314 + else {
67315 + struct sockaddr_in sin;
67316 + const struct inet_sock *inet = inet_sk(sk);
67317 +
67318 + sin.sin_addr.s_addr = inet->inet_daddr;
67319 + sin.sin_port = inet->inet_dport;
67320 +
67321 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67322 + }
67323 +}
67324 +
67325 +int
67326 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67327 +{
67328 + struct sockaddr_in sin;
67329 +
67330 + if (unlikely(skb->len < sizeof (struct udphdr)))
67331 + return 0; // skip this packet
67332 +
67333 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67334 + sin.sin_port = udp_hdr(skb)->source;
67335 +
67336 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67337 +}
67338 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67339 new file mode 100644
67340 index 0000000..25f54ef
67341 --- /dev/null
67342 +++ b/grsecurity/gracl_learn.c
67343 @@ -0,0 +1,207 @@
67344 +#include <linux/kernel.h>
67345 +#include <linux/mm.h>
67346 +#include <linux/sched.h>
67347 +#include <linux/poll.h>
67348 +#include <linux/string.h>
67349 +#include <linux/file.h>
67350 +#include <linux/types.h>
67351 +#include <linux/vmalloc.h>
67352 +#include <linux/grinternal.h>
67353 +
67354 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67355 + size_t count, loff_t *ppos);
67356 +extern int gr_acl_is_enabled(void);
67357 +
67358 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67359 +static int gr_learn_attached;
67360 +
67361 +/* use a 512k buffer */
67362 +#define LEARN_BUFFER_SIZE (512 * 1024)
67363 +
67364 +static DEFINE_SPINLOCK(gr_learn_lock);
67365 +static DEFINE_MUTEX(gr_learn_user_mutex);
67366 +
67367 +/* we need to maintain two buffers, so that the kernel context of grlearn
67368 + uses a semaphore around the userspace copying, and the other kernel contexts
67369 + use a spinlock when copying into the buffer, since they cannot sleep
67370 +*/
67371 +static char *learn_buffer;
67372 +static char *learn_buffer_user;
67373 +static int learn_buffer_len;
67374 +static int learn_buffer_user_len;
67375 +
67376 +static ssize_t
67377 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67378 +{
67379 + DECLARE_WAITQUEUE(wait, current);
67380 + ssize_t retval = 0;
67381 +
67382 + add_wait_queue(&learn_wait, &wait);
67383 + set_current_state(TASK_INTERRUPTIBLE);
67384 + do {
67385 + mutex_lock(&gr_learn_user_mutex);
67386 + spin_lock(&gr_learn_lock);
67387 + if (learn_buffer_len)
67388 + break;
67389 + spin_unlock(&gr_learn_lock);
67390 + mutex_unlock(&gr_learn_user_mutex);
67391 + if (file->f_flags & O_NONBLOCK) {
67392 + retval = -EAGAIN;
67393 + goto out;
67394 + }
67395 + if (signal_pending(current)) {
67396 + retval = -ERESTARTSYS;
67397 + goto out;
67398 + }
67399 +
67400 + schedule();
67401 + } while (1);
67402 +
67403 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
67404 + learn_buffer_user_len = learn_buffer_len;
67405 + retval = learn_buffer_len;
67406 + learn_buffer_len = 0;
67407 +
67408 + spin_unlock(&gr_learn_lock);
67409 +
67410 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
67411 + retval = -EFAULT;
67412 +
67413 + mutex_unlock(&gr_learn_user_mutex);
67414 +out:
67415 + set_current_state(TASK_RUNNING);
67416 + remove_wait_queue(&learn_wait, &wait);
67417 + return retval;
67418 +}
67419 +
67420 +static unsigned int
67421 +poll_learn(struct file * file, poll_table * wait)
67422 +{
67423 + poll_wait(file, &learn_wait, wait);
67424 +
67425 + if (learn_buffer_len)
67426 + return (POLLIN | POLLRDNORM);
67427 +
67428 + return 0;
67429 +}
67430 +
67431 +void
67432 +gr_clear_learn_entries(void)
67433 +{
67434 + char *tmp;
67435 +
67436 + mutex_lock(&gr_learn_user_mutex);
67437 + spin_lock(&gr_learn_lock);
67438 + tmp = learn_buffer;
67439 + learn_buffer = NULL;
67440 + spin_unlock(&gr_learn_lock);
67441 + if (tmp)
67442 + vfree(tmp);
67443 + if (learn_buffer_user != NULL) {
67444 + vfree(learn_buffer_user);
67445 + learn_buffer_user = NULL;
67446 + }
67447 + learn_buffer_len = 0;
67448 + mutex_unlock(&gr_learn_user_mutex);
67449 +
67450 + return;
67451 +}
67452 +
67453 +void
67454 +gr_add_learn_entry(const char *fmt, ...)
67455 +{
67456 + va_list args;
67457 + unsigned int len;
67458 +
67459 + if (!gr_learn_attached)
67460 + return;
67461 +
67462 + spin_lock(&gr_learn_lock);
67463 +
67464 + /* leave a gap at the end so we know when it's "full" but don't have to
67465 + compute the exact length of the string we're trying to append
67466 + */
67467 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67468 + spin_unlock(&gr_learn_lock);
67469 + wake_up_interruptible(&learn_wait);
67470 + return;
67471 + }
67472 + if (learn_buffer == NULL) {
67473 + spin_unlock(&gr_learn_lock);
67474 + return;
67475 + }
67476 +
67477 + va_start(args, fmt);
67478 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
67479 + va_end(args);
67480 +
67481 + learn_buffer_len += len + 1;
67482 +
67483 + spin_unlock(&gr_learn_lock);
67484 + wake_up_interruptible(&learn_wait);
67485 +
67486 + return;
67487 +}
67488 +
67489 +static int
67490 +open_learn(struct inode *inode, struct file *file)
67491 +{
67492 + if (file->f_mode & FMODE_READ && gr_learn_attached)
67493 + return -EBUSY;
67494 + if (file->f_mode & FMODE_READ) {
67495 + int retval = 0;
67496 + mutex_lock(&gr_learn_user_mutex);
67497 + if (learn_buffer == NULL)
67498 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
67499 + if (learn_buffer_user == NULL)
67500 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
67501 + if (learn_buffer == NULL) {
67502 + retval = -ENOMEM;
67503 + goto out_error;
67504 + }
67505 + if (learn_buffer_user == NULL) {
67506 + retval = -ENOMEM;
67507 + goto out_error;
67508 + }
67509 + learn_buffer_len = 0;
67510 + learn_buffer_user_len = 0;
67511 + gr_learn_attached = 1;
67512 +out_error:
67513 + mutex_unlock(&gr_learn_user_mutex);
67514 + return retval;
67515 + }
67516 + return 0;
67517 +}
67518 +
67519 +static int
67520 +close_learn(struct inode *inode, struct file *file)
67521 +{
67522 + if (file->f_mode & FMODE_READ) {
67523 + char *tmp = NULL;
67524 + mutex_lock(&gr_learn_user_mutex);
67525 + spin_lock(&gr_learn_lock);
67526 + tmp = learn_buffer;
67527 + learn_buffer = NULL;
67528 + spin_unlock(&gr_learn_lock);
67529 + if (tmp)
67530 + vfree(tmp);
67531 + if (learn_buffer_user != NULL) {
67532 + vfree(learn_buffer_user);
67533 + learn_buffer_user = NULL;
67534 + }
67535 + learn_buffer_len = 0;
67536 + learn_buffer_user_len = 0;
67537 + gr_learn_attached = 0;
67538 + mutex_unlock(&gr_learn_user_mutex);
67539 + }
67540 +
67541 + return 0;
67542 +}
67543 +
67544 +const struct file_operations grsec_fops = {
67545 + .read = read_learn,
67546 + .write = write_grsec_handler,
67547 + .open = open_learn,
67548 + .release = close_learn,
67549 + .poll = poll_learn,
67550 +};
67551 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
67552 new file mode 100644
67553 index 0000000..39645c9
67554 --- /dev/null
67555 +++ b/grsecurity/gracl_res.c
67556 @@ -0,0 +1,68 @@
67557 +#include <linux/kernel.h>
67558 +#include <linux/sched.h>
67559 +#include <linux/gracl.h>
67560 +#include <linux/grinternal.h>
67561 +
67562 +static const char *restab_log[] = {
67563 + [RLIMIT_CPU] = "RLIMIT_CPU",
67564 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
67565 + [RLIMIT_DATA] = "RLIMIT_DATA",
67566 + [RLIMIT_STACK] = "RLIMIT_STACK",
67567 + [RLIMIT_CORE] = "RLIMIT_CORE",
67568 + [RLIMIT_RSS] = "RLIMIT_RSS",
67569 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
67570 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
67571 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
67572 + [RLIMIT_AS] = "RLIMIT_AS",
67573 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
67574 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
67575 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
67576 + [RLIMIT_NICE] = "RLIMIT_NICE",
67577 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
67578 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
67579 + [GR_CRASH_RES] = "RLIMIT_CRASH"
67580 +};
67581 +
67582 +void
67583 +gr_log_resource(const struct task_struct *task,
67584 + const int res, const unsigned long wanted, const int gt)
67585 +{
67586 + const struct cred *cred;
67587 + unsigned long rlim;
67588 +
67589 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
67590 + return;
67591 +
67592 + // not yet supported resource
67593 + if (unlikely(!restab_log[res]))
67594 + return;
67595 +
67596 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
67597 + rlim = task_rlimit_max(task, res);
67598 + else
67599 + rlim = task_rlimit(task, res);
67600 +
67601 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
67602 + return;
67603 +
67604 + rcu_read_lock();
67605 + cred = __task_cred(task);
67606 +
67607 + if (res == RLIMIT_NPROC &&
67608 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
67609 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
67610 + goto out_rcu_unlock;
67611 + else if (res == RLIMIT_MEMLOCK &&
67612 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
67613 + goto out_rcu_unlock;
67614 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
67615 + goto out_rcu_unlock;
67616 + rcu_read_unlock();
67617 +
67618 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
67619 +
67620 + return;
67621 +out_rcu_unlock:
67622 + rcu_read_unlock();
67623 + return;
67624 +}
67625 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
67626 new file mode 100644
67627 index 0000000..3c38bfe
67628 --- /dev/null
67629 +++ b/grsecurity/gracl_segv.c
67630 @@ -0,0 +1,305 @@
67631 +#include <linux/kernel.h>
67632 +#include <linux/mm.h>
67633 +#include <asm/uaccess.h>
67634 +#include <asm/errno.h>
67635 +#include <asm/mman.h>
67636 +#include <net/sock.h>
67637 +#include <linux/file.h>
67638 +#include <linux/fs.h>
67639 +#include <linux/net.h>
67640 +#include <linux/in.h>
67641 +#include <linux/slab.h>
67642 +#include <linux/types.h>
67643 +#include <linux/sched.h>
67644 +#include <linux/timer.h>
67645 +#include <linux/gracl.h>
67646 +#include <linux/grsecurity.h>
67647 +#include <linux/grinternal.h>
67648 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
67649 +#include <linux/magic.h>
67650 +#include <linux/pagemap.h>
67651 +#include "../fs/btrfs/async-thread.h"
67652 +#include "../fs/btrfs/ctree.h"
67653 +#include "../fs/btrfs/btrfs_inode.h"
67654 +#endif
67655 +
67656 +static struct crash_uid *uid_set;
67657 +static unsigned short uid_used;
67658 +static DEFINE_SPINLOCK(gr_uid_lock);
67659 +extern rwlock_t gr_inode_lock;
67660 +extern struct acl_subject_label *
67661 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
67662 + struct acl_role_label *role);
67663 +
67664 +static inline dev_t __get_dev(const struct dentry *dentry)
67665 +{
67666 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
67667 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
67668 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
67669 + else
67670 +#endif
67671 + return dentry->d_sb->s_dev;
67672 +}
67673 +
67674 +int
67675 +gr_init_uidset(void)
67676 +{
67677 + uid_set =
67678 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
67679 + uid_used = 0;
67680 +
67681 + return uid_set ? 1 : 0;
67682 +}
67683 +
67684 +void
67685 +gr_free_uidset(void)
67686 +{
67687 + if (uid_set)
67688 + kfree(uid_set);
67689 +
67690 + return;
67691 +}
67692 +
67693 +int
67694 +gr_find_uid(const uid_t uid)
67695 +{
67696 + struct crash_uid *tmp = uid_set;
67697 + uid_t buid;
67698 + int low = 0, high = uid_used - 1, mid;
67699 +
67700 + while (high >= low) {
67701 + mid = (low + high) >> 1;
67702 + buid = tmp[mid].uid;
67703 + if (buid == uid)
67704 + return mid;
67705 + if (buid > uid)
67706 + high = mid - 1;
67707 + if (buid < uid)
67708 + low = mid + 1;
67709 + }
67710 +
67711 + return -1;
67712 +}
67713 +
67714 +static __inline__ void
67715 +gr_insertsort(void)
67716 +{
67717 + unsigned short i, j;
67718 + struct crash_uid index;
67719 +
67720 + for (i = 1; i < uid_used; i++) {
67721 + index = uid_set[i];
67722 + j = i;
67723 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
67724 + uid_set[j] = uid_set[j - 1];
67725 + j--;
67726 + }
67727 + uid_set[j] = index;
67728 + }
67729 +
67730 + return;
67731 +}
67732 +
67733 +static __inline__ void
67734 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
67735 +{
67736 + int loc;
67737 + uid_t uid = GR_GLOBAL_UID(kuid);
67738 +
67739 + if (uid_used == GR_UIDTABLE_MAX)
67740 + return;
67741 +
67742 + loc = gr_find_uid(uid);
67743 +
67744 + if (loc >= 0) {
67745 + uid_set[loc].expires = expires;
67746 + return;
67747 + }
67748 +
67749 + uid_set[uid_used].uid = uid;
67750 + uid_set[uid_used].expires = expires;
67751 + uid_used++;
67752 +
67753 + gr_insertsort();
67754 +
67755 + return;
67756 +}
67757 +
67758 +void
67759 +gr_remove_uid(const unsigned short loc)
67760 +{
67761 + unsigned short i;
67762 +
67763 + for (i = loc + 1; i < uid_used; i++)
67764 + uid_set[i - 1] = uid_set[i];
67765 +
67766 + uid_used--;
67767 +
67768 + return;
67769 +}
67770 +
67771 +int
67772 +gr_check_crash_uid(const kuid_t kuid)
67773 +{
67774 + int loc;
67775 + int ret = 0;
67776 + uid_t uid;
67777 +
67778 + if (unlikely(!gr_acl_is_enabled()))
67779 + return 0;
67780 +
67781 + uid = GR_GLOBAL_UID(kuid);
67782 +
67783 + spin_lock(&gr_uid_lock);
67784 + loc = gr_find_uid(uid);
67785 +
67786 + if (loc < 0)
67787 + goto out_unlock;
67788 +
67789 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
67790 + gr_remove_uid(loc);
67791 + else
67792 + ret = 1;
67793 +
67794 +out_unlock:
67795 + spin_unlock(&gr_uid_lock);
67796 + return ret;
67797 +}
67798 +
67799 +static __inline__ int
67800 +proc_is_setxid(const struct cred *cred)
67801 +{
67802 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
67803 + !uid_eq(cred->uid, cred->fsuid))
67804 + return 1;
67805 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
67806 + !gid_eq(cred->gid, cred->fsgid))
67807 + return 1;
67808 +
67809 + return 0;
67810 +}
67811 +
67812 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
67813 +
67814 +void
67815 +gr_handle_crash(struct task_struct *task, const int sig)
67816 +{
67817 + struct acl_subject_label *curr;
67818 + struct task_struct *tsk, *tsk2;
67819 + const struct cred *cred;
67820 + const struct cred *cred2;
67821 +
67822 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
67823 + return;
67824 +
67825 + if (unlikely(!gr_acl_is_enabled()))
67826 + return;
67827 +
67828 + curr = task->acl;
67829 +
67830 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
67831 + return;
67832 +
67833 + if (time_before_eq(curr->expires, get_seconds())) {
67834 + curr->expires = 0;
67835 + curr->crashes = 0;
67836 + }
67837 +
67838 + curr->crashes++;
67839 +
67840 + if (!curr->expires)
67841 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
67842 +
67843 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
67844 + time_after(curr->expires, get_seconds())) {
67845 + rcu_read_lock();
67846 + cred = __task_cred(task);
67847 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
67848 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
67849 + spin_lock(&gr_uid_lock);
67850 + gr_insert_uid(cred->uid, curr->expires);
67851 + spin_unlock(&gr_uid_lock);
67852 + curr->expires = 0;
67853 + curr->crashes = 0;
67854 + read_lock(&tasklist_lock);
67855 + do_each_thread(tsk2, tsk) {
67856 + cred2 = __task_cred(tsk);
67857 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
67858 + gr_fake_force_sig(SIGKILL, tsk);
67859 + } while_each_thread(tsk2, tsk);
67860 + read_unlock(&tasklist_lock);
67861 + } else {
67862 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
67863 + read_lock(&tasklist_lock);
67864 + read_lock(&grsec_exec_file_lock);
67865 + do_each_thread(tsk2, tsk) {
67866 + if (likely(tsk != task)) {
67867 + // if this thread has the same subject as the one that triggered
67868 + // RES_CRASH and it's the same binary, kill it
67869 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
67870 + gr_fake_force_sig(SIGKILL, tsk);
67871 + }
67872 + } while_each_thread(tsk2, tsk);
67873 + read_unlock(&grsec_exec_file_lock);
67874 + read_unlock(&tasklist_lock);
67875 + }
67876 + rcu_read_unlock();
67877 + }
67878 +
67879 + return;
67880 +}
67881 +
67882 +int
67883 +gr_check_crash_exec(const struct file *filp)
67884 +{
67885 + struct acl_subject_label *curr;
67886 +
67887 + if (unlikely(!gr_acl_is_enabled()))
67888 + return 0;
67889 +
67890 + read_lock(&gr_inode_lock);
67891 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
67892 + __get_dev(filp->f_path.dentry),
67893 + current->role);
67894 + read_unlock(&gr_inode_lock);
67895 +
67896 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
67897 + (!curr->crashes && !curr->expires))
67898 + return 0;
67899 +
67900 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
67901 + time_after(curr->expires, get_seconds()))
67902 + return 1;
67903 + else if (time_before_eq(curr->expires, get_seconds())) {
67904 + curr->crashes = 0;
67905 + curr->expires = 0;
67906 + }
67907 +
67908 + return 0;
67909 +}
67910 +
67911 +void
67912 +gr_handle_alertkill(struct task_struct *task)
67913 +{
67914 + struct acl_subject_label *curracl;
67915 + __u32 curr_ip;
67916 + struct task_struct *p, *p2;
67917 +
67918 + if (unlikely(!gr_acl_is_enabled()))
67919 + return;
67920 +
67921 + curracl = task->acl;
67922 + curr_ip = task->signal->curr_ip;
67923 +
67924 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
67925 + read_lock(&tasklist_lock);
67926 + do_each_thread(p2, p) {
67927 + if (p->signal->curr_ip == curr_ip)
67928 + gr_fake_force_sig(SIGKILL, p);
67929 + } while_each_thread(p2, p);
67930 + read_unlock(&tasklist_lock);
67931 + } else if (curracl->mode & GR_KILLPROC)
67932 + gr_fake_force_sig(SIGKILL, task);
67933 +
67934 + return;
67935 +}
67936 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
67937 new file mode 100644
67938 index 0000000..98011b0
67939 --- /dev/null
67940 +++ b/grsecurity/gracl_shm.c
67941 @@ -0,0 +1,40 @@
67942 +#include <linux/kernel.h>
67943 +#include <linux/mm.h>
67944 +#include <linux/sched.h>
67945 +#include <linux/file.h>
67946 +#include <linux/ipc.h>
67947 +#include <linux/gracl.h>
67948 +#include <linux/grsecurity.h>
67949 +#include <linux/grinternal.h>
67950 +
67951 +int
67952 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
67953 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
67954 +{
67955 + struct task_struct *task;
67956 +
67957 + if (!gr_acl_is_enabled())
67958 + return 1;
67959 +
67960 + rcu_read_lock();
67961 + read_lock(&tasklist_lock);
67962 +
67963 + task = find_task_by_vpid(shm_cprid);
67964 +
67965 + if (unlikely(!task))
67966 + task = find_task_by_vpid(shm_lapid);
67967 +
67968 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
67969 + (task_pid_nr(task) == shm_lapid)) &&
67970 + (task->acl->mode & GR_PROTSHM) &&
67971 + (task->acl != current->acl))) {
67972 + read_unlock(&tasklist_lock);
67973 + rcu_read_unlock();
67974 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
67975 + return 0;
67976 + }
67977 + read_unlock(&tasklist_lock);
67978 + rcu_read_unlock();
67979 +
67980 + return 1;
67981 +}
67982 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
67983 new file mode 100644
67984 index 0000000..bc0be01
67985 --- /dev/null
67986 +++ b/grsecurity/grsec_chdir.c
67987 @@ -0,0 +1,19 @@
67988 +#include <linux/kernel.h>
67989 +#include <linux/sched.h>
67990 +#include <linux/fs.h>
67991 +#include <linux/file.h>
67992 +#include <linux/grsecurity.h>
67993 +#include <linux/grinternal.h>
67994 +
67995 +void
67996 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
67997 +{
67998 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
67999 + if ((grsec_enable_chdir && grsec_enable_group &&
68000 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
68001 + !grsec_enable_group)) {
68002 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
68003 + }
68004 +#endif
68005 + return;
68006 +}
68007 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
68008 new file mode 100644
68009 index 0000000..bd6e105
68010 --- /dev/null
68011 +++ b/grsecurity/grsec_chroot.c
68012 @@ -0,0 +1,370 @@
68013 +#include <linux/kernel.h>
68014 +#include <linux/module.h>
68015 +#include <linux/sched.h>
68016 +#include <linux/file.h>
68017 +#include <linux/fs.h>
68018 +#include <linux/mount.h>
68019 +#include <linux/types.h>
68020 +#include "../fs/mount.h"
68021 +#include <linux/grsecurity.h>
68022 +#include <linux/grinternal.h>
68023 +
68024 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68025 +static int gr_init_ran;
68026 +#endif
68027 +
68028 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
68029 +{
68030 +#ifdef CONFIG_GRKERNSEC
68031 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
68032 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
68033 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68034 + && gr_init_ran
68035 +#endif
68036 + )
68037 + task->gr_is_chrooted = 1;
68038 + else {
68039 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68040 + if (task_pid_nr(task) == 1 && !gr_init_ran)
68041 + gr_init_ran = 1;
68042 +#endif
68043 + task->gr_is_chrooted = 0;
68044 + }
68045 +
68046 + task->gr_chroot_dentry = path->dentry;
68047 +#endif
68048 + return;
68049 +}
68050 +
68051 +void gr_clear_chroot_entries(struct task_struct *task)
68052 +{
68053 +#ifdef CONFIG_GRKERNSEC
68054 + task->gr_is_chrooted = 0;
68055 + task->gr_chroot_dentry = NULL;
68056 +#endif
68057 + return;
68058 +}
68059 +
68060 +int
68061 +gr_handle_chroot_unix(const pid_t pid)
68062 +{
68063 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
68064 + struct task_struct *p;
68065 +
68066 + if (unlikely(!grsec_enable_chroot_unix))
68067 + return 1;
68068 +
68069 + if (likely(!proc_is_chrooted(current)))
68070 + return 1;
68071 +
68072 + rcu_read_lock();
68073 + read_lock(&tasklist_lock);
68074 + p = find_task_by_vpid_unrestricted(pid);
68075 + if (unlikely(p && !have_same_root(current, p))) {
68076 + read_unlock(&tasklist_lock);
68077 + rcu_read_unlock();
68078 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
68079 + return 0;
68080 + }
68081 + read_unlock(&tasklist_lock);
68082 + rcu_read_unlock();
68083 +#endif
68084 + return 1;
68085 +}
68086 +
68087 +int
68088 +gr_handle_chroot_nice(void)
68089 +{
68090 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68091 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
68092 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
68093 + return -EPERM;
68094 + }
68095 +#endif
68096 + return 0;
68097 +}
68098 +
68099 +int
68100 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
68101 +{
68102 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68103 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
68104 + && proc_is_chrooted(current)) {
68105 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
68106 + return -EACCES;
68107 + }
68108 +#endif
68109 + return 0;
68110 +}
68111 +
68112 +int
68113 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
68114 +{
68115 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68116 + struct task_struct *p;
68117 + int ret = 0;
68118 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
68119 + return ret;
68120 +
68121 + read_lock(&tasklist_lock);
68122 + do_each_pid_task(pid, type, p) {
68123 + if (!have_same_root(current, p)) {
68124 + ret = 1;
68125 + goto out;
68126 + }
68127 + } while_each_pid_task(pid, type, p);
68128 +out:
68129 + read_unlock(&tasklist_lock);
68130 + return ret;
68131 +#endif
68132 + return 0;
68133 +}
68134 +
68135 +int
68136 +gr_pid_is_chrooted(struct task_struct *p)
68137 +{
68138 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68139 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
68140 + return 0;
68141 +
68142 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
68143 + !have_same_root(current, p)) {
68144 + return 1;
68145 + }
68146 +#endif
68147 + return 0;
68148 +}
68149 +
68150 +EXPORT_SYMBOL(gr_pid_is_chrooted);
68151 +
68152 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
68153 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
68154 +{
68155 + struct path path, currentroot;
68156 + int ret = 0;
68157 +
68158 + path.dentry = (struct dentry *)u_dentry;
68159 + path.mnt = (struct vfsmount *)u_mnt;
68160 + get_fs_root(current->fs, &currentroot);
68161 + if (path_is_under(&path, &currentroot))
68162 + ret = 1;
68163 + path_put(&currentroot);
68164 +
68165 + return ret;
68166 +}
68167 +#endif
68168 +
68169 +int
68170 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
68171 +{
68172 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
68173 + if (!grsec_enable_chroot_fchdir)
68174 + return 1;
68175 +
68176 + if (!proc_is_chrooted(current))
68177 + return 1;
68178 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
68179 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
68180 + return 0;
68181 + }
68182 +#endif
68183 + return 1;
68184 +}
68185 +
68186 +int
68187 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68188 + const time_t shm_createtime)
68189 +{
68190 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
68191 + struct task_struct *p;
68192 + time_t starttime;
68193 +
68194 + if (unlikely(!grsec_enable_chroot_shmat))
68195 + return 1;
68196 +
68197 + if (likely(!proc_is_chrooted(current)))
68198 + return 1;
68199 +
68200 + rcu_read_lock();
68201 + read_lock(&tasklist_lock);
68202 +
68203 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
68204 + starttime = p->start_time.tv_sec;
68205 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
68206 + if (have_same_root(current, p)) {
68207 + goto allow;
68208 + } else {
68209 + read_unlock(&tasklist_lock);
68210 + rcu_read_unlock();
68211 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68212 + return 0;
68213 + }
68214 + }
68215 + /* creator exited, pid reuse, fall through to next check */
68216 + }
68217 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
68218 + if (unlikely(!have_same_root(current, p))) {
68219 + read_unlock(&tasklist_lock);
68220 + rcu_read_unlock();
68221 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68222 + return 0;
68223 + }
68224 + }
68225 +
68226 +allow:
68227 + read_unlock(&tasklist_lock);
68228 + rcu_read_unlock();
68229 +#endif
68230 + return 1;
68231 +}
68232 +
68233 +void
68234 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
68235 +{
68236 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
68237 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
68238 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
68239 +#endif
68240 + return;
68241 +}
68242 +
68243 +int
68244 +gr_handle_chroot_mknod(const struct dentry *dentry,
68245 + const struct vfsmount *mnt, const int mode)
68246 +{
68247 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
68248 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
68249 + proc_is_chrooted(current)) {
68250 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
68251 + return -EPERM;
68252 + }
68253 +#endif
68254 + return 0;
68255 +}
68256 +
68257 +int
68258 +gr_handle_chroot_mount(const struct dentry *dentry,
68259 + const struct vfsmount *mnt, const char *dev_name)
68260 +{
68261 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
68262 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
68263 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
68264 + return -EPERM;
68265 + }
68266 +#endif
68267 + return 0;
68268 +}
68269 +
68270 +int
68271 +gr_handle_chroot_pivot(void)
68272 +{
68273 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
68274 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
68275 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
68276 + return -EPERM;
68277 + }
68278 +#endif
68279 + return 0;
68280 +}
68281 +
68282 +int
68283 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
68284 +{
68285 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
68286 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
68287 + !gr_is_outside_chroot(dentry, mnt)) {
68288 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
68289 + return -EPERM;
68290 + }
68291 +#endif
68292 + return 0;
68293 +}
68294 +
68295 +extern const char *captab_log[];
68296 +extern int captab_log_entries;
68297 +
68298 +int
68299 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
68300 +{
68301 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68302 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68303 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68304 + if (cap_raised(chroot_caps, cap)) {
68305 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
68306 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
68307 + }
68308 + return 0;
68309 + }
68310 + }
68311 +#endif
68312 + return 1;
68313 +}
68314 +
68315 +int
68316 +gr_chroot_is_capable(const int cap)
68317 +{
68318 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68319 + return gr_task_chroot_is_capable(current, current_cred(), cap);
68320 +#endif
68321 + return 1;
68322 +}
68323 +
68324 +int
68325 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
68326 +{
68327 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68328 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68329 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68330 + if (cap_raised(chroot_caps, cap)) {
68331 + return 0;
68332 + }
68333 + }
68334 +#endif
68335 + return 1;
68336 +}
68337 +
68338 +int
68339 +gr_chroot_is_capable_nolog(const int cap)
68340 +{
68341 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68342 + return gr_task_chroot_is_capable_nolog(current, cap);
68343 +#endif
68344 + return 1;
68345 +}
68346 +
68347 +int
68348 +gr_handle_chroot_sysctl(const int op)
68349 +{
68350 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
68351 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
68352 + proc_is_chrooted(current))
68353 + return -EACCES;
68354 +#endif
68355 + return 0;
68356 +}
68357 +
68358 +void
68359 +gr_handle_chroot_chdir(const struct path *path)
68360 +{
68361 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
68362 + if (grsec_enable_chroot_chdir)
68363 + set_fs_pwd(current->fs, path);
68364 +#endif
68365 + return;
68366 +}
68367 +
68368 +int
68369 +gr_handle_chroot_chmod(const struct dentry *dentry,
68370 + const struct vfsmount *mnt, const int mode)
68371 +{
68372 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
68373 + /* allow chmod +s on directories, but not files */
68374 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
68375 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
68376 + proc_is_chrooted(current)) {
68377 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
68378 + return -EPERM;
68379 + }
68380 +#endif
68381 + return 0;
68382 +}
68383 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
68384 new file mode 100644
68385 index 0000000..ce65ceb
68386 --- /dev/null
68387 +++ b/grsecurity/grsec_disabled.c
68388 @@ -0,0 +1,434 @@
68389 +#include <linux/kernel.h>
68390 +#include <linux/module.h>
68391 +#include <linux/sched.h>
68392 +#include <linux/file.h>
68393 +#include <linux/fs.h>
68394 +#include <linux/kdev_t.h>
68395 +#include <linux/net.h>
68396 +#include <linux/in.h>
68397 +#include <linux/ip.h>
68398 +#include <linux/skbuff.h>
68399 +#include <linux/sysctl.h>
68400 +
68401 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
68402 +void
68403 +pax_set_initial_flags(struct linux_binprm *bprm)
68404 +{
68405 + return;
68406 +}
68407 +#endif
68408 +
68409 +#ifdef CONFIG_SYSCTL
68410 +__u32
68411 +gr_handle_sysctl(const struct ctl_table * table, const int op)
68412 +{
68413 + return 0;
68414 +}
68415 +#endif
68416 +
68417 +#ifdef CONFIG_TASKSTATS
68418 +int gr_is_taskstats_denied(int pid)
68419 +{
68420 + return 0;
68421 +}
68422 +#endif
68423 +
68424 +int
68425 +gr_acl_is_enabled(void)
68426 +{
68427 + return 0;
68428 +}
68429 +
68430 +void
68431 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
68432 +{
68433 + return;
68434 +}
68435 +
68436 +int
68437 +gr_handle_rawio(const struct inode *inode)
68438 +{
68439 + return 0;
68440 +}
68441 +
68442 +void
68443 +gr_acl_handle_psacct(struct task_struct *task, const long code)
68444 +{
68445 + return;
68446 +}
68447 +
68448 +int
68449 +gr_handle_ptrace(struct task_struct *task, const long request)
68450 +{
68451 + return 0;
68452 +}
68453 +
68454 +int
68455 +gr_handle_proc_ptrace(struct task_struct *task)
68456 +{
68457 + return 0;
68458 +}
68459 +
68460 +int
68461 +gr_set_acls(const int type)
68462 +{
68463 + return 0;
68464 +}
68465 +
68466 +int
68467 +gr_check_hidden_task(const struct task_struct *tsk)
68468 +{
68469 + return 0;
68470 +}
68471 +
68472 +int
68473 +gr_check_protected_task(const struct task_struct *task)
68474 +{
68475 + return 0;
68476 +}
68477 +
68478 +int
68479 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
68480 +{
68481 + return 0;
68482 +}
68483 +
68484 +void
68485 +gr_copy_label(struct task_struct *tsk)
68486 +{
68487 + return;
68488 +}
68489 +
68490 +void
68491 +gr_set_pax_flags(struct task_struct *task)
68492 +{
68493 + return;
68494 +}
68495 +
68496 +int
68497 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
68498 + const int unsafe_share)
68499 +{
68500 + return 0;
68501 +}
68502 +
68503 +void
68504 +gr_handle_delete(const ino_t ino, const dev_t dev)
68505 +{
68506 + return;
68507 +}
68508 +
68509 +void
68510 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
68511 +{
68512 + return;
68513 +}
68514 +
68515 +void
68516 +gr_handle_crash(struct task_struct *task, const int sig)
68517 +{
68518 + return;
68519 +}
68520 +
68521 +int
68522 +gr_check_crash_exec(const struct file *filp)
68523 +{
68524 + return 0;
68525 +}
68526 +
68527 +int
68528 +gr_check_crash_uid(const kuid_t uid)
68529 +{
68530 + return 0;
68531 +}
68532 +
68533 +void
68534 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68535 + struct dentry *old_dentry,
68536 + struct dentry *new_dentry,
68537 + struct vfsmount *mnt, const __u8 replace)
68538 +{
68539 + return;
68540 +}
68541 +
68542 +int
68543 +gr_search_socket(const int family, const int type, const int protocol)
68544 +{
68545 + return 1;
68546 +}
68547 +
68548 +int
68549 +gr_search_connectbind(const int mode, const struct socket *sock,
68550 + const struct sockaddr_in *addr)
68551 +{
68552 + return 0;
68553 +}
68554 +
68555 +void
68556 +gr_handle_alertkill(struct task_struct *task)
68557 +{
68558 + return;
68559 +}
68560 +
68561 +__u32
68562 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
68563 +{
68564 + return 1;
68565 +}
68566 +
68567 +__u32
68568 +gr_acl_handle_hidden_file(const struct dentry * dentry,
68569 + const struct vfsmount * mnt)
68570 +{
68571 + return 1;
68572 +}
68573 +
68574 +__u32
68575 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
68576 + int acc_mode)
68577 +{
68578 + return 1;
68579 +}
68580 +
68581 +__u32
68582 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
68583 +{
68584 + return 1;
68585 +}
68586 +
68587 +__u32
68588 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
68589 +{
68590 + return 1;
68591 +}
68592 +
68593 +int
68594 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
68595 + unsigned int *vm_flags)
68596 +{
68597 + return 1;
68598 +}
68599 +
68600 +__u32
68601 +gr_acl_handle_truncate(const struct dentry * dentry,
68602 + const struct vfsmount * mnt)
68603 +{
68604 + return 1;
68605 +}
68606 +
68607 +__u32
68608 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
68609 +{
68610 + return 1;
68611 +}
68612 +
68613 +__u32
68614 +gr_acl_handle_access(const struct dentry * dentry,
68615 + const struct vfsmount * mnt, const int fmode)
68616 +{
68617 + return 1;
68618 +}
68619 +
68620 +__u32
68621 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
68622 + umode_t *mode)
68623 +{
68624 + return 1;
68625 +}
68626 +
68627 +__u32
68628 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
68629 +{
68630 + return 1;
68631 +}
68632 +
68633 +__u32
68634 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
68635 +{
68636 + return 1;
68637 +}
68638 +
68639 +void
68640 +grsecurity_init(void)
68641 +{
68642 + return;
68643 +}
68644 +
68645 +umode_t gr_acl_umask(void)
68646 +{
68647 + return 0;
68648 +}
68649 +
68650 +__u32
68651 +gr_acl_handle_mknod(const struct dentry * new_dentry,
68652 + const struct dentry * parent_dentry,
68653 + const struct vfsmount * parent_mnt,
68654 + const int mode)
68655 +{
68656 + return 1;
68657 +}
68658 +
68659 +__u32
68660 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
68661 + const struct dentry * parent_dentry,
68662 + const struct vfsmount * parent_mnt)
68663 +{
68664 + return 1;
68665 +}
68666 +
68667 +__u32
68668 +gr_acl_handle_symlink(const struct dentry * new_dentry,
68669 + const struct dentry * parent_dentry,
68670 + const struct vfsmount * parent_mnt, const struct filename *from)
68671 +{
68672 + return 1;
68673 +}
68674 +
68675 +__u32
68676 +gr_acl_handle_link(const struct dentry * new_dentry,
68677 + const struct dentry * parent_dentry,
68678 + const struct vfsmount * parent_mnt,
68679 + const struct dentry * old_dentry,
68680 + const struct vfsmount * old_mnt, const struct filename *to)
68681 +{
68682 + return 1;
68683 +}
68684 +
68685 +int
68686 +gr_acl_handle_rename(const struct dentry *new_dentry,
68687 + const struct dentry *parent_dentry,
68688 + const struct vfsmount *parent_mnt,
68689 + const struct dentry *old_dentry,
68690 + const struct inode *old_parent_inode,
68691 + const struct vfsmount *old_mnt, const struct filename *newname)
68692 +{
68693 + return 0;
68694 +}
68695 +
68696 +int
68697 +gr_acl_handle_filldir(const struct file *file, const char *name,
68698 + const int namelen, const ino_t ino)
68699 +{
68700 + return 1;
68701 +}
68702 +
68703 +int
68704 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68705 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
68706 +{
68707 + return 1;
68708 +}
68709 +
68710 +int
68711 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
68712 +{
68713 + return 0;
68714 +}
68715 +
68716 +int
68717 +gr_search_accept(const struct socket *sock)
68718 +{
68719 + return 0;
68720 +}
68721 +
68722 +int
68723 +gr_search_listen(const struct socket *sock)
68724 +{
68725 + return 0;
68726 +}
68727 +
68728 +int
68729 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
68730 +{
68731 + return 0;
68732 +}
68733 +
68734 +__u32
68735 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
68736 +{
68737 + return 1;
68738 +}
68739 +
68740 +__u32
68741 +gr_acl_handle_creat(const struct dentry * dentry,
68742 + const struct dentry * p_dentry,
68743 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
68744 + const int imode)
68745 +{
68746 + return 1;
68747 +}
68748 +
68749 +void
68750 +gr_acl_handle_exit(void)
68751 +{
68752 + return;
68753 +}
68754 +
68755 +int
68756 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
68757 +{
68758 + return 1;
68759 +}
68760 +
68761 +void
68762 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
68763 +{
68764 + return;
68765 +}
68766 +
68767 +int
68768 +gr_acl_handle_procpidmem(const struct task_struct *task)
68769 +{
68770 + return 0;
68771 +}
68772 +
68773 +int
68774 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
68775 +{
68776 + return 0;
68777 +}
68778 +
68779 +int
68780 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
68781 +{
68782 + return 0;
68783 +}
68784 +
68785 +void
68786 +gr_set_kernel_label(struct task_struct *task)
68787 +{
68788 + return;
68789 +}
68790 +
68791 +int
68792 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
68793 +{
68794 + return 0;
68795 +}
68796 +
68797 +int
68798 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
68799 +{
68800 + return 0;
68801 +}
68802 +
68803 +int gr_acl_enable_at_secure(void)
68804 +{
68805 + return 0;
68806 +}
68807 +
68808 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
68809 +{
68810 + return dentry->d_sb->s_dev;
68811 +}
68812 +
68813 +void gr_put_exec_file(struct task_struct *task)
68814 +{
68815 + return;
68816 +}
68817 +
68818 +EXPORT_SYMBOL(gr_set_kernel_label);
68819 +#ifdef CONFIG_SECURITY
68820 +EXPORT_SYMBOL(gr_check_user_change);
68821 +EXPORT_SYMBOL(gr_check_group_change);
68822 +#endif
68823 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
68824 new file mode 100644
68825 index 0000000..387032b
68826 --- /dev/null
68827 +++ b/grsecurity/grsec_exec.c
68828 @@ -0,0 +1,187 @@
68829 +#include <linux/kernel.h>
68830 +#include <linux/sched.h>
68831 +#include <linux/file.h>
68832 +#include <linux/binfmts.h>
68833 +#include <linux/fs.h>
68834 +#include <linux/types.h>
68835 +#include <linux/grdefs.h>
68836 +#include <linux/grsecurity.h>
68837 +#include <linux/grinternal.h>
68838 +#include <linux/capability.h>
68839 +#include <linux/module.h>
68840 +#include <linux/compat.h>
68841 +
68842 +#include <asm/uaccess.h>
68843 +
68844 +#ifdef CONFIG_GRKERNSEC_EXECLOG
68845 +static char gr_exec_arg_buf[132];
68846 +static DEFINE_MUTEX(gr_exec_arg_mutex);
68847 +#endif
68848 +
68849 +struct user_arg_ptr {
68850 +#ifdef CONFIG_COMPAT
68851 + bool is_compat;
68852 +#endif
68853 + union {
68854 + const char __user *const __user *native;
68855 +#ifdef CONFIG_COMPAT
68856 + const compat_uptr_t __user *compat;
68857 +#endif
68858 + } ptr;
68859 +};
68860 +
68861 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
68862 +
68863 +void
68864 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
68865 +{
68866 +#ifdef CONFIG_GRKERNSEC_EXECLOG
68867 + char *grarg = gr_exec_arg_buf;
68868 + unsigned int i, x, execlen = 0;
68869 + char c;
68870 +
68871 + if (!((grsec_enable_execlog && grsec_enable_group &&
68872 + in_group_p(grsec_audit_gid))
68873 + || (grsec_enable_execlog && !grsec_enable_group)))
68874 + return;
68875 +
68876 + mutex_lock(&gr_exec_arg_mutex);
68877 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
68878 +
68879 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
68880 + const char __user *p;
68881 + unsigned int len;
68882 +
68883 + p = get_user_arg_ptr(argv, i);
68884 + if (IS_ERR(p))
68885 + goto log;
68886 +
68887 + len = strnlen_user(p, 128 - execlen);
68888 + if (len > 128 - execlen)
68889 + len = 128 - execlen;
68890 + else if (len > 0)
68891 + len--;
68892 + if (copy_from_user(grarg + execlen, p, len))
68893 + goto log;
68894 +
68895 + /* rewrite unprintable characters */
68896 + for (x = 0; x < len; x++) {
68897 + c = *(grarg + execlen + x);
68898 + if (c < 32 || c > 126)
68899 + *(grarg + execlen + x) = ' ';
68900 + }
68901 +
68902 + execlen += len;
68903 + *(grarg + execlen) = ' ';
68904 + *(grarg + execlen + 1) = '\0';
68905 + execlen++;
68906 + }
68907 +
68908 + log:
68909 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
68910 + bprm->file->f_path.mnt, grarg);
68911 + mutex_unlock(&gr_exec_arg_mutex);
68912 +#endif
68913 + return;
68914 +}
68915 +
68916 +#ifdef CONFIG_GRKERNSEC
68917 +extern int gr_acl_is_capable(const int cap);
68918 +extern int gr_acl_is_capable_nolog(const int cap);
68919 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
68920 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
68921 +extern int gr_chroot_is_capable(const int cap);
68922 +extern int gr_chroot_is_capable_nolog(const int cap);
68923 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
68924 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
68925 +#endif
68926 +
68927 +const char *captab_log[] = {
68928 + "CAP_CHOWN",
68929 + "CAP_DAC_OVERRIDE",
68930 + "CAP_DAC_READ_SEARCH",
68931 + "CAP_FOWNER",
68932 + "CAP_FSETID",
68933 + "CAP_KILL",
68934 + "CAP_SETGID",
68935 + "CAP_SETUID",
68936 + "CAP_SETPCAP",
68937 + "CAP_LINUX_IMMUTABLE",
68938 + "CAP_NET_BIND_SERVICE",
68939 + "CAP_NET_BROADCAST",
68940 + "CAP_NET_ADMIN",
68941 + "CAP_NET_RAW",
68942 + "CAP_IPC_LOCK",
68943 + "CAP_IPC_OWNER",
68944 + "CAP_SYS_MODULE",
68945 + "CAP_SYS_RAWIO",
68946 + "CAP_SYS_CHROOT",
68947 + "CAP_SYS_PTRACE",
68948 + "CAP_SYS_PACCT",
68949 + "CAP_SYS_ADMIN",
68950 + "CAP_SYS_BOOT",
68951 + "CAP_SYS_NICE",
68952 + "CAP_SYS_RESOURCE",
68953 + "CAP_SYS_TIME",
68954 + "CAP_SYS_TTY_CONFIG",
68955 + "CAP_MKNOD",
68956 + "CAP_LEASE",
68957 + "CAP_AUDIT_WRITE",
68958 + "CAP_AUDIT_CONTROL",
68959 + "CAP_SETFCAP",
68960 + "CAP_MAC_OVERRIDE",
68961 + "CAP_MAC_ADMIN",
68962 + "CAP_SYSLOG",
68963 + "CAP_WAKE_ALARM"
68964 +};
68965 +
68966 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
68967 +
68968 +int gr_is_capable(const int cap)
68969 +{
68970 +#ifdef CONFIG_GRKERNSEC
68971 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
68972 + return 1;
68973 + return 0;
68974 +#else
68975 + return 1;
68976 +#endif
68977 +}
68978 +
68979 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
68980 +{
68981 +#ifdef CONFIG_GRKERNSEC
68982 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
68983 + return 1;
68984 + return 0;
68985 +#else
68986 + return 1;
68987 +#endif
68988 +}
68989 +
68990 +int gr_is_capable_nolog(const int cap)
68991 +{
68992 +#ifdef CONFIG_GRKERNSEC
68993 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
68994 + return 1;
68995 + return 0;
68996 +#else
68997 + return 1;
68998 +#endif
68999 +}
69000 +
69001 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
69002 +{
69003 +#ifdef CONFIG_GRKERNSEC
69004 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
69005 + return 1;
69006 + return 0;
69007 +#else
69008 + return 1;
69009 +#endif
69010 +}
69011 +
69012 +EXPORT_SYMBOL(gr_is_capable);
69013 +EXPORT_SYMBOL(gr_is_capable_nolog);
69014 +EXPORT_SYMBOL(gr_task_is_capable);
69015 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
69016 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
69017 new file mode 100644
69018 index 0000000..06cc6ea
69019 --- /dev/null
69020 +++ b/grsecurity/grsec_fifo.c
69021 @@ -0,0 +1,24 @@
69022 +#include <linux/kernel.h>
69023 +#include <linux/sched.h>
69024 +#include <linux/fs.h>
69025 +#include <linux/file.h>
69026 +#include <linux/grinternal.h>
69027 +
69028 +int
69029 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
69030 + const struct dentry *dir, const int flag, const int acc_mode)
69031 +{
69032 +#ifdef CONFIG_GRKERNSEC_FIFO
69033 + const struct cred *cred = current_cred();
69034 +
69035 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
69036 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
69037 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
69038 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
69039 + if (!inode_permission(dentry->d_inode, acc_mode))
69040 + gr_log_fs_int2(GR_DONT_AUDIT, GR_FIFO_MSG, dentry, mnt, GR_GLOBAL_UID(dentry->d_inode->i_uid), GR_GLOBAL_GID(dentry->d_inode->i_gid));
69041 + return -EACCES;
69042 + }
69043 +#endif
69044 + return 0;
69045 +}
69046 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
69047 new file mode 100644
69048 index 0000000..8ca18bf
69049 --- /dev/null
69050 +++ b/grsecurity/grsec_fork.c
69051 @@ -0,0 +1,23 @@
69052 +#include <linux/kernel.h>
69053 +#include <linux/sched.h>
69054 +#include <linux/grsecurity.h>
69055 +#include <linux/grinternal.h>
69056 +#include <linux/errno.h>
69057 +
69058 +void
69059 +gr_log_forkfail(const int retval)
69060 +{
69061 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69062 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
69063 + switch (retval) {
69064 + case -EAGAIN:
69065 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
69066 + break;
69067 + case -ENOMEM:
69068 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
69069 + break;
69070 + }
69071 + }
69072 +#endif
69073 + return;
69074 +}
69075 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
69076 new file mode 100644
69077 index 0000000..99a0cb9
69078 --- /dev/null
69079 +++ b/grsecurity/grsec_init.c
69080 @@ -0,0 +1,283 @@
69081 +#include <linux/kernel.h>
69082 +#include <linux/sched.h>
69083 +#include <linux/mm.h>
69084 +#include <linux/gracl.h>
69085 +#include <linux/slab.h>
69086 +#include <linux/vmalloc.h>
69087 +#include <linux/percpu.h>
69088 +#include <linux/module.h>
69089 +
69090 +int grsec_enable_ptrace_readexec;
69091 +int grsec_enable_setxid;
69092 +int grsec_enable_symlinkown;
69093 +kgid_t grsec_symlinkown_gid;
69094 +int grsec_enable_brute;
69095 +int grsec_enable_link;
69096 +int grsec_enable_dmesg;
69097 +int grsec_enable_harden_ptrace;
69098 +int grsec_enable_fifo;
69099 +int grsec_enable_execlog;
69100 +int grsec_enable_signal;
69101 +int grsec_enable_forkfail;
69102 +int grsec_enable_audit_ptrace;
69103 +int grsec_enable_time;
69104 +int grsec_enable_group;
69105 +kgid_t grsec_audit_gid;
69106 +int grsec_enable_chdir;
69107 +int grsec_enable_mount;
69108 +int grsec_enable_rofs;
69109 +int grsec_deny_new_usb;
69110 +int grsec_enable_chroot_findtask;
69111 +int grsec_enable_chroot_mount;
69112 +int grsec_enable_chroot_shmat;
69113 +int grsec_enable_chroot_fchdir;
69114 +int grsec_enable_chroot_double;
69115 +int grsec_enable_chroot_pivot;
69116 +int grsec_enable_chroot_chdir;
69117 +int grsec_enable_chroot_chmod;
69118 +int grsec_enable_chroot_mknod;
69119 +int grsec_enable_chroot_nice;
69120 +int grsec_enable_chroot_execlog;
69121 +int grsec_enable_chroot_caps;
69122 +int grsec_enable_chroot_sysctl;
69123 +int grsec_enable_chroot_unix;
69124 +int grsec_enable_tpe;
69125 +kgid_t grsec_tpe_gid;
69126 +int grsec_enable_blackhole;
69127 +#ifdef CONFIG_IPV6_MODULE
69128 +EXPORT_SYMBOL(grsec_enable_blackhole);
69129 +#endif
69130 +int grsec_lastack_retries;
69131 +int grsec_enable_tpe_all;
69132 +int grsec_enable_tpe_invert;
69133 +int grsec_enable_socket_all;
69134 +kgid_t grsec_socket_all_gid;
69135 +int grsec_enable_socket_client;
69136 +kgid_t grsec_socket_client_gid;
69137 +int grsec_enable_socket_server;
69138 +kgid_t grsec_socket_server_gid;
69139 +int grsec_resource_logging;
69140 +int grsec_disable_privio;
69141 +int grsec_enable_log_rwxmaps;
69142 +int grsec_lock;
69143 +
69144 +DEFINE_SPINLOCK(grsec_alert_lock);
69145 +unsigned long grsec_alert_wtime = 0;
69146 +unsigned long grsec_alert_fyet = 0;
69147 +
69148 +DEFINE_SPINLOCK(grsec_audit_lock);
69149 +
69150 +DEFINE_RWLOCK(grsec_exec_file_lock);
69151 +
69152 +char *gr_shared_page[4];
69153 +
69154 +char *gr_alert_log_fmt;
69155 +char *gr_audit_log_fmt;
69156 +char *gr_alert_log_buf;
69157 +char *gr_audit_log_buf;
69158 +
69159 +extern struct gr_arg *gr_usermode;
69160 +extern unsigned char *gr_system_salt;
69161 +extern unsigned char *gr_system_sum;
69162 +
69163 +void __init
69164 +grsecurity_init(void)
69165 +{
69166 + int j;
69167 + /* create the per-cpu shared pages */
69168 +
69169 +#ifdef CONFIG_X86
69170 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
69171 +#endif
69172 +
69173 + for (j = 0; j < 4; j++) {
69174 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
69175 + if (gr_shared_page[j] == NULL) {
69176 + panic("Unable to allocate grsecurity shared page");
69177 + return;
69178 + }
69179 + }
69180 +
69181 + /* allocate log buffers */
69182 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
69183 + if (!gr_alert_log_fmt) {
69184 + panic("Unable to allocate grsecurity alert log format buffer");
69185 + return;
69186 + }
69187 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
69188 + if (!gr_audit_log_fmt) {
69189 + panic("Unable to allocate grsecurity audit log format buffer");
69190 + return;
69191 + }
69192 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69193 + if (!gr_alert_log_buf) {
69194 + panic("Unable to allocate grsecurity alert log buffer");
69195 + return;
69196 + }
69197 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69198 + if (!gr_audit_log_buf) {
69199 + panic("Unable to allocate grsecurity audit log buffer");
69200 + return;
69201 + }
69202 +
69203 + /* allocate memory for authentication structure */
69204 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
69205 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
69206 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
69207 +
69208 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
69209 + panic("Unable to allocate grsecurity authentication structure");
69210 + return;
69211 + }
69212 +
69213 +
69214 +#ifdef CONFIG_GRKERNSEC_IO
69215 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
69216 + grsec_disable_privio = 1;
69217 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69218 + grsec_disable_privio = 1;
69219 +#else
69220 + grsec_disable_privio = 0;
69221 +#endif
69222 +#endif
69223 +
69224 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69225 + /* for backward compatibility, tpe_invert always defaults to on if
69226 + enabled in the kernel
69227 + */
69228 + grsec_enable_tpe_invert = 1;
69229 +#endif
69230 +
69231 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69232 +#ifndef CONFIG_GRKERNSEC_SYSCTL
69233 + grsec_lock = 1;
69234 +#endif
69235 +
69236 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69237 + grsec_enable_log_rwxmaps = 1;
69238 +#endif
69239 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
69240 + grsec_enable_group = 1;
69241 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
69242 +#endif
69243 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69244 + grsec_enable_ptrace_readexec = 1;
69245 +#endif
69246 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69247 + grsec_enable_chdir = 1;
69248 +#endif
69249 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69250 + grsec_enable_harden_ptrace = 1;
69251 +#endif
69252 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69253 + grsec_enable_mount = 1;
69254 +#endif
69255 +#ifdef CONFIG_GRKERNSEC_LINK
69256 + grsec_enable_link = 1;
69257 +#endif
69258 +#ifdef CONFIG_GRKERNSEC_BRUTE
69259 + grsec_enable_brute = 1;
69260 +#endif
69261 +#ifdef CONFIG_GRKERNSEC_DMESG
69262 + grsec_enable_dmesg = 1;
69263 +#endif
69264 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
69265 + grsec_enable_blackhole = 1;
69266 + grsec_lastack_retries = 4;
69267 +#endif
69268 +#ifdef CONFIG_GRKERNSEC_FIFO
69269 + grsec_enable_fifo = 1;
69270 +#endif
69271 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69272 + grsec_enable_execlog = 1;
69273 +#endif
69274 +#ifdef CONFIG_GRKERNSEC_SETXID
69275 + grsec_enable_setxid = 1;
69276 +#endif
69277 +#ifdef CONFIG_GRKERNSEC_SIGNAL
69278 + grsec_enable_signal = 1;
69279 +#endif
69280 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69281 + grsec_enable_forkfail = 1;
69282 +#endif
69283 +#ifdef CONFIG_GRKERNSEC_TIME
69284 + grsec_enable_time = 1;
69285 +#endif
69286 +#ifdef CONFIG_GRKERNSEC_RESLOG
69287 + grsec_resource_logging = 1;
69288 +#endif
69289 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69290 + grsec_enable_chroot_findtask = 1;
69291 +#endif
69292 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69293 + grsec_enable_chroot_unix = 1;
69294 +#endif
69295 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69296 + grsec_enable_chroot_mount = 1;
69297 +#endif
69298 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69299 + grsec_enable_chroot_fchdir = 1;
69300 +#endif
69301 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69302 + grsec_enable_chroot_shmat = 1;
69303 +#endif
69304 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69305 + grsec_enable_audit_ptrace = 1;
69306 +#endif
69307 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69308 + grsec_enable_chroot_double = 1;
69309 +#endif
69310 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69311 + grsec_enable_chroot_pivot = 1;
69312 +#endif
69313 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69314 + grsec_enable_chroot_chdir = 1;
69315 +#endif
69316 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69317 + grsec_enable_chroot_chmod = 1;
69318 +#endif
69319 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69320 + grsec_enable_chroot_mknod = 1;
69321 +#endif
69322 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69323 + grsec_enable_chroot_nice = 1;
69324 +#endif
69325 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69326 + grsec_enable_chroot_execlog = 1;
69327 +#endif
69328 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69329 + grsec_enable_chroot_caps = 1;
69330 +#endif
69331 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69332 + grsec_enable_chroot_sysctl = 1;
69333 +#endif
69334 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69335 + grsec_enable_symlinkown = 1;
69336 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
69337 +#endif
69338 +#ifdef CONFIG_GRKERNSEC_TPE
69339 + grsec_enable_tpe = 1;
69340 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
69341 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69342 + grsec_enable_tpe_all = 1;
69343 +#endif
69344 +#endif
69345 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69346 + grsec_enable_socket_all = 1;
69347 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
69348 +#endif
69349 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69350 + grsec_enable_socket_client = 1;
69351 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
69352 +#endif
69353 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69354 + grsec_enable_socket_server = 1;
69355 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
69356 +#endif
69357 +#endif
69358 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
69359 + grsec_deny_new_usb = 1;
69360 +#endif
69361 +
69362 + return;
69363 +}
69364 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
69365 new file mode 100644
69366 index 0000000..5e05e20
69367 --- /dev/null
69368 +++ b/grsecurity/grsec_link.c
69369 @@ -0,0 +1,58 @@
69370 +#include <linux/kernel.h>
69371 +#include <linux/sched.h>
69372 +#include <linux/fs.h>
69373 +#include <linux/file.h>
69374 +#include <linux/grinternal.h>
69375 +
69376 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
69377 +{
69378 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69379 + const struct inode *link_inode = link->dentry->d_inode;
69380 +
69381 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
69382 + /* ignore root-owned links, e.g. /proc/self */
69383 + gr_is_global_nonroot(link_inode->i_uid) && target &&
69384 + !uid_eq(link_inode->i_uid, target->i_uid)) {
69385 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
69386 + return 1;
69387 + }
69388 +#endif
69389 + return 0;
69390 +}
69391 +
69392 +int
69393 +gr_handle_follow_link(const struct inode *parent,
69394 + const struct inode *inode,
69395 + const struct dentry *dentry, const struct vfsmount *mnt)
69396 +{
69397 +#ifdef CONFIG_GRKERNSEC_LINK
69398 + const struct cred *cred = current_cred();
69399 +
69400 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
69401 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
69402 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
69403 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
69404 + return -EACCES;
69405 + }
69406 +#endif
69407 + return 0;
69408 +}
69409 +
69410 +int
69411 +gr_handle_hardlink(const struct dentry *dentry,
69412 + const struct vfsmount *mnt,
69413 + struct inode *inode, const int mode, const struct filename *to)
69414 +{
69415 +#ifdef CONFIG_GRKERNSEC_LINK
69416 + const struct cred *cred = current_cred();
69417 +
69418 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
69419 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
69420 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
69421 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
69422 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
69423 + return -EPERM;
69424 + }
69425 +#endif
69426 + return 0;
69427 +}
69428 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
69429 new file mode 100644
69430 index 0000000..dbe0a6b
69431 --- /dev/null
69432 +++ b/grsecurity/grsec_log.c
69433 @@ -0,0 +1,341 @@
69434 +#include <linux/kernel.h>
69435 +#include <linux/sched.h>
69436 +#include <linux/file.h>
69437 +#include <linux/tty.h>
69438 +#include <linux/fs.h>
69439 +#include <linux/mm.h>
69440 +#include <linux/grinternal.h>
69441 +
69442 +#ifdef CONFIG_TREE_PREEMPT_RCU
69443 +#define DISABLE_PREEMPT() preempt_disable()
69444 +#define ENABLE_PREEMPT() preempt_enable()
69445 +#else
69446 +#define DISABLE_PREEMPT()
69447 +#define ENABLE_PREEMPT()
69448 +#endif
69449 +
69450 +#define BEGIN_LOCKS(x) \
69451 + DISABLE_PREEMPT(); \
69452 + rcu_read_lock(); \
69453 + read_lock(&tasklist_lock); \
69454 + read_lock(&grsec_exec_file_lock); \
69455 + if (x != GR_DO_AUDIT) \
69456 + spin_lock(&grsec_alert_lock); \
69457 + else \
69458 + spin_lock(&grsec_audit_lock)
69459 +
69460 +#define END_LOCKS(x) \
69461 + if (x != GR_DO_AUDIT) \
69462 + spin_unlock(&grsec_alert_lock); \
69463 + else \
69464 + spin_unlock(&grsec_audit_lock); \
69465 + read_unlock(&grsec_exec_file_lock); \
69466 + read_unlock(&tasklist_lock); \
69467 + rcu_read_unlock(); \
69468 + ENABLE_PREEMPT(); \
69469 + if (x == GR_DONT_AUDIT) \
69470 + gr_handle_alertkill(current)
69471 +
69472 +enum {
69473 + FLOODING,
69474 + NO_FLOODING
69475 +};
69476 +
69477 +extern char *gr_alert_log_fmt;
69478 +extern char *gr_audit_log_fmt;
69479 +extern char *gr_alert_log_buf;
69480 +extern char *gr_audit_log_buf;
69481 +
69482 +static int gr_log_start(int audit)
69483 +{
69484 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
69485 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
69486 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69487 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
69488 + unsigned long curr_secs = get_seconds();
69489 +
69490 + if (audit == GR_DO_AUDIT)
69491 + goto set_fmt;
69492 +
69493 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
69494 + grsec_alert_wtime = curr_secs;
69495 + grsec_alert_fyet = 0;
69496 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
69497 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
69498 + grsec_alert_fyet++;
69499 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
69500 + grsec_alert_wtime = curr_secs;
69501 + grsec_alert_fyet++;
69502 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
69503 + return FLOODING;
69504 + }
69505 + else return FLOODING;
69506 +
69507 +set_fmt:
69508 +#endif
69509 + memset(buf, 0, PAGE_SIZE);
69510 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
69511 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
69512 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69513 + } else if (current->signal->curr_ip) {
69514 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
69515 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
69516 + } else if (gr_acl_is_enabled()) {
69517 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
69518 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
69519 + } else {
69520 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
69521 + strcpy(buf, fmt);
69522 + }
69523 +
69524 + return NO_FLOODING;
69525 +}
69526 +
69527 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69528 + __attribute__ ((format (printf, 2, 0)));
69529 +
69530 +static void gr_log_middle(int audit, const char *msg, va_list ap)
69531 +{
69532 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69533 + unsigned int len = strlen(buf);
69534 +
69535 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69536 +
69537 + return;
69538 +}
69539 +
69540 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69541 + __attribute__ ((format (printf, 2, 3)));
69542 +
69543 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
69544 +{
69545 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69546 + unsigned int len = strlen(buf);
69547 + va_list ap;
69548 +
69549 + va_start(ap, msg);
69550 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
69551 + va_end(ap);
69552 +
69553 + return;
69554 +}
69555 +
69556 +static void gr_log_end(int audit, int append_default)
69557 +{
69558 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
69559 + if (append_default) {
69560 + struct task_struct *task = current;
69561 + struct task_struct *parent = task->real_parent;
69562 + const struct cred *cred = __task_cred(task);
69563 + const struct cred *pcred = __task_cred(parent);
69564 + unsigned int len = strlen(buf);
69565 +
69566 + 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));
69567 + }
69568 +
69569 + printk("%s\n", buf);
69570 +
69571 + return;
69572 +}
69573 +
69574 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
69575 +{
69576 + int logtype;
69577 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
69578 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
69579 + void *voidptr = NULL;
69580 + int num1 = 0, num2 = 0;
69581 + unsigned long ulong1 = 0, ulong2 = 0;
69582 + struct dentry *dentry = NULL;
69583 + struct vfsmount *mnt = NULL;
69584 + struct file *file = NULL;
69585 + struct task_struct *task = NULL;
69586 + struct vm_area_struct *vma = NULL;
69587 + const struct cred *cred, *pcred;
69588 + va_list ap;
69589 +
69590 + BEGIN_LOCKS(audit);
69591 + logtype = gr_log_start(audit);
69592 + if (logtype == FLOODING) {
69593 + END_LOCKS(audit);
69594 + return;
69595 + }
69596 + va_start(ap, argtypes);
69597 + switch (argtypes) {
69598 + case GR_TTYSNIFF:
69599 + task = va_arg(ap, struct task_struct *);
69600 + 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));
69601 + break;
69602 + case GR_SYSCTL_HIDDEN:
69603 + str1 = va_arg(ap, char *);
69604 + gr_log_middle_varargs(audit, msg, result, str1);
69605 + break;
69606 + case GR_RBAC:
69607 + dentry = va_arg(ap, struct dentry *);
69608 + mnt = va_arg(ap, struct vfsmount *);
69609 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
69610 + break;
69611 + case GR_RBAC_STR:
69612 + dentry = va_arg(ap, struct dentry *);
69613 + mnt = va_arg(ap, struct vfsmount *);
69614 + str1 = va_arg(ap, char *);
69615 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
69616 + break;
69617 + case GR_STR_RBAC:
69618 + str1 = va_arg(ap, char *);
69619 + dentry = va_arg(ap, struct dentry *);
69620 + mnt = va_arg(ap, struct vfsmount *);
69621 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
69622 + break;
69623 + case GR_RBAC_MODE2:
69624 + dentry = va_arg(ap, struct dentry *);
69625 + mnt = va_arg(ap, struct vfsmount *);
69626 + str1 = va_arg(ap, char *);
69627 + str2 = va_arg(ap, char *);
69628 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
69629 + break;
69630 + case GR_RBAC_MODE3:
69631 + dentry = va_arg(ap, struct dentry *);
69632 + mnt = va_arg(ap, struct vfsmount *);
69633 + str1 = va_arg(ap, char *);
69634 + str2 = va_arg(ap, char *);
69635 + str3 = va_arg(ap, char *);
69636 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
69637 + break;
69638 + case GR_FILENAME:
69639 + dentry = va_arg(ap, struct dentry *);
69640 + mnt = va_arg(ap, struct vfsmount *);
69641 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
69642 + break;
69643 + case GR_STR_FILENAME:
69644 + str1 = va_arg(ap, char *);
69645 + dentry = va_arg(ap, struct dentry *);
69646 + mnt = va_arg(ap, struct vfsmount *);
69647 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
69648 + break;
69649 + case GR_FILENAME_STR:
69650 + dentry = va_arg(ap, struct dentry *);
69651 + mnt = va_arg(ap, struct vfsmount *);
69652 + str1 = va_arg(ap, char *);
69653 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
69654 + break;
69655 + case GR_FILENAME_TWO_INT:
69656 + dentry = va_arg(ap, struct dentry *);
69657 + mnt = va_arg(ap, struct vfsmount *);
69658 + num1 = va_arg(ap, int);
69659 + num2 = va_arg(ap, int);
69660 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
69661 + break;
69662 + case GR_FILENAME_TWO_INT_STR:
69663 + dentry = va_arg(ap, struct dentry *);
69664 + mnt = va_arg(ap, struct vfsmount *);
69665 + num1 = va_arg(ap, int);
69666 + num2 = va_arg(ap, int);
69667 + str1 = va_arg(ap, char *);
69668 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
69669 + break;
69670 + case GR_TEXTREL:
69671 + file = va_arg(ap, struct file *);
69672 + ulong1 = va_arg(ap, unsigned long);
69673 + ulong2 = va_arg(ap, unsigned long);
69674 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
69675 + break;
69676 + case GR_PTRACE:
69677 + task = va_arg(ap, struct task_struct *);
69678 + 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));
69679 + break;
69680 + case GR_RESOURCE:
69681 + task = va_arg(ap, struct task_struct *);
69682 + cred = __task_cred(task);
69683 + pcred = __task_cred(task->real_parent);
69684 + ulong1 = va_arg(ap, unsigned long);
69685 + str1 = va_arg(ap, char *);
69686 + ulong2 = va_arg(ap, unsigned long);
69687 + 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));
69688 + break;
69689 + case GR_CAP:
69690 + task = va_arg(ap, struct task_struct *);
69691 + cred = __task_cred(task);
69692 + pcred = __task_cred(task->real_parent);
69693 + str1 = va_arg(ap, char *);
69694 + 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));
69695 + break;
69696 + case GR_SIG:
69697 + str1 = va_arg(ap, char *);
69698 + voidptr = va_arg(ap, void *);
69699 + gr_log_middle_varargs(audit, msg, str1, voidptr);
69700 + break;
69701 + case GR_SIG2:
69702 + task = va_arg(ap, struct task_struct *);
69703 + cred = __task_cred(task);
69704 + pcred = __task_cred(task->real_parent);
69705 + num1 = va_arg(ap, int);
69706 + 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));
69707 + break;
69708 + case GR_CRASH1:
69709 + task = va_arg(ap, struct task_struct *);
69710 + cred = __task_cred(task);
69711 + pcred = __task_cred(task->real_parent);
69712 + ulong1 = va_arg(ap, unsigned long);
69713 + 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);
69714 + break;
69715 + case GR_CRASH2:
69716 + task = va_arg(ap, struct task_struct *);
69717 + cred = __task_cred(task);
69718 + pcred = __task_cred(task->real_parent);
69719 + ulong1 = va_arg(ap, unsigned long);
69720 + 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);
69721 + break;
69722 + case GR_RWXMAP:
69723 + file = va_arg(ap, struct file *);
69724 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
69725 + break;
69726 + case GR_RWXMAPVMA:
69727 + vma = va_arg(ap, struct vm_area_struct *);
69728 + if (vma->vm_file)
69729 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
69730 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
69731 + str1 = "<stack>";
69732 + else if (vma->vm_start <= current->mm->brk &&
69733 + vma->vm_end >= current->mm->start_brk)
69734 + str1 = "<heap>";
69735 + else
69736 + str1 = "<anonymous mapping>";
69737 + gr_log_middle_varargs(audit, msg, str1);
69738 + break;
69739 + case GR_PSACCT:
69740 + {
69741 + unsigned int wday, cday;
69742 + __u8 whr, chr;
69743 + __u8 wmin, cmin;
69744 + __u8 wsec, csec;
69745 + char cur_tty[64] = { 0 };
69746 + char parent_tty[64] = { 0 };
69747 +
69748 + task = va_arg(ap, struct task_struct *);
69749 + wday = va_arg(ap, unsigned int);
69750 + cday = va_arg(ap, unsigned int);
69751 + whr = va_arg(ap, int);
69752 + chr = va_arg(ap, int);
69753 + wmin = va_arg(ap, int);
69754 + cmin = va_arg(ap, int);
69755 + wsec = va_arg(ap, int);
69756 + csec = va_arg(ap, int);
69757 + ulong1 = va_arg(ap, unsigned long);
69758 + cred = __task_cred(task);
69759 + pcred = __task_cred(task->real_parent);
69760 +
69761 + gr_log_middle_varargs(audit, msg, gr_task_fullpath(task), task->comm, task_pid_nr(task), &task->signal->curr_ip, tty_name(task->signal->tty, cur_tty), GR_GLOBAL_UID(cred->uid), GR_GLOBAL_UID(cred->euid), GR_GLOBAL_GID(cred->gid), GR_GLOBAL_GID(cred->egid), wday, whr, wmin, wsec, cday, chr, cmin, csec, (task->flags & PF_SIGNALED) ? "killed by signal" : "exited", ulong1, gr_parent_task_fullpath(task), task->real_parent->comm, task_pid_nr(task->real_parent), &task->real_parent->signal->curr_ip, tty_name(task->real_parent->signal->tty, parent_tty), GR_GLOBAL_UID(pcred->uid), GR_GLOBAL_UID(pcred->euid), GR_GLOBAL_GID(pcred->gid), GR_GLOBAL_GID(pcred->egid));
69762 + }
69763 + break;
69764 + default:
69765 + gr_log_middle(audit, msg, ap);
69766 + }
69767 + va_end(ap);
69768 + // these don't need DEFAULTSECARGS printed on the end
69769 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
69770 + gr_log_end(audit, 0);
69771 + else
69772 + gr_log_end(audit, 1);
69773 + END_LOCKS(audit);
69774 +}
69775 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
69776 new file mode 100644
69777 index 0000000..f536303
69778 --- /dev/null
69779 +++ b/grsecurity/grsec_mem.c
69780 @@ -0,0 +1,40 @@
69781 +#include <linux/kernel.h>
69782 +#include <linux/sched.h>
69783 +#include <linux/mm.h>
69784 +#include <linux/mman.h>
69785 +#include <linux/grinternal.h>
69786 +
69787 +void
69788 +gr_handle_ioperm(void)
69789 +{
69790 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
69791 + return;
69792 +}
69793 +
69794 +void
69795 +gr_handle_iopl(void)
69796 +{
69797 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
69798 + return;
69799 +}
69800 +
69801 +void
69802 +gr_handle_mem_readwrite(u64 from, u64 to)
69803 +{
69804 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
69805 + return;
69806 +}
69807 +
69808 +void
69809 +gr_handle_vm86(void)
69810 +{
69811 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
69812 + return;
69813 +}
69814 +
69815 +void
69816 +gr_log_badprocpid(const char *entry)
69817 +{
69818 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
69819 + return;
69820 +}
69821 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
69822 new file mode 100644
69823 index 0000000..2131422
69824 --- /dev/null
69825 +++ b/grsecurity/grsec_mount.c
69826 @@ -0,0 +1,62 @@
69827 +#include <linux/kernel.h>
69828 +#include <linux/sched.h>
69829 +#include <linux/mount.h>
69830 +#include <linux/grsecurity.h>
69831 +#include <linux/grinternal.h>
69832 +
69833 +void
69834 +gr_log_remount(const char *devname, const int retval)
69835 +{
69836 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69837 + if (grsec_enable_mount && (retval >= 0))
69838 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
69839 +#endif
69840 + return;
69841 +}
69842 +
69843 +void
69844 +gr_log_unmount(const char *devname, const int retval)
69845 +{
69846 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69847 + if (grsec_enable_mount && (retval >= 0))
69848 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
69849 +#endif
69850 + return;
69851 +}
69852 +
69853 +void
69854 +gr_log_mount(const char *from, const char *to, const int retval)
69855 +{
69856 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69857 + if (grsec_enable_mount && (retval >= 0))
69858 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
69859 +#endif
69860 + return;
69861 +}
69862 +
69863 +int
69864 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
69865 +{
69866 +#ifdef CONFIG_GRKERNSEC_ROFS
69867 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
69868 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
69869 + return -EPERM;
69870 + } else
69871 + return 0;
69872 +#endif
69873 + return 0;
69874 +}
69875 +
69876 +int
69877 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
69878 +{
69879 +#ifdef CONFIG_GRKERNSEC_ROFS
69880 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
69881 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
69882 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
69883 + return -EPERM;
69884 + } else
69885 + return 0;
69886 +#endif
69887 + return 0;
69888 +}
69889 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
69890 new file mode 100644
69891 index 0000000..6ee9d50
69892 --- /dev/null
69893 +++ b/grsecurity/grsec_pax.c
69894 @@ -0,0 +1,45 @@
69895 +#include <linux/kernel.h>
69896 +#include <linux/sched.h>
69897 +#include <linux/mm.h>
69898 +#include <linux/file.h>
69899 +#include <linux/grinternal.h>
69900 +#include <linux/grsecurity.h>
69901 +
69902 +void
69903 +gr_log_textrel(struct vm_area_struct * vma)
69904 +{
69905 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69906 + if (grsec_enable_log_rwxmaps)
69907 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
69908 +#endif
69909 + return;
69910 +}
69911 +
69912 +void gr_log_ptgnustack(struct file *file)
69913 +{
69914 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69915 + if (grsec_enable_log_rwxmaps)
69916 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
69917 +#endif
69918 + return;
69919 +}
69920 +
69921 +void
69922 +gr_log_rwxmmap(struct file *file)
69923 +{
69924 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69925 + if (grsec_enable_log_rwxmaps)
69926 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
69927 +#endif
69928 + return;
69929 +}
69930 +
69931 +void
69932 +gr_log_rwxmprotect(struct vm_area_struct *vma)
69933 +{
69934 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69935 + if (grsec_enable_log_rwxmaps)
69936 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
69937 +#endif
69938 + return;
69939 +}
69940 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
69941 new file mode 100644
69942 index 0000000..f7f29aa
69943 --- /dev/null
69944 +++ b/grsecurity/grsec_ptrace.c
69945 @@ -0,0 +1,30 @@
69946 +#include <linux/kernel.h>
69947 +#include <linux/sched.h>
69948 +#include <linux/grinternal.h>
69949 +#include <linux/security.h>
69950 +
69951 +void
69952 +gr_audit_ptrace(struct task_struct *task)
69953 +{
69954 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69955 + if (grsec_enable_audit_ptrace)
69956 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
69957 +#endif
69958 + return;
69959 +}
69960 +
69961 +int
69962 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
69963 +{
69964 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69965 + const struct dentry *dentry = file->f_path.dentry;
69966 + const struct vfsmount *mnt = file->f_path.mnt;
69967 +
69968 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
69969 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
69970 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
69971 + return -EACCES;
69972 + }
69973 +#endif
69974 + return 0;
69975 +}
69976 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
69977 new file mode 100644
69978 index 0000000..4e29cc7
69979 --- /dev/null
69980 +++ b/grsecurity/grsec_sig.c
69981 @@ -0,0 +1,246 @@
69982 +#include <linux/kernel.h>
69983 +#include <linux/sched.h>
69984 +#include <linux/fs.h>
69985 +#include <linux/delay.h>
69986 +#include <linux/grsecurity.h>
69987 +#include <linux/grinternal.h>
69988 +#include <linux/hardirq.h>
69989 +
69990 +char *signames[] = {
69991 + [SIGSEGV] = "Segmentation fault",
69992 + [SIGILL] = "Illegal instruction",
69993 + [SIGABRT] = "Abort",
69994 + [SIGBUS] = "Invalid alignment/Bus error"
69995 +};
69996 +
69997 +void
69998 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
69999 +{
70000 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70001 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
70002 + (sig == SIGABRT) || (sig == SIGBUS))) {
70003 + if (task_pid_nr(t) == task_pid_nr(current)) {
70004 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
70005 + } else {
70006 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
70007 + }
70008 + }
70009 +#endif
70010 + return;
70011 +}
70012 +
70013 +int
70014 +gr_handle_signal(const struct task_struct *p, const int sig)
70015 +{
70016 +#ifdef CONFIG_GRKERNSEC
70017 + /* ignore the 0 signal for protected task checks */
70018 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
70019 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
70020 + return -EPERM;
70021 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
70022 + return -EPERM;
70023 + }
70024 +#endif
70025 + return 0;
70026 +}
70027 +
70028 +#ifdef CONFIG_GRKERNSEC
70029 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
70030 +
70031 +int gr_fake_force_sig(int sig, struct task_struct *t)
70032 +{
70033 + unsigned long int flags;
70034 + int ret, blocked, ignored;
70035 + struct k_sigaction *action;
70036 +
70037 + spin_lock_irqsave(&t->sighand->siglock, flags);
70038 + action = &t->sighand->action[sig-1];
70039 + ignored = action->sa.sa_handler == SIG_IGN;
70040 + blocked = sigismember(&t->blocked, sig);
70041 + if (blocked || ignored) {
70042 + action->sa.sa_handler = SIG_DFL;
70043 + if (blocked) {
70044 + sigdelset(&t->blocked, sig);
70045 + recalc_sigpending_and_wake(t);
70046 + }
70047 + }
70048 + if (action->sa.sa_handler == SIG_DFL)
70049 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
70050 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
70051 +
70052 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
70053 +
70054 + return ret;
70055 +}
70056 +#endif
70057 +
70058 +#ifdef CONFIG_GRKERNSEC_BRUTE
70059 +#define GR_USER_BAN_TIME (15 * 60)
70060 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
70061 +
70062 +static int __get_dumpable(unsigned long mm_flags)
70063 +{
70064 + int ret;
70065 +
70066 + ret = mm_flags & MMF_DUMPABLE_MASK;
70067 + return (ret >= 2) ? 2 : ret;
70068 +}
70069 +#endif
70070 +
70071 +void gr_handle_brute_attach(unsigned long mm_flags)
70072 +{
70073 +#ifdef CONFIG_GRKERNSEC_BRUTE
70074 + struct task_struct *p = current;
70075 + kuid_t uid = GLOBAL_ROOT_UID;
70076 + int daemon = 0;
70077 +
70078 + if (!grsec_enable_brute)
70079 + return;
70080 +
70081 + rcu_read_lock();
70082 + read_lock(&tasklist_lock);
70083 + read_lock(&grsec_exec_file_lock);
70084 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
70085 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
70086 + p->real_parent->brute = 1;
70087 + daemon = 1;
70088 + } else {
70089 + const struct cred *cred = __task_cred(p), *cred2;
70090 + struct task_struct *tsk, *tsk2;
70091 +
70092 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
70093 + struct user_struct *user;
70094 +
70095 + uid = cred->uid;
70096 +
70097 + /* this is put upon execution past expiration */
70098 + user = find_user(uid);
70099 + if (user == NULL)
70100 + goto unlock;
70101 + user->suid_banned = 1;
70102 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
70103 + if (user->suid_ban_expires == ~0UL)
70104 + user->suid_ban_expires--;
70105 +
70106 + /* only kill other threads of the same binary, from the same user */
70107 + do_each_thread(tsk2, tsk) {
70108 + cred2 = __task_cred(tsk);
70109 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
70110 + gr_fake_force_sig(SIGKILL, tsk);
70111 + } while_each_thread(tsk2, tsk);
70112 + }
70113 + }
70114 +unlock:
70115 + read_unlock(&grsec_exec_file_lock);
70116 + read_unlock(&tasklist_lock);
70117 + rcu_read_unlock();
70118 +
70119 + if (gr_is_global_nonroot(uid))
70120 + 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);
70121 + else if (daemon)
70122 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
70123 +
70124 +#endif
70125 + return;
70126 +}
70127 +
70128 +void gr_handle_brute_check(void)
70129 +{
70130 +#ifdef CONFIG_GRKERNSEC_BRUTE
70131 + struct task_struct *p = current;
70132 +
70133 + if (unlikely(p->brute)) {
70134 + if (!grsec_enable_brute)
70135 + p->brute = 0;
70136 + else if (time_before(get_seconds(), p->brute_expires))
70137 + msleep(30 * 1000);
70138 + }
70139 +#endif
70140 + return;
70141 +}
70142 +
70143 +void gr_handle_kernel_exploit(void)
70144 +{
70145 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70146 + const struct cred *cred;
70147 + struct task_struct *tsk, *tsk2;
70148 + struct user_struct *user;
70149 + kuid_t uid;
70150 +
70151 + if (in_irq() || in_serving_softirq() || in_nmi())
70152 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
70153 +
70154 + uid = current_uid();
70155 +
70156 + if (gr_is_global_root(uid))
70157 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
70158 + else {
70159 + /* kill all the processes of this user, hold a reference
70160 + to their creds struct, and prevent them from creating
70161 + another process until system reset
70162 + */
70163 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
70164 + GR_GLOBAL_UID(uid));
70165 + /* we intentionally leak this ref */
70166 + user = get_uid(current->cred->user);
70167 + if (user)
70168 + user->kernel_banned = 1;
70169 +
70170 + /* kill all processes of this user */
70171 + read_lock(&tasklist_lock);
70172 + do_each_thread(tsk2, tsk) {
70173 + cred = __task_cred(tsk);
70174 + if (uid_eq(cred->uid, uid))
70175 + gr_fake_force_sig(SIGKILL, tsk);
70176 + } while_each_thread(tsk2, tsk);
70177 + read_unlock(&tasklist_lock);
70178 + }
70179 +#endif
70180 +}
70181 +
70182 +#ifdef CONFIG_GRKERNSEC_BRUTE
70183 +static bool suid_ban_expired(struct user_struct *user)
70184 +{
70185 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
70186 + user->suid_banned = 0;
70187 + user->suid_ban_expires = 0;
70188 + free_uid(user);
70189 + return true;
70190 + }
70191 +
70192 + return false;
70193 +}
70194 +#endif
70195 +
70196 +int gr_process_kernel_exec_ban(void)
70197 +{
70198 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70199 + if (unlikely(current->cred->user->kernel_banned))
70200 + return -EPERM;
70201 +#endif
70202 + return 0;
70203 +}
70204 +
70205 +int gr_process_kernel_setuid_ban(struct user_struct *user)
70206 +{
70207 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70208 + if (unlikely(user->kernel_banned))
70209 + gr_fake_force_sig(SIGKILL, current);
70210 +#endif
70211 + return 0;
70212 +}
70213 +
70214 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
70215 +{
70216 +#ifdef CONFIG_GRKERNSEC_BRUTE
70217 + struct user_struct *user = current->cred->user;
70218 + if (unlikely(user->suid_banned)) {
70219 + if (suid_ban_expired(user))
70220 + return 0;
70221 + /* disallow execution of suid binaries only */
70222 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
70223 + return -EPERM;
70224 + }
70225 +#endif
70226 + return 0;
70227 +}
70228 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
70229 new file mode 100644
70230 index 0000000..4030d57
70231 --- /dev/null
70232 +++ b/grsecurity/grsec_sock.c
70233 @@ -0,0 +1,244 @@
70234 +#include <linux/kernel.h>
70235 +#include <linux/module.h>
70236 +#include <linux/sched.h>
70237 +#include <linux/file.h>
70238 +#include <linux/net.h>
70239 +#include <linux/in.h>
70240 +#include <linux/ip.h>
70241 +#include <net/sock.h>
70242 +#include <net/inet_sock.h>
70243 +#include <linux/grsecurity.h>
70244 +#include <linux/grinternal.h>
70245 +#include <linux/gracl.h>
70246 +
70247 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
70248 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
70249 +
70250 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
70251 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
70252 +
70253 +#ifdef CONFIG_UNIX_MODULE
70254 +EXPORT_SYMBOL(gr_acl_handle_unix);
70255 +EXPORT_SYMBOL(gr_acl_handle_mknod);
70256 +EXPORT_SYMBOL(gr_handle_chroot_unix);
70257 +EXPORT_SYMBOL(gr_handle_create);
70258 +#endif
70259 +
70260 +#ifdef CONFIG_GRKERNSEC
70261 +#define gr_conn_table_size 32749
70262 +struct conn_table_entry {
70263 + struct conn_table_entry *next;
70264 + struct signal_struct *sig;
70265 +};
70266 +
70267 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
70268 +DEFINE_SPINLOCK(gr_conn_table_lock);
70269 +
70270 +extern const char * gr_socktype_to_name(unsigned char type);
70271 +extern const char * gr_proto_to_name(unsigned char proto);
70272 +extern const char * gr_sockfamily_to_name(unsigned char family);
70273 +
70274 +static __inline__ int
70275 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
70276 +{
70277 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
70278 +}
70279 +
70280 +static __inline__ int
70281 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
70282 + __u16 sport, __u16 dport)
70283 +{
70284 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
70285 + sig->gr_sport == sport && sig->gr_dport == dport))
70286 + return 1;
70287 + else
70288 + return 0;
70289 +}
70290 +
70291 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
70292 +{
70293 + struct conn_table_entry **match;
70294 + unsigned int index;
70295 +
70296 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70297 + sig->gr_sport, sig->gr_dport,
70298 + gr_conn_table_size);
70299 +
70300 + newent->sig = sig;
70301 +
70302 + match = &gr_conn_table[index];
70303 + newent->next = *match;
70304 + *match = newent;
70305 +
70306 + return;
70307 +}
70308 +
70309 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
70310 +{
70311 + struct conn_table_entry *match, *last = NULL;
70312 + unsigned int index;
70313 +
70314 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70315 + sig->gr_sport, sig->gr_dport,
70316 + gr_conn_table_size);
70317 +
70318 + match = gr_conn_table[index];
70319 + while (match && !conn_match(match->sig,
70320 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
70321 + sig->gr_dport)) {
70322 + last = match;
70323 + match = match->next;
70324 + }
70325 +
70326 + if (match) {
70327 + if (last)
70328 + last->next = match->next;
70329 + else
70330 + gr_conn_table[index] = NULL;
70331 + kfree(match);
70332 + }
70333 +
70334 + return;
70335 +}
70336 +
70337 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
70338 + __u16 sport, __u16 dport)
70339 +{
70340 + struct conn_table_entry *match;
70341 + unsigned int index;
70342 +
70343 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
70344 +
70345 + match = gr_conn_table[index];
70346 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
70347 + match = match->next;
70348 +
70349 + if (match)
70350 + return match->sig;
70351 + else
70352 + return NULL;
70353 +}
70354 +
70355 +#endif
70356 +
70357 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
70358 +{
70359 +#ifdef CONFIG_GRKERNSEC
70360 + struct signal_struct *sig = task->signal;
70361 + struct conn_table_entry *newent;
70362 +
70363 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
70364 + if (newent == NULL)
70365 + return;
70366 + /* no bh lock needed since we are called with bh disabled */
70367 + spin_lock(&gr_conn_table_lock);
70368 + gr_del_task_from_ip_table_nolock(sig);
70369 + sig->gr_saddr = inet->inet_rcv_saddr;
70370 + sig->gr_daddr = inet->inet_daddr;
70371 + sig->gr_sport = inet->inet_sport;
70372 + sig->gr_dport = inet->inet_dport;
70373 + gr_add_to_task_ip_table_nolock(sig, newent);
70374 + spin_unlock(&gr_conn_table_lock);
70375 +#endif
70376 + return;
70377 +}
70378 +
70379 +void gr_del_task_from_ip_table(struct task_struct *task)
70380 +{
70381 +#ifdef CONFIG_GRKERNSEC
70382 + spin_lock_bh(&gr_conn_table_lock);
70383 + gr_del_task_from_ip_table_nolock(task->signal);
70384 + spin_unlock_bh(&gr_conn_table_lock);
70385 +#endif
70386 + return;
70387 +}
70388 +
70389 +void
70390 +gr_attach_curr_ip(const struct sock *sk)
70391 +{
70392 +#ifdef CONFIG_GRKERNSEC
70393 + struct signal_struct *p, *set;
70394 + const struct inet_sock *inet = inet_sk(sk);
70395 +
70396 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
70397 + return;
70398 +
70399 + set = current->signal;
70400 +
70401 + spin_lock_bh(&gr_conn_table_lock);
70402 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
70403 + inet->inet_dport, inet->inet_sport);
70404 + if (unlikely(p != NULL)) {
70405 + set->curr_ip = p->curr_ip;
70406 + set->used_accept = 1;
70407 + gr_del_task_from_ip_table_nolock(p);
70408 + spin_unlock_bh(&gr_conn_table_lock);
70409 + return;
70410 + }
70411 + spin_unlock_bh(&gr_conn_table_lock);
70412 +
70413 + set->curr_ip = inet->inet_daddr;
70414 + set->used_accept = 1;
70415 +#endif
70416 + return;
70417 +}
70418 +
70419 +int
70420 +gr_handle_sock_all(const int family, const int type, const int protocol)
70421 +{
70422 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70423 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
70424 + (family != AF_UNIX)) {
70425 + if (family == AF_INET)
70426 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
70427 + else
70428 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
70429 + return -EACCES;
70430 + }
70431 +#endif
70432 + return 0;
70433 +}
70434 +
70435 +int
70436 +gr_handle_sock_server(const struct sockaddr *sck)
70437 +{
70438 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70439 + if (grsec_enable_socket_server &&
70440 + in_group_p(grsec_socket_server_gid) &&
70441 + sck && (sck->sa_family != AF_UNIX) &&
70442 + (sck->sa_family != AF_LOCAL)) {
70443 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70444 + return -EACCES;
70445 + }
70446 +#endif
70447 + return 0;
70448 +}
70449 +
70450 +int
70451 +gr_handle_sock_server_other(const struct sock *sck)
70452 +{
70453 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70454 + if (grsec_enable_socket_server &&
70455 + in_group_p(grsec_socket_server_gid) &&
70456 + sck && (sck->sk_family != AF_UNIX) &&
70457 + (sck->sk_family != AF_LOCAL)) {
70458 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70459 + return -EACCES;
70460 + }
70461 +#endif
70462 + return 0;
70463 +}
70464 +
70465 +int
70466 +gr_handle_sock_client(const struct sockaddr *sck)
70467 +{
70468 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70469 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
70470 + sck && (sck->sa_family != AF_UNIX) &&
70471 + (sck->sa_family != AF_LOCAL)) {
70472 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
70473 + return -EACCES;
70474 + }
70475 +#endif
70476 + return 0;
70477 +}
70478 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
70479 new file mode 100644
70480 index 0000000..a147ae7
70481 --- /dev/null
70482 +++ b/grsecurity/grsec_sysctl.c
70483 @@ -0,0 +1,470 @@
70484 +#include <linux/kernel.h>
70485 +#include <linux/sched.h>
70486 +#include <linux/sysctl.h>
70487 +#include <linux/grsecurity.h>
70488 +#include <linux/grinternal.h>
70489 +
70490 +int
70491 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
70492 +{
70493 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70494 + if (dirname == NULL || name == NULL)
70495 + return 0;
70496 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
70497 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
70498 + return -EACCES;
70499 + }
70500 +#endif
70501 + return 0;
70502 +}
70503 +
70504 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
70505 +static int __maybe_unused __read_only one = 1;
70506 +#endif
70507 +
70508 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
70509 + defined(CONFIG_GRKERNSEC_DENYUSB)
70510 +struct ctl_table grsecurity_table[] = {
70511 +#ifdef CONFIG_GRKERNSEC_SYSCTL
70512 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
70513 +#ifdef CONFIG_GRKERNSEC_IO
70514 + {
70515 + .procname = "disable_priv_io",
70516 + .data = &grsec_disable_privio,
70517 + .maxlen = sizeof(int),
70518 + .mode = 0600,
70519 + .proc_handler = &proc_dointvec,
70520 + },
70521 +#endif
70522 +#endif
70523 +#ifdef CONFIG_GRKERNSEC_LINK
70524 + {
70525 + .procname = "linking_restrictions",
70526 + .data = &grsec_enable_link,
70527 + .maxlen = sizeof(int),
70528 + .mode = 0600,
70529 + .proc_handler = &proc_dointvec,
70530 + },
70531 +#endif
70532 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70533 + {
70534 + .procname = "enforce_symlinksifowner",
70535 + .data = &grsec_enable_symlinkown,
70536 + .maxlen = sizeof(int),
70537 + .mode = 0600,
70538 + .proc_handler = &proc_dointvec,
70539 + },
70540 + {
70541 + .procname = "symlinkown_gid",
70542 + .data = &grsec_symlinkown_gid,
70543 + .maxlen = sizeof(int),
70544 + .mode = 0600,
70545 + .proc_handler = &proc_dointvec,
70546 + },
70547 +#endif
70548 +#ifdef CONFIG_GRKERNSEC_BRUTE
70549 + {
70550 + .procname = "deter_bruteforce",
70551 + .data = &grsec_enable_brute,
70552 + .maxlen = sizeof(int),
70553 + .mode = 0600,
70554 + .proc_handler = &proc_dointvec,
70555 + },
70556 +#endif
70557 +#ifdef CONFIG_GRKERNSEC_FIFO
70558 + {
70559 + .procname = "fifo_restrictions",
70560 + .data = &grsec_enable_fifo,
70561 + .maxlen = sizeof(int),
70562 + .mode = 0600,
70563 + .proc_handler = &proc_dointvec,
70564 + },
70565 +#endif
70566 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70567 + {
70568 + .procname = "ptrace_readexec",
70569 + .data = &grsec_enable_ptrace_readexec,
70570 + .maxlen = sizeof(int),
70571 + .mode = 0600,
70572 + .proc_handler = &proc_dointvec,
70573 + },
70574 +#endif
70575 +#ifdef CONFIG_GRKERNSEC_SETXID
70576 + {
70577 + .procname = "consistent_setxid",
70578 + .data = &grsec_enable_setxid,
70579 + .maxlen = sizeof(int),
70580 + .mode = 0600,
70581 + .proc_handler = &proc_dointvec,
70582 + },
70583 +#endif
70584 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
70585 + {
70586 + .procname = "ip_blackhole",
70587 + .data = &grsec_enable_blackhole,
70588 + .maxlen = sizeof(int),
70589 + .mode = 0600,
70590 + .proc_handler = &proc_dointvec,
70591 + },
70592 + {
70593 + .procname = "lastack_retries",
70594 + .data = &grsec_lastack_retries,
70595 + .maxlen = sizeof(int),
70596 + .mode = 0600,
70597 + .proc_handler = &proc_dointvec,
70598 + },
70599 +#endif
70600 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70601 + {
70602 + .procname = "exec_logging",
70603 + .data = &grsec_enable_execlog,
70604 + .maxlen = sizeof(int),
70605 + .mode = 0600,
70606 + .proc_handler = &proc_dointvec,
70607 + },
70608 +#endif
70609 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70610 + {
70611 + .procname = "rwxmap_logging",
70612 + .data = &grsec_enable_log_rwxmaps,
70613 + .maxlen = sizeof(int),
70614 + .mode = 0600,
70615 + .proc_handler = &proc_dointvec,
70616 + },
70617 +#endif
70618 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70619 + {
70620 + .procname = "signal_logging",
70621 + .data = &grsec_enable_signal,
70622 + .maxlen = sizeof(int),
70623 + .mode = 0600,
70624 + .proc_handler = &proc_dointvec,
70625 + },
70626 +#endif
70627 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70628 + {
70629 + .procname = "forkfail_logging",
70630 + .data = &grsec_enable_forkfail,
70631 + .maxlen = sizeof(int),
70632 + .mode = 0600,
70633 + .proc_handler = &proc_dointvec,
70634 + },
70635 +#endif
70636 +#ifdef CONFIG_GRKERNSEC_TIME
70637 + {
70638 + .procname = "timechange_logging",
70639 + .data = &grsec_enable_time,
70640 + .maxlen = sizeof(int),
70641 + .mode = 0600,
70642 + .proc_handler = &proc_dointvec,
70643 + },
70644 +#endif
70645 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
70646 + {
70647 + .procname = "chroot_deny_shmat",
70648 + .data = &grsec_enable_chroot_shmat,
70649 + .maxlen = sizeof(int),
70650 + .mode = 0600,
70651 + .proc_handler = &proc_dointvec,
70652 + },
70653 +#endif
70654 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
70655 + {
70656 + .procname = "chroot_deny_unix",
70657 + .data = &grsec_enable_chroot_unix,
70658 + .maxlen = sizeof(int),
70659 + .mode = 0600,
70660 + .proc_handler = &proc_dointvec,
70661 + },
70662 +#endif
70663 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
70664 + {
70665 + .procname = "chroot_deny_mount",
70666 + .data = &grsec_enable_chroot_mount,
70667 + .maxlen = sizeof(int),
70668 + .mode = 0600,
70669 + .proc_handler = &proc_dointvec,
70670 + },
70671 +#endif
70672 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
70673 + {
70674 + .procname = "chroot_deny_fchdir",
70675 + .data = &grsec_enable_chroot_fchdir,
70676 + .maxlen = sizeof(int),
70677 + .mode = 0600,
70678 + .proc_handler = &proc_dointvec,
70679 + },
70680 +#endif
70681 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
70682 + {
70683 + .procname = "chroot_deny_chroot",
70684 + .data = &grsec_enable_chroot_double,
70685 + .maxlen = sizeof(int),
70686 + .mode = 0600,
70687 + .proc_handler = &proc_dointvec,
70688 + },
70689 +#endif
70690 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
70691 + {
70692 + .procname = "chroot_deny_pivot",
70693 + .data = &grsec_enable_chroot_pivot,
70694 + .maxlen = sizeof(int),
70695 + .mode = 0600,
70696 + .proc_handler = &proc_dointvec,
70697 + },
70698 +#endif
70699 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
70700 + {
70701 + .procname = "chroot_enforce_chdir",
70702 + .data = &grsec_enable_chroot_chdir,
70703 + .maxlen = sizeof(int),
70704 + .mode = 0600,
70705 + .proc_handler = &proc_dointvec,
70706 + },
70707 +#endif
70708 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
70709 + {
70710 + .procname = "chroot_deny_chmod",
70711 + .data = &grsec_enable_chroot_chmod,
70712 + .maxlen = sizeof(int),
70713 + .mode = 0600,
70714 + .proc_handler = &proc_dointvec,
70715 + },
70716 +#endif
70717 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
70718 + {
70719 + .procname = "chroot_deny_mknod",
70720 + .data = &grsec_enable_chroot_mknod,
70721 + .maxlen = sizeof(int),
70722 + .mode = 0600,
70723 + .proc_handler = &proc_dointvec,
70724 + },
70725 +#endif
70726 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70727 + {
70728 + .procname = "chroot_restrict_nice",
70729 + .data = &grsec_enable_chroot_nice,
70730 + .maxlen = sizeof(int),
70731 + .mode = 0600,
70732 + .proc_handler = &proc_dointvec,
70733 + },
70734 +#endif
70735 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
70736 + {
70737 + .procname = "chroot_execlog",
70738 + .data = &grsec_enable_chroot_execlog,
70739 + .maxlen = sizeof(int),
70740 + .mode = 0600,
70741 + .proc_handler = &proc_dointvec,
70742 + },
70743 +#endif
70744 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70745 + {
70746 + .procname = "chroot_caps",
70747 + .data = &grsec_enable_chroot_caps,
70748 + .maxlen = sizeof(int),
70749 + .mode = 0600,
70750 + .proc_handler = &proc_dointvec,
70751 + },
70752 +#endif
70753 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70754 + {
70755 + .procname = "chroot_deny_sysctl",
70756 + .data = &grsec_enable_chroot_sysctl,
70757 + .maxlen = sizeof(int),
70758 + .mode = 0600,
70759 + .proc_handler = &proc_dointvec,
70760 + },
70761 +#endif
70762 +#ifdef CONFIG_GRKERNSEC_TPE
70763 + {
70764 + .procname = "tpe",
70765 + .data = &grsec_enable_tpe,
70766 + .maxlen = sizeof(int),
70767 + .mode = 0600,
70768 + .proc_handler = &proc_dointvec,
70769 + },
70770 + {
70771 + .procname = "tpe_gid",
70772 + .data = &grsec_tpe_gid,
70773 + .maxlen = sizeof(int),
70774 + .mode = 0600,
70775 + .proc_handler = &proc_dointvec,
70776 + },
70777 +#endif
70778 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
70779 + {
70780 + .procname = "tpe_invert",
70781 + .data = &grsec_enable_tpe_invert,
70782 + .maxlen = sizeof(int),
70783 + .mode = 0600,
70784 + .proc_handler = &proc_dointvec,
70785 + },
70786 +#endif
70787 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
70788 + {
70789 + .procname = "tpe_restrict_all",
70790 + .data = &grsec_enable_tpe_all,
70791 + .maxlen = sizeof(int),
70792 + .mode = 0600,
70793 + .proc_handler = &proc_dointvec,
70794 + },
70795 +#endif
70796 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70797 + {
70798 + .procname = "socket_all",
70799 + .data = &grsec_enable_socket_all,
70800 + .maxlen = sizeof(int),
70801 + .mode = 0600,
70802 + .proc_handler = &proc_dointvec,
70803 + },
70804 + {
70805 + .procname = "socket_all_gid",
70806 + .data = &grsec_socket_all_gid,
70807 + .maxlen = sizeof(int),
70808 + .mode = 0600,
70809 + .proc_handler = &proc_dointvec,
70810 + },
70811 +#endif
70812 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70813 + {
70814 + .procname = "socket_client",
70815 + .data = &grsec_enable_socket_client,
70816 + .maxlen = sizeof(int),
70817 + .mode = 0600,
70818 + .proc_handler = &proc_dointvec,
70819 + },
70820 + {
70821 + .procname = "socket_client_gid",
70822 + .data = &grsec_socket_client_gid,
70823 + .maxlen = sizeof(int),
70824 + .mode = 0600,
70825 + .proc_handler = &proc_dointvec,
70826 + },
70827 +#endif
70828 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70829 + {
70830 + .procname = "socket_server",
70831 + .data = &grsec_enable_socket_server,
70832 + .maxlen = sizeof(int),
70833 + .mode = 0600,
70834 + .proc_handler = &proc_dointvec,
70835 + },
70836 + {
70837 + .procname = "socket_server_gid",
70838 + .data = &grsec_socket_server_gid,
70839 + .maxlen = sizeof(int),
70840 + .mode = 0600,
70841 + .proc_handler = &proc_dointvec,
70842 + },
70843 +#endif
70844 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
70845 + {
70846 + .procname = "audit_group",
70847 + .data = &grsec_enable_group,
70848 + .maxlen = sizeof(int),
70849 + .mode = 0600,
70850 + .proc_handler = &proc_dointvec,
70851 + },
70852 + {
70853 + .procname = "audit_gid",
70854 + .data = &grsec_audit_gid,
70855 + .maxlen = sizeof(int),
70856 + .mode = 0600,
70857 + .proc_handler = &proc_dointvec,
70858 + },
70859 +#endif
70860 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
70861 + {
70862 + .procname = "audit_chdir",
70863 + .data = &grsec_enable_chdir,
70864 + .maxlen = sizeof(int),
70865 + .mode = 0600,
70866 + .proc_handler = &proc_dointvec,
70867 + },
70868 +#endif
70869 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70870 + {
70871 + .procname = "audit_mount",
70872 + .data = &grsec_enable_mount,
70873 + .maxlen = sizeof(int),
70874 + .mode = 0600,
70875 + .proc_handler = &proc_dointvec,
70876 + },
70877 +#endif
70878 +#ifdef CONFIG_GRKERNSEC_DMESG
70879 + {
70880 + .procname = "dmesg",
70881 + .data = &grsec_enable_dmesg,
70882 + .maxlen = sizeof(int),
70883 + .mode = 0600,
70884 + .proc_handler = &proc_dointvec,
70885 + },
70886 +#endif
70887 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70888 + {
70889 + .procname = "chroot_findtask",
70890 + .data = &grsec_enable_chroot_findtask,
70891 + .maxlen = sizeof(int),
70892 + .mode = 0600,
70893 + .proc_handler = &proc_dointvec,
70894 + },
70895 +#endif
70896 +#ifdef CONFIG_GRKERNSEC_RESLOG
70897 + {
70898 + .procname = "resource_logging",
70899 + .data = &grsec_resource_logging,
70900 + .maxlen = sizeof(int),
70901 + .mode = 0600,
70902 + .proc_handler = &proc_dointvec,
70903 + },
70904 +#endif
70905 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70906 + {
70907 + .procname = "audit_ptrace",
70908 + .data = &grsec_enable_audit_ptrace,
70909 + .maxlen = sizeof(int),
70910 + .mode = 0600,
70911 + .proc_handler = &proc_dointvec,
70912 + },
70913 +#endif
70914 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
70915 + {
70916 + .procname = "harden_ptrace",
70917 + .data = &grsec_enable_harden_ptrace,
70918 + .maxlen = sizeof(int),
70919 + .mode = 0600,
70920 + .proc_handler = &proc_dointvec,
70921 + },
70922 +#endif
70923 + {
70924 + .procname = "grsec_lock",
70925 + .data = &grsec_lock,
70926 + .maxlen = sizeof(int),
70927 + .mode = 0600,
70928 + .proc_handler = &proc_dointvec,
70929 + },
70930 +#endif
70931 +#ifdef CONFIG_GRKERNSEC_ROFS
70932 + {
70933 + .procname = "romount_protect",
70934 + .data = &grsec_enable_rofs,
70935 + .maxlen = sizeof(int),
70936 + .mode = 0600,
70937 + .proc_handler = &proc_dointvec_minmax,
70938 + .extra1 = &one,
70939 + .extra2 = &one,
70940 + },
70941 +#endif
70942 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
70943 + {
70944 + .procname = "deny_new_usb",
70945 + .data = &grsec_deny_new_usb,
70946 + .maxlen = sizeof(int),
70947 + .mode = 0600,
70948 + .proc_handler = &proc_dointvec,
70949 + },
70950 +#endif
70951 + { }
70952 +};
70953 +#endif
70954 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
70955 new file mode 100644
70956 index 0000000..0dc13c3
70957 --- /dev/null
70958 +++ b/grsecurity/grsec_time.c
70959 @@ -0,0 +1,16 @@
70960 +#include <linux/kernel.h>
70961 +#include <linux/sched.h>
70962 +#include <linux/grinternal.h>
70963 +#include <linux/module.h>
70964 +
70965 +void
70966 +gr_log_timechange(void)
70967 +{
70968 +#ifdef CONFIG_GRKERNSEC_TIME
70969 + if (grsec_enable_time)
70970 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
70971 +#endif
70972 + return;
70973 +}
70974 +
70975 +EXPORT_SYMBOL(gr_log_timechange);
70976 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
70977 new file mode 100644
70978 index 0000000..ee57dcf
70979 --- /dev/null
70980 +++ b/grsecurity/grsec_tpe.c
70981 @@ -0,0 +1,73 @@
70982 +#include <linux/kernel.h>
70983 +#include <linux/sched.h>
70984 +#include <linux/file.h>
70985 +#include <linux/fs.h>
70986 +#include <linux/grinternal.h>
70987 +
70988 +extern int gr_acl_tpe_check(void);
70989 +
70990 +int
70991 +gr_tpe_allow(const struct file *file)
70992 +{
70993 +#ifdef CONFIG_GRKERNSEC
70994 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
70995 + const struct cred *cred = current_cred();
70996 + char *msg = NULL;
70997 + char *msg2 = NULL;
70998 +
70999 + // never restrict root
71000 + if (gr_is_global_root(cred->uid))
71001 + return 1;
71002 +
71003 + if (grsec_enable_tpe) {
71004 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71005 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
71006 + msg = "not being in trusted group";
71007 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
71008 + msg = "being in untrusted group";
71009 +#else
71010 + if (in_group_p(grsec_tpe_gid))
71011 + msg = "being in untrusted group";
71012 +#endif
71013 + }
71014 + if (!msg && gr_acl_tpe_check())
71015 + msg = "being in untrusted role";
71016 +
71017 + // not in any affected group/role
71018 + if (!msg)
71019 + goto next_check;
71020 +
71021 + if (gr_is_global_nonroot(inode->i_uid))
71022 + msg2 = "file in non-root-owned directory";
71023 + else if (inode->i_mode & S_IWOTH)
71024 + msg2 = "file in world-writable directory";
71025 + else if (inode->i_mode & S_IWGRP)
71026 + msg2 = "file in group-writable directory";
71027 +
71028 + if (msg && msg2) {
71029 + char fullmsg[70] = {0};
71030 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
71031 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
71032 + return 0;
71033 + }
71034 + msg = NULL;
71035 +next_check:
71036 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71037 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
71038 + return 1;
71039 +
71040 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
71041 + msg = "directory not owned by user";
71042 + else if (inode->i_mode & S_IWOTH)
71043 + msg = "file in world-writable directory";
71044 + else if (inode->i_mode & S_IWGRP)
71045 + msg = "file in group-writable directory";
71046 +
71047 + if (msg) {
71048 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
71049 + return 0;
71050 + }
71051 +#endif
71052 +#endif
71053 + return 1;
71054 +}
71055 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
71056 new file mode 100644
71057 index 0000000..ae02d8e
71058 --- /dev/null
71059 +++ b/grsecurity/grsec_usb.c
71060 @@ -0,0 +1,15 @@
71061 +#include <linux/kernel.h>
71062 +#include <linux/grinternal.h>
71063 +#include <linux/module.h>
71064 +
71065 +int gr_handle_new_usb(void)
71066 +{
71067 +#ifdef CONFIG_GRKERNSEC_DENYUSB
71068 + if (grsec_deny_new_usb) {
71069 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
71070 + return 1;
71071 + }
71072 +#endif
71073 + return 0;
71074 +}
71075 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
71076 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
71077 new file mode 100644
71078 index 0000000..9f7b1ac
71079 --- /dev/null
71080 +++ b/grsecurity/grsum.c
71081 @@ -0,0 +1,61 @@
71082 +#include <linux/err.h>
71083 +#include <linux/kernel.h>
71084 +#include <linux/sched.h>
71085 +#include <linux/mm.h>
71086 +#include <linux/scatterlist.h>
71087 +#include <linux/crypto.h>
71088 +#include <linux/gracl.h>
71089 +
71090 +
71091 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
71092 +#error "crypto and sha256 must be built into the kernel"
71093 +#endif
71094 +
71095 +int
71096 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
71097 +{
71098 + char *p;
71099 + struct crypto_hash *tfm;
71100 + struct hash_desc desc;
71101 + struct scatterlist sg;
71102 + unsigned char temp_sum[GR_SHA_LEN];
71103 + volatile int retval = 0;
71104 + volatile int dummy = 0;
71105 + unsigned int i;
71106 +
71107 + sg_init_table(&sg, 1);
71108 +
71109 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
71110 + if (IS_ERR(tfm)) {
71111 + /* should never happen, since sha256 should be built in */
71112 + return 1;
71113 + }
71114 +
71115 + desc.tfm = tfm;
71116 + desc.flags = 0;
71117 +
71118 + crypto_hash_init(&desc);
71119 +
71120 + p = salt;
71121 + sg_set_buf(&sg, p, GR_SALT_LEN);
71122 + crypto_hash_update(&desc, &sg, sg.length);
71123 +
71124 + p = entry->pw;
71125 + sg_set_buf(&sg, p, strlen(p));
71126 +
71127 + crypto_hash_update(&desc, &sg, sg.length);
71128 +
71129 + crypto_hash_final(&desc, temp_sum);
71130 +
71131 + memset(entry->pw, 0, GR_PW_LEN);
71132 +
71133 + for (i = 0; i < GR_SHA_LEN; i++)
71134 + if (sum[i] != temp_sum[i])
71135 + retval = 1;
71136 + else
71137 + dummy = 1; // waste a cycle
71138 +
71139 + crypto_free_hash(tfm);
71140 +
71141 + return retval;
71142 +}
71143 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
71144 index 77ff547..181834f 100644
71145 --- a/include/asm-generic/4level-fixup.h
71146 +++ b/include/asm-generic/4level-fixup.h
71147 @@ -13,8 +13,10 @@
71148 #define pmd_alloc(mm, pud, address) \
71149 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
71150 NULL: pmd_offset(pud, address))
71151 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
71152
71153 #define pud_alloc(mm, pgd, address) (pgd)
71154 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
71155 #define pud_offset(pgd, start) (pgd)
71156 #define pud_none(pud) 0
71157 #define pud_bad(pud) 0
71158 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
71159 index b7babf0..04ad282 100644
71160 --- a/include/asm-generic/atomic-long.h
71161 +++ b/include/asm-generic/atomic-long.h
71162 @@ -22,6 +22,12 @@
71163
71164 typedef atomic64_t atomic_long_t;
71165
71166 +#ifdef CONFIG_PAX_REFCOUNT
71167 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
71168 +#else
71169 +typedef atomic64_t atomic_long_unchecked_t;
71170 +#endif
71171 +
71172 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
71173
71174 static inline long atomic_long_read(atomic_long_t *l)
71175 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71176 return (long)atomic64_read(v);
71177 }
71178
71179 +#ifdef CONFIG_PAX_REFCOUNT
71180 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71181 +{
71182 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71183 +
71184 + return (long)atomic64_read_unchecked(v);
71185 +}
71186 +#endif
71187 +
71188 static inline void atomic_long_set(atomic_long_t *l, long i)
71189 {
71190 atomic64_t *v = (atomic64_t *)l;
71191 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71192 atomic64_set(v, i);
71193 }
71194
71195 +#ifdef CONFIG_PAX_REFCOUNT
71196 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71197 +{
71198 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71199 +
71200 + atomic64_set_unchecked(v, i);
71201 +}
71202 +#endif
71203 +
71204 static inline void atomic_long_inc(atomic_long_t *l)
71205 {
71206 atomic64_t *v = (atomic64_t *)l;
71207 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71208 atomic64_inc(v);
71209 }
71210
71211 +#ifdef CONFIG_PAX_REFCOUNT
71212 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71213 +{
71214 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71215 +
71216 + atomic64_inc_unchecked(v);
71217 +}
71218 +#endif
71219 +
71220 static inline void atomic_long_dec(atomic_long_t *l)
71221 {
71222 atomic64_t *v = (atomic64_t *)l;
71223 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71224 atomic64_dec(v);
71225 }
71226
71227 +#ifdef CONFIG_PAX_REFCOUNT
71228 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71229 +{
71230 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71231 +
71232 + atomic64_dec_unchecked(v);
71233 +}
71234 +#endif
71235 +
71236 static inline void atomic_long_add(long i, atomic_long_t *l)
71237 {
71238 atomic64_t *v = (atomic64_t *)l;
71239 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71240 atomic64_add(i, v);
71241 }
71242
71243 +#ifdef CONFIG_PAX_REFCOUNT
71244 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71245 +{
71246 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71247 +
71248 + atomic64_add_unchecked(i, v);
71249 +}
71250 +#endif
71251 +
71252 static inline void atomic_long_sub(long i, atomic_long_t *l)
71253 {
71254 atomic64_t *v = (atomic64_t *)l;
71255 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71256 atomic64_sub(i, v);
71257 }
71258
71259 +#ifdef CONFIG_PAX_REFCOUNT
71260 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71261 +{
71262 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71263 +
71264 + atomic64_sub_unchecked(i, v);
71265 +}
71266 +#endif
71267 +
71268 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71269 {
71270 atomic64_t *v = (atomic64_t *)l;
71271 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71272 return (long)atomic64_add_return(i, v);
71273 }
71274
71275 +#ifdef CONFIG_PAX_REFCOUNT
71276 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71277 +{
71278 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71279 +
71280 + return (long)atomic64_add_return_unchecked(i, v);
71281 +}
71282 +#endif
71283 +
71284 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71285 {
71286 atomic64_t *v = (atomic64_t *)l;
71287 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71288 return (long)atomic64_inc_return(v);
71289 }
71290
71291 +#ifdef CONFIG_PAX_REFCOUNT
71292 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71293 +{
71294 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71295 +
71296 + return (long)atomic64_inc_return_unchecked(v);
71297 +}
71298 +#endif
71299 +
71300 static inline long atomic_long_dec_return(atomic_long_t *l)
71301 {
71302 atomic64_t *v = (atomic64_t *)l;
71303 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71304
71305 typedef atomic_t atomic_long_t;
71306
71307 +#ifdef CONFIG_PAX_REFCOUNT
71308 +typedef atomic_unchecked_t atomic_long_unchecked_t;
71309 +#else
71310 +typedef atomic_t atomic_long_unchecked_t;
71311 +#endif
71312 +
71313 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
71314 static inline long atomic_long_read(atomic_long_t *l)
71315 {
71316 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71317 return (long)atomic_read(v);
71318 }
71319
71320 +#ifdef CONFIG_PAX_REFCOUNT
71321 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71322 +{
71323 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71324 +
71325 + return (long)atomic_read_unchecked(v);
71326 +}
71327 +#endif
71328 +
71329 static inline void atomic_long_set(atomic_long_t *l, long i)
71330 {
71331 atomic_t *v = (atomic_t *)l;
71332 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71333 atomic_set(v, i);
71334 }
71335
71336 +#ifdef CONFIG_PAX_REFCOUNT
71337 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71338 +{
71339 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71340 +
71341 + atomic_set_unchecked(v, i);
71342 +}
71343 +#endif
71344 +
71345 static inline void atomic_long_inc(atomic_long_t *l)
71346 {
71347 atomic_t *v = (atomic_t *)l;
71348 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71349 atomic_inc(v);
71350 }
71351
71352 +#ifdef CONFIG_PAX_REFCOUNT
71353 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71354 +{
71355 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71356 +
71357 + atomic_inc_unchecked(v);
71358 +}
71359 +#endif
71360 +
71361 static inline void atomic_long_dec(atomic_long_t *l)
71362 {
71363 atomic_t *v = (atomic_t *)l;
71364 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71365 atomic_dec(v);
71366 }
71367
71368 +#ifdef CONFIG_PAX_REFCOUNT
71369 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71370 +{
71371 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71372 +
71373 + atomic_dec_unchecked(v);
71374 +}
71375 +#endif
71376 +
71377 static inline void atomic_long_add(long i, atomic_long_t *l)
71378 {
71379 atomic_t *v = (atomic_t *)l;
71380 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71381 atomic_add(i, v);
71382 }
71383
71384 +#ifdef CONFIG_PAX_REFCOUNT
71385 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71386 +{
71387 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71388 +
71389 + atomic_add_unchecked(i, v);
71390 +}
71391 +#endif
71392 +
71393 static inline void atomic_long_sub(long i, atomic_long_t *l)
71394 {
71395 atomic_t *v = (atomic_t *)l;
71396 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71397 atomic_sub(i, v);
71398 }
71399
71400 +#ifdef CONFIG_PAX_REFCOUNT
71401 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71402 +{
71403 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71404 +
71405 + atomic_sub_unchecked(i, v);
71406 +}
71407 +#endif
71408 +
71409 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71410 {
71411 atomic_t *v = (atomic_t *)l;
71412 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71413 return (long)atomic_add_return(i, v);
71414 }
71415
71416 +#ifdef CONFIG_PAX_REFCOUNT
71417 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71418 +{
71419 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71420 +
71421 + return (long)atomic_add_return_unchecked(i, v);
71422 +}
71423 +
71424 +#endif
71425 +
71426 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71427 {
71428 atomic_t *v = (atomic_t *)l;
71429 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71430 return (long)atomic_inc_return(v);
71431 }
71432
71433 +#ifdef CONFIG_PAX_REFCOUNT
71434 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71435 +{
71436 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71437 +
71438 + return (long)atomic_inc_return_unchecked(v);
71439 +}
71440 +#endif
71441 +
71442 static inline long atomic_long_dec_return(atomic_long_t *l)
71443 {
71444 atomic_t *v = (atomic_t *)l;
71445 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71446
71447 #endif /* BITS_PER_LONG == 64 */
71448
71449 +#ifdef CONFIG_PAX_REFCOUNT
71450 +static inline void pax_refcount_needs_these_functions(void)
71451 +{
71452 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
71453 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
71454 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
71455 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
71456 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
71457 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
71458 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
71459 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
71460 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
71461 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
71462 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
71463 +#ifdef CONFIG_X86
71464 + atomic_clear_mask_unchecked(0, NULL);
71465 + atomic_set_mask_unchecked(0, NULL);
71466 +#endif
71467 +
71468 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
71469 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
71470 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
71471 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
71472 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
71473 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
71474 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
71475 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
71476 +}
71477 +#else
71478 +#define atomic_read_unchecked(v) atomic_read(v)
71479 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
71480 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
71481 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
71482 +#define atomic_inc_unchecked(v) atomic_inc(v)
71483 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
71484 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
71485 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
71486 +#define atomic_dec_unchecked(v) atomic_dec(v)
71487 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
71488 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
71489 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
71490 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
71491 +
71492 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
71493 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
71494 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
71495 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
71496 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
71497 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
71498 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
71499 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
71500 +#endif
71501 +
71502 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
71503 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
71504 index 33bd2de..f31bff97 100644
71505 --- a/include/asm-generic/atomic.h
71506 +++ b/include/asm-generic/atomic.h
71507 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
71508 * Atomically clears the bits set in @mask from @v
71509 */
71510 #ifndef atomic_clear_mask
71511 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
71512 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
71513 {
71514 unsigned long flags;
71515
71516 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
71517 index b18ce4f..2ee2843 100644
71518 --- a/include/asm-generic/atomic64.h
71519 +++ b/include/asm-generic/atomic64.h
71520 @@ -16,6 +16,8 @@ typedef struct {
71521 long long counter;
71522 } atomic64_t;
71523
71524 +typedef atomic64_t atomic64_unchecked_t;
71525 +
71526 #define ATOMIC64_INIT(i) { (i) }
71527
71528 extern long long atomic64_read(const atomic64_t *v);
71529 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
71530 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
71531 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
71532
71533 +#define atomic64_read_unchecked(v) atomic64_read(v)
71534 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
71535 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
71536 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
71537 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
71538 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
71539 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
71540 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
71541 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
71542 +
71543 #endif /* _ASM_GENERIC_ATOMIC64_H */
71544 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
71545 index 1bfcfe5..e04c5c9 100644
71546 --- a/include/asm-generic/cache.h
71547 +++ b/include/asm-generic/cache.h
71548 @@ -6,7 +6,7 @@
71549 * cache lines need to provide their own cache.h.
71550 */
71551
71552 -#define L1_CACHE_SHIFT 5
71553 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
71554 +#define L1_CACHE_SHIFT 5UL
71555 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
71556
71557 #endif /* __ASM_GENERIC_CACHE_H */
71558 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
71559 index 0d68a1e..b74a761 100644
71560 --- a/include/asm-generic/emergency-restart.h
71561 +++ b/include/asm-generic/emergency-restart.h
71562 @@ -1,7 +1,7 @@
71563 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
71564 #define _ASM_GENERIC_EMERGENCY_RESTART_H
71565
71566 -static inline void machine_emergency_restart(void)
71567 +static inline __noreturn void machine_emergency_restart(void)
71568 {
71569 machine_restart(NULL);
71570 }
71571 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
71572 index 90f99c7..00ce236 100644
71573 --- a/include/asm-generic/kmap_types.h
71574 +++ b/include/asm-generic/kmap_types.h
71575 @@ -2,9 +2,9 @@
71576 #define _ASM_GENERIC_KMAP_TYPES_H
71577
71578 #ifdef __WITH_KM_FENCE
71579 -# define KM_TYPE_NR 41
71580 +# define KM_TYPE_NR 42
71581 #else
71582 -# define KM_TYPE_NR 20
71583 +# define KM_TYPE_NR 21
71584 #endif
71585
71586 #endif
71587 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
71588 index 9ceb03b..62b0b8f 100644
71589 --- a/include/asm-generic/local.h
71590 +++ b/include/asm-generic/local.h
71591 @@ -23,24 +23,37 @@ typedef struct
71592 atomic_long_t a;
71593 } local_t;
71594
71595 +typedef struct {
71596 + atomic_long_unchecked_t a;
71597 +} local_unchecked_t;
71598 +
71599 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
71600
71601 #define local_read(l) atomic_long_read(&(l)->a)
71602 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
71603 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
71604 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
71605 #define local_inc(l) atomic_long_inc(&(l)->a)
71606 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
71607 #define local_dec(l) atomic_long_dec(&(l)->a)
71608 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
71609 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
71610 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
71611 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
71612 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
71613
71614 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
71615 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
71616 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
71617 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
71618 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
71619 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
71620 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
71621 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
71622 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
71623
71624 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
71625 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
71626 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
71627 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
71628 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
71629 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
71630 index 725612b..9cc513a 100644
71631 --- a/include/asm-generic/pgtable-nopmd.h
71632 +++ b/include/asm-generic/pgtable-nopmd.h
71633 @@ -1,14 +1,19 @@
71634 #ifndef _PGTABLE_NOPMD_H
71635 #define _PGTABLE_NOPMD_H
71636
71637 -#ifndef __ASSEMBLY__
71638 -
71639 #include <asm-generic/pgtable-nopud.h>
71640
71641 -struct mm_struct;
71642 -
71643 #define __PAGETABLE_PMD_FOLDED
71644
71645 +#define PMD_SHIFT PUD_SHIFT
71646 +#define PTRS_PER_PMD 1
71647 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
71648 +#define PMD_MASK (~(PMD_SIZE-1))
71649 +
71650 +#ifndef __ASSEMBLY__
71651 +
71652 +struct mm_struct;
71653 +
71654 /*
71655 * Having the pmd type consist of a pud gets the size right, and allows
71656 * us to conceptually access the pud entry that this pmd is folded into
71657 @@ -16,11 +21,6 @@ struct mm_struct;
71658 */
71659 typedef struct { pud_t pud; } pmd_t;
71660
71661 -#define PMD_SHIFT PUD_SHIFT
71662 -#define PTRS_PER_PMD 1
71663 -#define PMD_SIZE (1UL << PMD_SHIFT)
71664 -#define PMD_MASK (~(PMD_SIZE-1))
71665 -
71666 /*
71667 * The "pud_xxx()" functions here are trivial for a folded two-level
71668 * setup: the pmd is never bad, and a pmd always exists (as it's folded
71669 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
71670 index 810431d..0ec4804f 100644
71671 --- a/include/asm-generic/pgtable-nopud.h
71672 +++ b/include/asm-generic/pgtable-nopud.h
71673 @@ -1,10 +1,15 @@
71674 #ifndef _PGTABLE_NOPUD_H
71675 #define _PGTABLE_NOPUD_H
71676
71677 -#ifndef __ASSEMBLY__
71678 -
71679 #define __PAGETABLE_PUD_FOLDED
71680
71681 +#define PUD_SHIFT PGDIR_SHIFT
71682 +#define PTRS_PER_PUD 1
71683 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
71684 +#define PUD_MASK (~(PUD_SIZE-1))
71685 +
71686 +#ifndef __ASSEMBLY__
71687 +
71688 /*
71689 * Having the pud type consist of a pgd gets the size right, and allows
71690 * us to conceptually access the pgd entry that this pud is folded into
71691 @@ -12,11 +17,6 @@
71692 */
71693 typedef struct { pgd_t pgd; } pud_t;
71694
71695 -#define PUD_SHIFT PGDIR_SHIFT
71696 -#define PTRS_PER_PUD 1
71697 -#define PUD_SIZE (1UL << PUD_SHIFT)
71698 -#define PUD_MASK (~(PUD_SIZE-1))
71699 -
71700 /*
71701 * The "pgd_xxx()" functions here are trivial for a folded two-level
71702 * setup: the pud is never bad, and a pud always exists (as it's folded
71703 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
71704 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
71705
71706 #define pgd_populate(mm, pgd, pud) do { } while (0)
71707 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
71708 /*
71709 * (puds are folded into pgds so this doesn't get actually called,
71710 * but the define is needed for a generic inline function.)
71711 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
71712 index 0807ddf..cd67747 100644
71713 --- a/include/asm-generic/pgtable.h
71714 +++ b/include/asm-generic/pgtable.h
71715 @@ -741,6 +741,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
71716 }
71717 #endif /* CONFIG_NUMA_BALANCING */
71718
71719 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
71720 +#ifdef CONFIG_PAX_KERNEXEC
71721 +#error KERNEXEC requires pax_open_kernel
71722 +#else
71723 +static inline unsigned long pax_open_kernel(void) { return 0; }
71724 +#endif
71725 +#endif
71726 +
71727 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
71728 +#ifdef CONFIG_PAX_KERNEXEC
71729 +#error KERNEXEC requires pax_close_kernel
71730 +#else
71731 +static inline unsigned long pax_close_kernel(void) { return 0; }
71732 +#endif
71733 +#endif
71734 +
71735 #endif /* CONFIG_MMU */
71736
71737 #endif /* !__ASSEMBLY__ */
71738 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
71739 index dc1269c..48a4f51 100644
71740 --- a/include/asm-generic/uaccess.h
71741 +++ b/include/asm-generic/uaccess.h
71742 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
71743 return __clear_user(to, n);
71744 }
71745
71746 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
71747 +#ifdef CONFIG_PAX_MEMORY_UDEREF
71748 +#error UDEREF requires pax_open_userland
71749 +#else
71750 +static inline unsigned long pax_open_userland(void) { return 0; }
71751 +#endif
71752 +#endif
71753 +
71754 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
71755 +#ifdef CONFIG_PAX_MEMORY_UDEREF
71756 +#error UDEREF requires pax_close_userland
71757 +#else
71758 +static inline unsigned long pax_close_userland(void) { return 0; }
71759 +#endif
71760 +#endif
71761 +
71762 #endif /* __ASM_GENERIC_UACCESS_H */
71763 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
71764 index 69732d2..cbe16d9 100644
71765 --- a/include/asm-generic/vmlinux.lds.h
71766 +++ b/include/asm-generic/vmlinux.lds.h
71767 @@ -227,6 +227,7 @@
71768 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
71769 VMLINUX_SYMBOL(__start_rodata) = .; \
71770 *(.rodata) *(.rodata.*) \
71771 + *(.data..read_only) \
71772 *(__vermagic) /* Kernel version magic */ \
71773 . = ALIGN(8); \
71774 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
71775 @@ -710,17 +711,18 @@
71776 * section in the linker script will go there too. @phdr should have
71777 * a leading colon.
71778 *
71779 - * Note that this macros defines __per_cpu_load as an absolute symbol.
71780 + * Note that this macros defines per_cpu_load as an absolute symbol.
71781 * If there is no need to put the percpu section at a predetermined
71782 * address, use PERCPU_SECTION.
71783 */
71784 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
71785 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
71786 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
71787 + per_cpu_load = .; \
71788 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
71789 - LOAD_OFFSET) { \
71790 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
71791 PERCPU_INPUT(cacheline) \
71792 } phdr \
71793 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
71794 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
71795
71796 /**
71797 * PERCPU_SECTION - define output section for percpu area, simple version
71798 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
71799 index 418d270..bfd2794 100644
71800 --- a/include/crypto/algapi.h
71801 +++ b/include/crypto/algapi.h
71802 @@ -34,7 +34,7 @@ struct crypto_type {
71803 unsigned int maskclear;
71804 unsigned int maskset;
71805 unsigned int tfmsize;
71806 -};
71807 +} __do_const;
71808
71809 struct crypto_instance {
71810 struct crypto_alg alg;
71811 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
71812 index 12083dc..39740ec 100644
71813 --- a/include/drm/drmP.h
71814 +++ b/include/drm/drmP.h
71815 @@ -69,6 +69,7 @@
71816 #include <linux/workqueue.h>
71817 #include <linux/poll.h>
71818 #include <asm/pgalloc.h>
71819 +#include <asm/local.h>
71820 #include <drm/drm.h>
71821 #include <drm/drm_sarea.h>
71822
71823 @@ -293,10 +294,12 @@ do { \
71824 * \param cmd command.
71825 * \param arg argument.
71826 */
71827 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
71828 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
71829 + struct drm_file *file_priv);
71830 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
71831 struct drm_file *file_priv);
71832
71833 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
71834 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
71835 unsigned long arg);
71836
71837 #define DRM_IOCTL_NR(n) _IOC_NR(n)
71838 @@ -311,10 +314,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
71839 struct drm_ioctl_desc {
71840 unsigned int cmd;
71841 int flags;
71842 - drm_ioctl_t *func;
71843 + drm_ioctl_t func;
71844 unsigned int cmd_drv;
71845 const char *name;
71846 -};
71847 +} __do_const;
71848
71849 /**
71850 * Creates a driver or general drm_ioctl_desc array entry for the given
71851 @@ -1015,7 +1018,7 @@ struct drm_info_list {
71852 int (*show)(struct seq_file*, void*); /** show callback */
71853 u32 driver_features; /**< Required driver features for this entry */
71854 void *data;
71855 -};
71856 +} __do_const;
71857
71858 /**
71859 * debugfs node structure. This structure represents a debugfs file.
71860 @@ -1088,7 +1091,7 @@ struct drm_device {
71861
71862 /** \name Usage Counters */
71863 /*@{ */
71864 - int open_count; /**< Outstanding files open */
71865 + local_t open_count; /**< Outstanding files open */
71866 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
71867 atomic_t vma_count; /**< Outstanding vma areas open */
71868 int buf_use; /**< Buffers in use -- cannot alloc */
71869 @@ -1099,7 +1102,7 @@ struct drm_device {
71870 /*@{ */
71871 unsigned long counters;
71872 enum drm_stat_type types[15];
71873 - atomic_t counts[15];
71874 + atomic_unchecked_t counts[15];
71875 /*@} */
71876
71877 struct list_head filelist;
71878 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
71879 index f43d556..94d9343 100644
71880 --- a/include/drm/drm_crtc_helper.h
71881 +++ b/include/drm/drm_crtc_helper.h
71882 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
71883 struct drm_connector *connector);
71884 /* disable encoder when not in use - more explicit than dpms off */
71885 void (*disable)(struct drm_encoder *encoder);
71886 -};
71887 +} __no_const;
71888
71889 /**
71890 * drm_connector_helper_funcs - helper operations for connectors
71891 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
71892 index 72dcbe8..8db58d7 100644
71893 --- a/include/drm/ttm/ttm_memory.h
71894 +++ b/include/drm/ttm/ttm_memory.h
71895 @@ -48,7 +48,7 @@
71896
71897 struct ttm_mem_shrink {
71898 int (*do_shrink) (struct ttm_mem_shrink *);
71899 -};
71900 +} __no_const;
71901
71902 /**
71903 * struct ttm_mem_global - Global memory accounting structure.
71904 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
71905 index 4b840e8..155d235 100644
71906 --- a/include/keys/asymmetric-subtype.h
71907 +++ b/include/keys/asymmetric-subtype.h
71908 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
71909 /* Verify the signature on a key of this subtype (optional) */
71910 int (*verify_signature)(const struct key *key,
71911 const struct public_key_signature *sig);
71912 -};
71913 +} __do_const;
71914
71915 /**
71916 * asymmetric_key_subtype - Get the subtype from an asymmetric key
71917 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
71918 index c1da539..1dcec55 100644
71919 --- a/include/linux/atmdev.h
71920 +++ b/include/linux/atmdev.h
71921 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
71922 #endif
71923
71924 struct k_atm_aal_stats {
71925 -#define __HANDLE_ITEM(i) atomic_t i
71926 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71927 __AAL_STAT_ITEMS
71928 #undef __HANDLE_ITEM
71929 };
71930 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
71931 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
71932 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
71933 struct module *owner;
71934 -};
71935 +} __do_const ;
71936
71937 struct atmphy_ops {
71938 int (*start)(struct atm_dev *dev);
71939 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
71940 index 70cf138..0418ee2 100644
71941 --- a/include/linux/binfmts.h
71942 +++ b/include/linux/binfmts.h
71943 @@ -73,8 +73,10 @@ struct linux_binfmt {
71944 int (*load_binary)(struct linux_binprm *);
71945 int (*load_shlib)(struct file *);
71946 int (*core_dump)(struct coredump_params *cprm);
71947 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
71948 + void (*handle_mmap)(struct file *);
71949 unsigned long min_coredump; /* minimal dump size */
71950 -};
71951 +} __do_const;
71952
71953 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
71954
71955 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
71956 index 2fdb4a4..54aad7e 100644
71957 --- a/include/linux/blkdev.h
71958 +++ b/include/linux/blkdev.h
71959 @@ -1526,7 +1526,7 @@ struct block_device_operations {
71960 /* this callback is with swap_lock and sometimes page table lock held */
71961 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
71962 struct module *owner;
71963 -};
71964 +} __do_const;
71965
71966 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
71967 unsigned long);
71968 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
71969 index 7c2e030..b72475d 100644
71970 --- a/include/linux/blktrace_api.h
71971 +++ b/include/linux/blktrace_api.h
71972 @@ -23,7 +23,7 @@ struct blk_trace {
71973 struct dentry *dir;
71974 struct dentry *dropped_file;
71975 struct dentry *msg_file;
71976 - atomic_t dropped;
71977 + atomic_unchecked_t dropped;
71978 };
71979
71980 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
71981 diff --git a/include/linux/cache.h b/include/linux/cache.h
71982 index 4c57065..40346da 100644
71983 --- a/include/linux/cache.h
71984 +++ b/include/linux/cache.h
71985 @@ -16,6 +16,14 @@
71986 #define __read_mostly
71987 #endif
71988
71989 +#ifndef __read_only
71990 +#ifdef CONFIG_PAX_KERNEXEC
71991 +#error KERNEXEC requires __read_only
71992 +#else
71993 +#define __read_only __read_mostly
71994 +#endif
71995 +#endif
71996 +
71997 #ifndef ____cacheline_aligned
71998 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
71999 #endif
72000 diff --git a/include/linux/capability.h b/include/linux/capability.h
72001 index d9a4f7f4..19f77d6 100644
72002 --- a/include/linux/capability.h
72003 +++ b/include/linux/capability.h
72004 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
72005 extern bool nsown_capable(int cap);
72006 extern bool inode_capable(const struct inode *inode, int cap);
72007 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
72008 +extern bool capable_nolog(int cap);
72009 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
72010 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
72011
72012 /* audit system wants to get cap info from files as well */
72013 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
72014
72015 +extern int is_privileged_binary(const struct dentry *dentry);
72016 +
72017 #endif /* !_LINUX_CAPABILITY_H */
72018 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
72019 index 8609d57..86e4d79 100644
72020 --- a/include/linux/cdrom.h
72021 +++ b/include/linux/cdrom.h
72022 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
72023
72024 /* driver specifications */
72025 const int capability; /* capability flags */
72026 - int n_minors; /* number of active minor devices */
72027 /* handle uniform packets for scsi type devices (scsi,atapi) */
72028 int (*generic_packet) (struct cdrom_device_info *,
72029 struct packet_command *);
72030 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
72031 index 4ce9056..86caac6 100644
72032 --- a/include/linux/cleancache.h
72033 +++ b/include/linux/cleancache.h
72034 @@ -31,7 +31,7 @@ struct cleancache_ops {
72035 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
72036 void (*invalidate_inode)(int, struct cleancache_filekey);
72037 void (*invalidate_fs)(int);
72038 -};
72039 +} __no_const;
72040
72041 extern struct cleancache_ops *
72042 cleancache_register_ops(struct cleancache_ops *ops);
72043 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
72044 index 1ec14a7..d0654a2 100644
72045 --- a/include/linux/clk-provider.h
72046 +++ b/include/linux/clk-provider.h
72047 @@ -132,6 +132,7 @@ struct clk_ops {
72048 unsigned long);
72049 void (*init)(struct clk_hw *hw);
72050 };
72051 +typedef struct clk_ops __no_const clk_ops_no_const;
72052
72053 /**
72054 * struct clk_init_data - holds init data that's common to all clocks and is
72055 diff --git a/include/linux/compat.h b/include/linux/compat.h
72056 index ec1aee4..1077986 100644
72057 --- a/include/linux/compat.h
72058 +++ b/include/linux/compat.h
72059 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
72060 compat_size_t __user *len_ptr);
72061
72062 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
72063 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
72064 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
72065 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
72066 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
72067 compat_ssize_t msgsz, int msgflg);
72068 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
72069 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
72070 compat_ulong_t addr, compat_ulong_t data);
72071 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
72072 - compat_long_t addr, compat_long_t data);
72073 + compat_ulong_t addr, compat_ulong_t data);
72074
72075 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
72076 /*
72077 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
72078 index 842de22..7f3a41f 100644
72079 --- a/include/linux/compiler-gcc4.h
72080 +++ b/include/linux/compiler-gcc4.h
72081 @@ -39,9 +39,29 @@
72082 # define __compiletime_warning(message) __attribute__((warning(message)))
72083 # define __compiletime_error(message) __attribute__((error(message)))
72084 #endif /* __CHECKER__ */
72085 +
72086 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
72087 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
72088 +#define __bos0(ptr) __bos((ptr), 0)
72089 +#define __bos1(ptr) __bos((ptr), 1)
72090 #endif /* GCC_VERSION >= 40300 */
72091
72092 #if GCC_VERSION >= 40500
72093 +
72094 +#ifdef CONSTIFY_PLUGIN
72095 +#define __no_const __attribute__((no_const))
72096 +#define __do_const __attribute__((do_const))
72097 +#endif
72098 +
72099 +#ifdef SIZE_OVERFLOW_PLUGIN
72100 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
72101 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
72102 +#endif
72103 +
72104 +#ifdef LATENT_ENTROPY_PLUGIN
72105 +#define __latent_entropy __attribute__((latent_entropy))
72106 +#endif
72107 +
72108 /*
72109 * Mark a position in code as unreachable. This can be used to
72110 * suppress control flow warnings after asm blocks that transfer
72111 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
72112 index 92669cd..1771a15 100644
72113 --- a/include/linux/compiler.h
72114 +++ b/include/linux/compiler.h
72115 @@ -5,11 +5,14 @@
72116
72117 #ifdef __CHECKER__
72118 # define __user __attribute__((noderef, address_space(1)))
72119 +# define __force_user __force __user
72120 # define __kernel __attribute__((address_space(0)))
72121 +# define __force_kernel __force __kernel
72122 # define __safe __attribute__((safe))
72123 # define __force __attribute__((force))
72124 # define __nocast __attribute__((nocast))
72125 # define __iomem __attribute__((noderef, address_space(2)))
72126 +# define __force_iomem __force __iomem
72127 # define __must_hold(x) __attribute__((context(x,1,1)))
72128 # define __acquires(x) __attribute__((context(x,0,1)))
72129 # define __releases(x) __attribute__((context(x,1,0)))
72130 @@ -17,20 +20,37 @@
72131 # define __release(x) __context__(x,-1)
72132 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
72133 # define __percpu __attribute__((noderef, address_space(3)))
72134 +# define __force_percpu __force __percpu
72135 #ifdef CONFIG_SPARSE_RCU_POINTER
72136 # define __rcu __attribute__((noderef, address_space(4)))
72137 +# define __force_rcu __force __rcu
72138 #else
72139 # define __rcu
72140 +# define __force_rcu
72141 #endif
72142 extern void __chk_user_ptr(const volatile void __user *);
72143 extern void __chk_io_ptr(const volatile void __iomem *);
72144 #else
72145 -# define __user
72146 -# define __kernel
72147 +# ifdef CHECKER_PLUGIN
72148 +//# define __user
72149 +//# define __force_user
72150 +//# define __kernel
72151 +//# define __force_kernel
72152 +# else
72153 +# ifdef STRUCTLEAK_PLUGIN
72154 +# define __user __attribute__((user))
72155 +# else
72156 +# define __user
72157 +# endif
72158 +# define __force_user
72159 +# define __kernel
72160 +# define __force_kernel
72161 +# endif
72162 # define __safe
72163 # define __force
72164 # define __nocast
72165 # define __iomem
72166 +# define __force_iomem
72167 # define __chk_user_ptr(x) (void)0
72168 # define __chk_io_ptr(x) (void)0
72169 # define __builtin_warning(x, y...) (1)
72170 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
72171 # define __release(x) (void)0
72172 # define __cond_lock(x,c) (c)
72173 # define __percpu
72174 +# define __force_percpu
72175 # define __rcu
72176 +# define __force_rcu
72177 #endif
72178
72179 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
72180 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72181 # define __attribute_const__ /* unimplemented */
72182 #endif
72183
72184 +#ifndef __no_const
72185 +# define __no_const
72186 +#endif
72187 +
72188 +#ifndef __do_const
72189 +# define __do_const
72190 +#endif
72191 +
72192 +#ifndef __size_overflow
72193 +# define __size_overflow(...)
72194 +#endif
72195 +
72196 +#ifndef __intentional_overflow
72197 +# define __intentional_overflow(...)
72198 +#endif
72199 +
72200 +#ifndef __latent_entropy
72201 +# define __latent_entropy
72202 +#endif
72203 +
72204 /*
72205 * Tell gcc if a function is cold. The compiler will assume any path
72206 * directly leading to the call is unlikely.
72207 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72208 #define __cold
72209 #endif
72210
72211 +#ifndef __alloc_size
72212 +#define __alloc_size(...)
72213 +#endif
72214 +
72215 +#ifndef __bos
72216 +#define __bos(ptr, arg)
72217 +#endif
72218 +
72219 +#ifndef __bos0
72220 +#define __bos0(ptr)
72221 +#endif
72222 +
72223 +#ifndef __bos1
72224 +#define __bos1(ptr)
72225 +#endif
72226 +
72227 /* Simple shorthand for a section definition */
72228 #ifndef __section
72229 # define __section(S) __attribute__ ((__section__(#S)))
72230 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72231 * use is to mediate communication between process-level code and irq/NMI
72232 * handlers, all running on the same CPU.
72233 */
72234 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
72235 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
72236 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
72237
72238 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
72239 #ifdef CONFIG_KPROBES
72240 diff --git a/include/linux/completion.h b/include/linux/completion.h
72241 index 3cd574d..adce5fa 100644
72242 --- a/include/linux/completion.h
72243 +++ b/include/linux/completion.h
72244 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
72245 extern void wait_for_completion(struct completion *);
72246 extern void wait_for_completion_io(struct completion *);
72247 extern int wait_for_completion_interruptible(struct completion *x);
72248 -extern int wait_for_completion_killable(struct completion *x);
72249 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
72250 extern unsigned long wait_for_completion_timeout(struct completion *x,
72251 unsigned long timeout);
72252 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
72253 unsigned long timeout);
72254 extern long wait_for_completion_interruptible_timeout(
72255 - struct completion *x, unsigned long timeout);
72256 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72257 extern long wait_for_completion_killable_timeout(
72258 - struct completion *x, unsigned long timeout);
72259 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72260 extern bool try_wait_for_completion(struct completion *x);
72261 extern bool completion_done(struct completion *x);
72262
72263 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
72264 index 34025df..d94bbbc 100644
72265 --- a/include/linux/configfs.h
72266 +++ b/include/linux/configfs.h
72267 @@ -125,7 +125,7 @@ struct configfs_attribute {
72268 const char *ca_name;
72269 struct module *ca_owner;
72270 umode_t ca_mode;
72271 -};
72272 +} __do_const;
72273
72274 /*
72275 * Users often need to create attribute structures for their configurable
72276 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
72277 index 90d5a15..950cb80 100644
72278 --- a/include/linux/cpufreq.h
72279 +++ b/include/linux/cpufreq.h
72280 @@ -266,7 +266,7 @@ struct cpufreq_driver {
72281 int (*suspend) (struct cpufreq_policy *policy);
72282 int (*resume) (struct cpufreq_policy *policy);
72283 struct freq_attr **attr;
72284 -};
72285 +} __do_const;
72286
72287 /* flags */
72288
72289 @@ -325,6 +325,7 @@ struct global_attr {
72290 ssize_t (*store)(struct kobject *a, struct attribute *b,
72291 const char *c, size_t count);
72292 };
72293 +typedef struct global_attr __no_const global_attr_no_const;
72294
72295 #define define_one_global_ro(_name) \
72296 static struct global_attr _name = \
72297 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
72298 index 0bc4b74..973b368 100644
72299 --- a/include/linux/cpuidle.h
72300 +++ b/include/linux/cpuidle.h
72301 @@ -52,7 +52,8 @@ struct cpuidle_state {
72302 int index);
72303
72304 int (*enter_dead) (struct cpuidle_device *dev, int index);
72305 -};
72306 +} __do_const;
72307 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
72308
72309 /* Idle State Flags */
72310 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
72311 @@ -191,7 +192,7 @@ struct cpuidle_governor {
72312 void (*reflect) (struct cpuidle_device *dev, int index);
72313
72314 struct module *owner;
72315 -};
72316 +} __do_const;
72317
72318 #ifdef CONFIG_CPU_IDLE
72319
72320 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
72321 index d08e4d2..95fad61 100644
72322 --- a/include/linux/cpumask.h
72323 +++ b/include/linux/cpumask.h
72324 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72325 }
72326
72327 /* Valid inputs for n are -1 and 0. */
72328 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72329 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72330 {
72331 return n+1;
72332 }
72333
72334 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72335 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72336 {
72337 return n+1;
72338 }
72339
72340 -static inline unsigned int cpumask_next_and(int n,
72341 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
72342 const struct cpumask *srcp,
72343 const struct cpumask *andp)
72344 {
72345 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72346 *
72347 * Returns >= nr_cpu_ids if no further cpus set.
72348 */
72349 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72350 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72351 {
72352 /* -1 is a legal arg here. */
72353 if (n != -1)
72354 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72355 *
72356 * Returns >= nr_cpu_ids if no further cpus unset.
72357 */
72358 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72359 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72360 {
72361 /* -1 is a legal arg here. */
72362 if (n != -1)
72363 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72364 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
72365 }
72366
72367 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
72368 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
72369 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
72370
72371 /**
72372 diff --git a/include/linux/cred.h b/include/linux/cred.h
72373 index 04421e8..6bce4ef 100644
72374 --- a/include/linux/cred.h
72375 +++ b/include/linux/cred.h
72376 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
72377 static inline void validate_process_creds(void)
72378 {
72379 }
72380 +static inline void validate_task_creds(struct task_struct *task)
72381 +{
72382 +}
72383 #endif
72384
72385 /**
72386 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
72387 index b92eadf..b4ecdc1 100644
72388 --- a/include/linux/crypto.h
72389 +++ b/include/linux/crypto.h
72390 @@ -373,7 +373,7 @@ struct cipher_tfm {
72391 const u8 *key, unsigned int keylen);
72392 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72393 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72394 -};
72395 +} __no_const;
72396
72397 struct hash_tfm {
72398 int (*init)(struct hash_desc *desc);
72399 @@ -394,13 +394,13 @@ struct compress_tfm {
72400 int (*cot_decompress)(struct crypto_tfm *tfm,
72401 const u8 *src, unsigned int slen,
72402 u8 *dst, unsigned int *dlen);
72403 -};
72404 +} __no_const;
72405
72406 struct rng_tfm {
72407 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
72408 unsigned int dlen);
72409 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
72410 -};
72411 +} __no_const;
72412
72413 #define crt_ablkcipher crt_u.ablkcipher
72414 #define crt_aead crt_u.aead
72415 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
72416 index 653589e..4ef254a 100644
72417 --- a/include/linux/ctype.h
72418 +++ b/include/linux/ctype.h
72419 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
72420 * Fast implementation of tolower() for internal usage. Do not use in your
72421 * code.
72422 */
72423 -static inline char _tolower(const char c)
72424 +static inline unsigned char _tolower(const unsigned char c)
72425 {
72426 return c | 0x20;
72427 }
72428 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
72429 index 7925bf0..d5143d2 100644
72430 --- a/include/linux/decompress/mm.h
72431 +++ b/include/linux/decompress/mm.h
72432 @@ -77,7 +77,7 @@ static void free(void *where)
72433 * warnings when not needed (indeed large_malloc / large_free are not
72434 * needed by inflate */
72435
72436 -#define malloc(a) kmalloc(a, GFP_KERNEL)
72437 +#define malloc(a) kmalloc((a), GFP_KERNEL)
72438 #define free(a) kfree(a)
72439
72440 #define large_malloc(a) vmalloc(a)
72441 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
72442 index 5f1ab92..39c35ae 100644
72443 --- a/include/linux/devfreq.h
72444 +++ b/include/linux/devfreq.h
72445 @@ -114,7 +114,7 @@ struct devfreq_governor {
72446 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
72447 int (*event_handler)(struct devfreq *devfreq,
72448 unsigned int event, void *data);
72449 -};
72450 +} __do_const;
72451
72452 /**
72453 * struct devfreq - Device devfreq structure
72454 diff --git a/include/linux/device.h b/include/linux/device.h
72455 index 22b546a..a573dc9 100644
72456 --- a/include/linux/device.h
72457 +++ b/include/linux/device.h
72458 @@ -305,7 +305,7 @@ struct subsys_interface {
72459 struct list_head node;
72460 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
72461 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
72462 -};
72463 +} __do_const;
72464
72465 int subsys_interface_register(struct subsys_interface *sif);
72466 void subsys_interface_unregister(struct subsys_interface *sif);
72467 @@ -493,7 +493,7 @@ struct device_type {
72468 void (*release)(struct device *dev);
72469
72470 const struct dev_pm_ops *pm;
72471 -};
72472 +} __do_const;
72473
72474 /* interface for exporting device attributes */
72475 struct device_attribute {
72476 @@ -503,11 +503,12 @@ struct device_attribute {
72477 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
72478 const char *buf, size_t count);
72479 };
72480 +typedef struct device_attribute __no_const device_attribute_no_const;
72481
72482 struct dev_ext_attribute {
72483 struct device_attribute attr;
72484 void *var;
72485 -};
72486 +} __do_const;
72487
72488 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
72489 char *buf);
72490 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
72491 index 94af418..b1ca7a2 100644
72492 --- a/include/linux/dma-mapping.h
72493 +++ b/include/linux/dma-mapping.h
72494 @@ -54,7 +54,7 @@ struct dma_map_ops {
72495 u64 (*get_required_mask)(struct device *dev);
72496 #endif
72497 int is_phys;
72498 -};
72499 +} __do_const;
72500
72501 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
72502
72503 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
72504 index cb286b1..923d066 100644
72505 --- a/include/linux/dmaengine.h
72506 +++ b/include/linux/dmaengine.h
72507 @@ -1030,9 +1030,9 @@ struct dma_pinned_list {
72508 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
72509 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
72510
72511 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72512 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
72513 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
72514 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72515 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
72516 struct dma_pinned_list *pinned_list, struct page *page,
72517 unsigned int offset, size_t len);
72518
72519 diff --git a/include/linux/efi.h b/include/linux/efi.h
72520 index 5f8f176..62a0556 100644
72521 --- a/include/linux/efi.h
72522 +++ b/include/linux/efi.h
72523 @@ -745,6 +745,7 @@ struct efivar_operations {
72524 efi_set_variable_t *set_variable;
72525 efi_query_variable_store_t *query_variable_store;
72526 };
72527 +typedef struct efivar_operations __no_const efivar_operations_no_const;
72528
72529 struct efivars {
72530 /*
72531 diff --git a/include/linux/elf.h b/include/linux/elf.h
72532 index 40a3c0e..4c45a38 100644
72533 --- a/include/linux/elf.h
72534 +++ b/include/linux/elf.h
72535 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
72536 #define elf_note elf32_note
72537 #define elf_addr_t Elf32_Off
72538 #define Elf_Half Elf32_Half
72539 +#define elf_dyn Elf32_Dyn
72540
72541 #else
72542
72543 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
72544 #define elf_note elf64_note
72545 #define elf_addr_t Elf64_Off
72546 #define Elf_Half Elf64_Half
72547 +#define elf_dyn Elf64_Dyn
72548
72549 #endif
72550
72551 diff --git a/include/linux/err.h b/include/linux/err.h
72552 index 221fcfb..f29e5e2 100644
72553 --- a/include/linux/err.h
72554 +++ b/include/linux/err.h
72555 @@ -19,12 +19,12 @@
72556
72557 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
72558
72559 -static inline void * __must_check ERR_PTR(long error)
72560 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
72561 {
72562 return (void *) error;
72563 }
72564
72565 -static inline long __must_check PTR_ERR(__force const void *ptr)
72566 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
72567 {
72568 return (long) ptr;
72569 }
72570 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
72571 index fcb51c8..bdafcf6 100644
72572 --- a/include/linux/extcon.h
72573 +++ b/include/linux/extcon.h
72574 @@ -134,7 +134,7 @@ struct extcon_dev {
72575 /* /sys/class/extcon/.../mutually_exclusive/... */
72576 struct attribute_group attr_g_muex;
72577 struct attribute **attrs_muex;
72578 - struct device_attribute *d_attrs_muex;
72579 + device_attribute_no_const *d_attrs_muex;
72580 };
72581
72582 /**
72583 diff --git a/include/linux/fb.h b/include/linux/fb.h
72584 index ffac70a..ca3e711 100644
72585 --- a/include/linux/fb.h
72586 +++ b/include/linux/fb.h
72587 @@ -304,7 +304,7 @@ struct fb_ops {
72588 /* called at KDB enter and leave time to prepare the console */
72589 int (*fb_debug_enter)(struct fb_info *info);
72590 int (*fb_debug_leave)(struct fb_info *info);
72591 -};
72592 +} __do_const;
72593
72594 #ifdef CONFIG_FB_TILEBLITTING
72595 #define FB_TILE_CURSOR_NONE 0
72596 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
72597 index 085197b..0fa6f0b 100644
72598 --- a/include/linux/fdtable.h
72599 +++ b/include/linux/fdtable.h
72600 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
72601 void put_files_struct(struct files_struct *fs);
72602 void reset_files_struct(struct files_struct *);
72603 int unshare_files(struct files_struct **);
72604 -struct files_struct *dup_fd(struct files_struct *, int *);
72605 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
72606 void do_close_on_exec(struct files_struct *);
72607 int iterate_fd(struct files_struct *, unsigned,
72608 int (*)(const void *, struct file *, unsigned),
72609 diff --git a/include/linux/filter.h b/include/linux/filter.h
72610 index a6ac848..a104a76 100644
72611 --- a/include/linux/filter.h
72612 +++ b/include/linux/filter.h
72613 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
72614
72615 struct sk_buff;
72616 struct sock;
72617 +struct bpf_jit_work;
72618
72619 struct sk_filter
72620 {
72621 @@ -27,6 +28,9 @@ struct sk_filter
72622 unsigned int len; /* Number of filter blocks */
72623 unsigned int (*bpf_func)(const struct sk_buff *skb,
72624 const struct sock_filter *filter);
72625 +#ifdef CONFIG_BPF_JIT
72626 + struct bpf_jit_work *work;
72627 +#endif
72628 struct rcu_head rcu;
72629 struct sock_filter insns[0];
72630 };
72631 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
72632 index 8293262..2b3b8bd 100644
72633 --- a/include/linux/frontswap.h
72634 +++ b/include/linux/frontswap.h
72635 @@ -11,7 +11,7 @@ struct frontswap_ops {
72636 int (*load)(unsigned, pgoff_t, struct page *);
72637 void (*invalidate_page)(unsigned, pgoff_t);
72638 void (*invalidate_area)(unsigned);
72639 -};
72640 +} __no_const;
72641
72642 extern bool frontswap_enabled;
72643 extern struct frontswap_ops *
72644 diff --git a/include/linux/fs.h b/include/linux/fs.h
72645 index 9818747..788bfbd 100644
72646 --- a/include/linux/fs.h
72647 +++ b/include/linux/fs.h
72648 @@ -1554,7 +1554,8 @@ struct file_operations {
72649 long (*fallocate)(struct file *file, int mode, loff_t offset,
72650 loff_t len);
72651 int (*show_fdinfo)(struct seq_file *m, struct file *f);
72652 -};
72653 +} __do_const;
72654 +typedef struct file_operations __no_const file_operations_no_const;
72655
72656 struct inode_operations {
72657 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
72658 @@ -2740,4 +2741,14 @@ static inline bool dir_relax(struct inode *inode)
72659 return !IS_DEADDIR(inode);
72660 }
72661
72662 +static inline bool is_sidechannel_device(const struct inode *inode)
72663 +{
72664 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
72665 + umode_t mode = inode->i_mode;
72666 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
72667 +#else
72668 + return false;
72669 +#endif
72670 +}
72671 +
72672 #endif /* _LINUX_FS_H */
72673 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
72674 index 2b93a9a..855d94a 100644
72675 --- a/include/linux/fs_struct.h
72676 +++ b/include/linux/fs_struct.h
72677 @@ -6,7 +6,7 @@
72678 #include <linux/seqlock.h>
72679
72680 struct fs_struct {
72681 - int users;
72682 + atomic_t users;
72683 spinlock_t lock;
72684 seqcount_t seq;
72685 int umask;
72686 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
72687 index a9ff9a3..1ba1788 100644
72688 --- a/include/linux/fscache-cache.h
72689 +++ b/include/linux/fscache-cache.h
72690 @@ -113,7 +113,7 @@ struct fscache_operation {
72691 fscache_operation_release_t release;
72692 };
72693
72694 -extern atomic_t fscache_op_debug_id;
72695 +extern atomic_unchecked_t fscache_op_debug_id;
72696 extern void fscache_op_work_func(struct work_struct *work);
72697
72698 extern void fscache_enqueue_operation(struct fscache_operation *);
72699 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
72700 INIT_WORK(&op->work, fscache_op_work_func);
72701 atomic_set(&op->usage, 1);
72702 op->state = FSCACHE_OP_ST_INITIALISED;
72703 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
72704 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
72705 op->processor = processor;
72706 op->release = release;
72707 INIT_LIST_HEAD(&op->pend_link);
72708 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
72709 index 7a08623..4c07b0f 100644
72710 --- a/include/linux/fscache.h
72711 +++ b/include/linux/fscache.h
72712 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
72713 * - this is mandatory for any object that may have data
72714 */
72715 void (*now_uncached)(void *cookie_netfs_data);
72716 -};
72717 +} __do_const;
72718
72719 /*
72720 * fscache cached network filesystem type
72721 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
72722 index 1c804b0..1432c2b 100644
72723 --- a/include/linux/fsnotify.h
72724 +++ b/include/linux/fsnotify.h
72725 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
72726 struct inode *inode = file_inode(file);
72727 __u32 mask = FS_ACCESS;
72728
72729 + if (is_sidechannel_device(inode))
72730 + return;
72731 +
72732 if (S_ISDIR(inode->i_mode))
72733 mask |= FS_ISDIR;
72734
72735 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
72736 struct inode *inode = file_inode(file);
72737 __u32 mask = FS_MODIFY;
72738
72739 + if (is_sidechannel_device(inode))
72740 + return;
72741 +
72742 if (S_ISDIR(inode->i_mode))
72743 mask |= FS_ISDIR;
72744
72745 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
72746 */
72747 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
72748 {
72749 - return kstrdup(name, GFP_KERNEL);
72750 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
72751 }
72752
72753 /*
72754 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
72755 index 9f3c275..8bdff5d 100644
72756 --- a/include/linux/genhd.h
72757 +++ b/include/linux/genhd.h
72758 @@ -194,7 +194,7 @@ struct gendisk {
72759 struct kobject *slave_dir;
72760
72761 struct timer_rand_state *random;
72762 - atomic_t sync_io; /* RAID */
72763 + atomic_unchecked_t sync_io; /* RAID */
72764 struct disk_events *ev;
72765 #ifdef CONFIG_BLK_DEV_INTEGRITY
72766 struct blk_integrity *integrity;
72767 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
72768 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
72769
72770 /* drivers/char/random.c */
72771 -extern void add_disk_randomness(struct gendisk *disk);
72772 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
72773 extern void rand_initialize_disk(struct gendisk *disk);
72774
72775 static inline sector_t get_start_sect(struct block_device *bdev)
72776 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
72777 index 023bc34..b02b46a 100644
72778 --- a/include/linux/genl_magic_func.h
72779 +++ b/include/linux/genl_magic_func.h
72780 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
72781 },
72782
72783 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
72784 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
72785 +static struct genl_ops ZZZ_genl_ops[] = {
72786 #include GENL_MAGIC_INCLUDE_FILE
72787 };
72788
72789 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
72790 index 9b4dd49..61fd41d 100644
72791 --- a/include/linux/gfp.h
72792 +++ b/include/linux/gfp.h
72793 @@ -35,6 +35,13 @@ struct vm_area_struct;
72794 #define ___GFP_NO_KSWAPD 0x400000u
72795 #define ___GFP_OTHER_NODE 0x800000u
72796 #define ___GFP_WRITE 0x1000000u
72797 +
72798 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72799 +#define ___GFP_USERCOPY 0x2000000u
72800 +#else
72801 +#define ___GFP_USERCOPY 0
72802 +#endif
72803 +
72804 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
72805
72806 /*
72807 @@ -92,6 +99,7 @@ struct vm_area_struct;
72808 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
72809 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
72810 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
72811 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
72812
72813 /*
72814 * This may seem redundant, but it's a way of annotating false positives vs.
72815 @@ -99,7 +107,7 @@ struct vm_area_struct;
72816 */
72817 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
72818
72819 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
72820 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
72821 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
72822
72823 /* This equals 0, but use constants in case they ever change */
72824 @@ -153,6 +161,8 @@ struct vm_area_struct;
72825 /* 4GB DMA on some platforms */
72826 #define GFP_DMA32 __GFP_DMA32
72827
72828 +#define GFP_USERCOPY __GFP_USERCOPY
72829 +
72830 /* Convert GFP flags to their corresponding migrate type */
72831 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
72832 {
72833 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
72834 new file mode 100644
72835 index 0000000..ebe6d72
72836 --- /dev/null
72837 +++ b/include/linux/gracl.h
72838 @@ -0,0 +1,319 @@
72839 +#ifndef GR_ACL_H
72840 +#define GR_ACL_H
72841 +
72842 +#include <linux/grdefs.h>
72843 +#include <linux/resource.h>
72844 +#include <linux/capability.h>
72845 +#include <linux/dcache.h>
72846 +#include <asm/resource.h>
72847 +
72848 +/* Major status information */
72849 +
72850 +#define GR_VERSION "grsecurity 2.9.1"
72851 +#define GRSECURITY_VERSION 0x2901
72852 +
72853 +enum {
72854 + GR_SHUTDOWN = 0,
72855 + GR_ENABLE = 1,
72856 + GR_SPROLE = 2,
72857 + GR_RELOAD = 3,
72858 + GR_SEGVMOD = 4,
72859 + GR_STATUS = 5,
72860 + GR_UNSPROLE = 6,
72861 + GR_PASSSET = 7,
72862 + GR_SPROLEPAM = 8,
72863 +};
72864 +
72865 +/* Password setup definitions
72866 + * kernel/grhash.c */
72867 +enum {
72868 + GR_PW_LEN = 128,
72869 + GR_SALT_LEN = 16,
72870 + GR_SHA_LEN = 32,
72871 +};
72872 +
72873 +enum {
72874 + GR_SPROLE_LEN = 64,
72875 +};
72876 +
72877 +enum {
72878 + GR_NO_GLOB = 0,
72879 + GR_REG_GLOB,
72880 + GR_CREATE_GLOB
72881 +};
72882 +
72883 +#define GR_NLIMITS 32
72884 +
72885 +/* Begin Data Structures */
72886 +
72887 +struct sprole_pw {
72888 + unsigned char *rolename;
72889 + unsigned char salt[GR_SALT_LEN];
72890 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
72891 +};
72892 +
72893 +struct name_entry {
72894 + __u32 key;
72895 + ino_t inode;
72896 + dev_t device;
72897 + char *name;
72898 + __u16 len;
72899 + __u8 deleted;
72900 + struct name_entry *prev;
72901 + struct name_entry *next;
72902 +};
72903 +
72904 +struct inodev_entry {
72905 + struct name_entry *nentry;
72906 + struct inodev_entry *prev;
72907 + struct inodev_entry *next;
72908 +};
72909 +
72910 +struct acl_role_db {
72911 + struct acl_role_label **r_hash;
72912 + __u32 r_size;
72913 +};
72914 +
72915 +struct inodev_db {
72916 + struct inodev_entry **i_hash;
72917 + __u32 i_size;
72918 +};
72919 +
72920 +struct name_db {
72921 + struct name_entry **n_hash;
72922 + __u32 n_size;
72923 +};
72924 +
72925 +struct crash_uid {
72926 + uid_t uid;
72927 + unsigned long expires;
72928 +};
72929 +
72930 +struct gr_hash_struct {
72931 + void **table;
72932 + void **nametable;
72933 + void *first;
72934 + __u32 table_size;
72935 + __u32 used_size;
72936 + int type;
72937 +};
72938 +
72939 +/* Userspace Grsecurity ACL data structures */
72940 +
72941 +struct acl_subject_label {
72942 + char *filename;
72943 + ino_t inode;
72944 + dev_t device;
72945 + __u32 mode;
72946 + kernel_cap_t cap_mask;
72947 + kernel_cap_t cap_lower;
72948 + kernel_cap_t cap_invert_audit;
72949 +
72950 + struct rlimit res[GR_NLIMITS];
72951 + __u32 resmask;
72952 +
72953 + __u8 user_trans_type;
72954 + __u8 group_trans_type;
72955 + uid_t *user_transitions;
72956 + gid_t *group_transitions;
72957 + __u16 user_trans_num;
72958 + __u16 group_trans_num;
72959 +
72960 + __u32 sock_families[2];
72961 + __u32 ip_proto[8];
72962 + __u32 ip_type;
72963 + struct acl_ip_label **ips;
72964 + __u32 ip_num;
72965 + __u32 inaddr_any_override;
72966 +
72967 + __u32 crashes;
72968 + unsigned long expires;
72969 +
72970 + struct acl_subject_label *parent_subject;
72971 + struct gr_hash_struct *hash;
72972 + struct acl_subject_label *prev;
72973 + struct acl_subject_label *next;
72974 +
72975 + struct acl_object_label **obj_hash;
72976 + __u32 obj_hash_size;
72977 + __u16 pax_flags;
72978 +};
72979 +
72980 +struct role_allowed_ip {
72981 + __u32 addr;
72982 + __u32 netmask;
72983 +
72984 + struct role_allowed_ip *prev;
72985 + struct role_allowed_ip *next;
72986 +};
72987 +
72988 +struct role_transition {
72989 + char *rolename;
72990 +
72991 + struct role_transition *prev;
72992 + struct role_transition *next;
72993 +};
72994 +
72995 +struct acl_role_label {
72996 + char *rolename;
72997 + uid_t uidgid;
72998 + __u16 roletype;
72999 +
73000 + __u16 auth_attempts;
73001 + unsigned long expires;
73002 +
73003 + struct acl_subject_label *root_label;
73004 + struct gr_hash_struct *hash;
73005 +
73006 + struct acl_role_label *prev;
73007 + struct acl_role_label *next;
73008 +
73009 + struct role_transition *transitions;
73010 + struct role_allowed_ip *allowed_ips;
73011 + uid_t *domain_children;
73012 + __u16 domain_child_num;
73013 +
73014 + umode_t umask;
73015 +
73016 + struct acl_subject_label **subj_hash;
73017 + __u32 subj_hash_size;
73018 +};
73019 +
73020 +struct user_acl_role_db {
73021 + struct acl_role_label **r_table;
73022 + __u32 num_pointers; /* Number of allocations to track */
73023 + __u32 num_roles; /* Number of roles */
73024 + __u32 num_domain_children; /* Number of domain children */
73025 + __u32 num_subjects; /* Number of subjects */
73026 + __u32 num_objects; /* Number of objects */
73027 +};
73028 +
73029 +struct acl_object_label {
73030 + char *filename;
73031 + ino_t inode;
73032 + dev_t device;
73033 + __u32 mode;
73034 +
73035 + struct acl_subject_label *nested;
73036 + struct acl_object_label *globbed;
73037 +
73038 + /* next two structures not used */
73039 +
73040 + struct acl_object_label *prev;
73041 + struct acl_object_label *next;
73042 +};
73043 +
73044 +struct acl_ip_label {
73045 + char *iface;
73046 + __u32 addr;
73047 + __u32 netmask;
73048 + __u16 low, high;
73049 + __u8 mode;
73050 + __u32 type;
73051 + __u32 proto[8];
73052 +
73053 + /* next two structures not used */
73054 +
73055 + struct acl_ip_label *prev;
73056 + struct acl_ip_label *next;
73057 +};
73058 +
73059 +struct gr_arg {
73060 + struct user_acl_role_db role_db;
73061 + unsigned char pw[GR_PW_LEN];
73062 + unsigned char salt[GR_SALT_LEN];
73063 + unsigned char sum[GR_SHA_LEN];
73064 + unsigned char sp_role[GR_SPROLE_LEN];
73065 + struct sprole_pw *sprole_pws;
73066 + dev_t segv_device;
73067 + ino_t segv_inode;
73068 + uid_t segv_uid;
73069 + __u16 num_sprole_pws;
73070 + __u16 mode;
73071 +};
73072 +
73073 +struct gr_arg_wrapper {
73074 + struct gr_arg *arg;
73075 + __u32 version;
73076 + __u32 size;
73077 +};
73078 +
73079 +struct subject_map {
73080 + struct acl_subject_label *user;
73081 + struct acl_subject_label *kernel;
73082 + struct subject_map *prev;
73083 + struct subject_map *next;
73084 +};
73085 +
73086 +struct acl_subj_map_db {
73087 + struct subject_map **s_hash;
73088 + __u32 s_size;
73089 +};
73090 +
73091 +/* End Data Structures Section */
73092 +
73093 +/* Hash functions generated by empirical testing by Brad Spengler
73094 + Makes good use of the low bits of the inode. Generally 0-1 times
73095 + in loop for successful match. 0-3 for unsuccessful match.
73096 + Shift/add algorithm with modulus of table size and an XOR*/
73097 +
73098 +static __inline__ unsigned int
73099 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
73100 +{
73101 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
73102 +}
73103 +
73104 + static __inline__ unsigned int
73105 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
73106 +{
73107 + return ((const unsigned long)userp % sz);
73108 +}
73109 +
73110 +static __inline__ unsigned int
73111 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
73112 +{
73113 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
73114 +}
73115 +
73116 +static __inline__ unsigned int
73117 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
73118 +{
73119 + return full_name_hash((const unsigned char *)name, len) % sz;
73120 +}
73121 +
73122 +#define FOR_EACH_ROLE_START(role) \
73123 + role = role_list; \
73124 + while (role) {
73125 +
73126 +#define FOR_EACH_ROLE_END(role) \
73127 + role = role->prev; \
73128 + }
73129 +
73130 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
73131 + subj = NULL; \
73132 + iter = 0; \
73133 + while (iter < role->subj_hash_size) { \
73134 + if (subj == NULL) \
73135 + subj = role->subj_hash[iter]; \
73136 + if (subj == NULL) { \
73137 + iter++; \
73138 + continue; \
73139 + }
73140 +
73141 +#define FOR_EACH_SUBJECT_END(subj,iter) \
73142 + subj = subj->next; \
73143 + if (subj == NULL) \
73144 + iter++; \
73145 + }
73146 +
73147 +
73148 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
73149 + subj = role->hash->first; \
73150 + while (subj != NULL) {
73151 +
73152 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
73153 + subj = subj->next; \
73154 + }
73155 +
73156 +#endif
73157 +
73158 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
73159 new file mode 100644
73160 index 0000000..33ebd1f
73161 --- /dev/null
73162 +++ b/include/linux/gracl_compat.h
73163 @@ -0,0 +1,156 @@
73164 +#ifndef GR_ACL_COMPAT_H
73165 +#define GR_ACL_COMPAT_H
73166 +
73167 +#include <linux/resource.h>
73168 +#include <asm/resource.h>
73169 +
73170 +struct sprole_pw_compat {
73171 + compat_uptr_t rolename;
73172 + unsigned char salt[GR_SALT_LEN];
73173 + unsigned char sum[GR_SHA_LEN];
73174 +};
73175 +
73176 +struct gr_hash_struct_compat {
73177 + compat_uptr_t table;
73178 + compat_uptr_t nametable;
73179 + compat_uptr_t first;
73180 + __u32 table_size;
73181 + __u32 used_size;
73182 + int type;
73183 +};
73184 +
73185 +struct acl_subject_label_compat {
73186 + compat_uptr_t filename;
73187 + compat_ino_t inode;
73188 + __u32 device;
73189 + __u32 mode;
73190 + kernel_cap_t cap_mask;
73191 + kernel_cap_t cap_lower;
73192 + kernel_cap_t cap_invert_audit;
73193 +
73194 + struct compat_rlimit res[GR_NLIMITS];
73195 + __u32 resmask;
73196 +
73197 + __u8 user_trans_type;
73198 + __u8 group_trans_type;
73199 + compat_uptr_t user_transitions;
73200 + compat_uptr_t group_transitions;
73201 + __u16 user_trans_num;
73202 + __u16 group_trans_num;
73203 +
73204 + __u32 sock_families[2];
73205 + __u32 ip_proto[8];
73206 + __u32 ip_type;
73207 + compat_uptr_t ips;
73208 + __u32 ip_num;
73209 + __u32 inaddr_any_override;
73210 +
73211 + __u32 crashes;
73212 + compat_ulong_t expires;
73213 +
73214 + compat_uptr_t parent_subject;
73215 + compat_uptr_t hash;
73216 + compat_uptr_t prev;
73217 + compat_uptr_t next;
73218 +
73219 + compat_uptr_t obj_hash;
73220 + __u32 obj_hash_size;
73221 + __u16 pax_flags;
73222 +};
73223 +
73224 +struct role_allowed_ip_compat {
73225 + __u32 addr;
73226 + __u32 netmask;
73227 +
73228 + compat_uptr_t prev;
73229 + compat_uptr_t next;
73230 +};
73231 +
73232 +struct role_transition_compat {
73233 + compat_uptr_t rolename;
73234 +
73235 + compat_uptr_t prev;
73236 + compat_uptr_t next;
73237 +};
73238 +
73239 +struct acl_role_label_compat {
73240 + compat_uptr_t rolename;
73241 + uid_t uidgid;
73242 + __u16 roletype;
73243 +
73244 + __u16 auth_attempts;
73245 + compat_ulong_t expires;
73246 +
73247 + compat_uptr_t root_label;
73248 + compat_uptr_t hash;
73249 +
73250 + compat_uptr_t prev;
73251 + compat_uptr_t next;
73252 +
73253 + compat_uptr_t transitions;
73254 + compat_uptr_t allowed_ips;
73255 + compat_uptr_t domain_children;
73256 + __u16 domain_child_num;
73257 +
73258 + umode_t umask;
73259 +
73260 + compat_uptr_t subj_hash;
73261 + __u32 subj_hash_size;
73262 +};
73263 +
73264 +struct user_acl_role_db_compat {
73265 + compat_uptr_t r_table;
73266 + __u32 num_pointers;
73267 + __u32 num_roles;
73268 + __u32 num_domain_children;
73269 + __u32 num_subjects;
73270 + __u32 num_objects;
73271 +};
73272 +
73273 +struct acl_object_label_compat {
73274 + compat_uptr_t filename;
73275 + compat_ino_t inode;
73276 + __u32 device;
73277 + __u32 mode;
73278 +
73279 + compat_uptr_t nested;
73280 + compat_uptr_t globbed;
73281 +
73282 + compat_uptr_t prev;
73283 + compat_uptr_t next;
73284 +};
73285 +
73286 +struct acl_ip_label_compat {
73287 + compat_uptr_t iface;
73288 + __u32 addr;
73289 + __u32 netmask;
73290 + __u16 low, high;
73291 + __u8 mode;
73292 + __u32 type;
73293 + __u32 proto[8];
73294 +
73295 + compat_uptr_t prev;
73296 + compat_uptr_t next;
73297 +};
73298 +
73299 +struct gr_arg_compat {
73300 + struct user_acl_role_db_compat role_db;
73301 + unsigned char pw[GR_PW_LEN];
73302 + unsigned char salt[GR_SALT_LEN];
73303 + unsigned char sum[GR_SHA_LEN];
73304 + unsigned char sp_role[GR_SPROLE_LEN];
73305 + compat_uptr_t sprole_pws;
73306 + __u32 segv_device;
73307 + compat_ino_t segv_inode;
73308 + uid_t segv_uid;
73309 + __u16 num_sprole_pws;
73310 + __u16 mode;
73311 +};
73312 +
73313 +struct gr_arg_wrapper_compat {
73314 + compat_uptr_t arg;
73315 + __u32 version;
73316 + __u32 size;
73317 +};
73318 +
73319 +#endif
73320 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
73321 new file mode 100644
73322 index 0000000..323ecf2
73323 --- /dev/null
73324 +++ b/include/linux/gralloc.h
73325 @@ -0,0 +1,9 @@
73326 +#ifndef __GRALLOC_H
73327 +#define __GRALLOC_H
73328 +
73329 +void acl_free_all(void);
73330 +int acl_alloc_stack_init(unsigned long size);
73331 +void *acl_alloc(unsigned long len);
73332 +void *acl_alloc_num(unsigned long num, unsigned long len);
73333 +
73334 +#endif
73335 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
73336 new file mode 100644
73337 index 0000000..be66033
73338 --- /dev/null
73339 +++ b/include/linux/grdefs.h
73340 @@ -0,0 +1,140 @@
73341 +#ifndef GRDEFS_H
73342 +#define GRDEFS_H
73343 +
73344 +/* Begin grsecurity status declarations */
73345 +
73346 +enum {
73347 + GR_READY = 0x01,
73348 + GR_STATUS_INIT = 0x00 // disabled state
73349 +};
73350 +
73351 +/* Begin ACL declarations */
73352 +
73353 +/* Role flags */
73354 +
73355 +enum {
73356 + GR_ROLE_USER = 0x0001,
73357 + GR_ROLE_GROUP = 0x0002,
73358 + GR_ROLE_DEFAULT = 0x0004,
73359 + GR_ROLE_SPECIAL = 0x0008,
73360 + GR_ROLE_AUTH = 0x0010,
73361 + GR_ROLE_NOPW = 0x0020,
73362 + GR_ROLE_GOD = 0x0040,
73363 + GR_ROLE_LEARN = 0x0080,
73364 + GR_ROLE_TPE = 0x0100,
73365 + GR_ROLE_DOMAIN = 0x0200,
73366 + GR_ROLE_PAM = 0x0400,
73367 + GR_ROLE_PERSIST = 0x0800
73368 +};
73369 +
73370 +/* ACL Subject and Object mode flags */
73371 +enum {
73372 + GR_DELETED = 0x80000000
73373 +};
73374 +
73375 +/* ACL Object-only mode flags */
73376 +enum {
73377 + GR_READ = 0x00000001,
73378 + GR_APPEND = 0x00000002,
73379 + GR_WRITE = 0x00000004,
73380 + GR_EXEC = 0x00000008,
73381 + GR_FIND = 0x00000010,
73382 + GR_INHERIT = 0x00000020,
73383 + GR_SETID = 0x00000040,
73384 + GR_CREATE = 0x00000080,
73385 + GR_DELETE = 0x00000100,
73386 + GR_LINK = 0x00000200,
73387 + GR_AUDIT_READ = 0x00000400,
73388 + GR_AUDIT_APPEND = 0x00000800,
73389 + GR_AUDIT_WRITE = 0x00001000,
73390 + GR_AUDIT_EXEC = 0x00002000,
73391 + GR_AUDIT_FIND = 0x00004000,
73392 + GR_AUDIT_INHERIT= 0x00008000,
73393 + GR_AUDIT_SETID = 0x00010000,
73394 + GR_AUDIT_CREATE = 0x00020000,
73395 + GR_AUDIT_DELETE = 0x00040000,
73396 + GR_AUDIT_LINK = 0x00080000,
73397 + GR_PTRACERD = 0x00100000,
73398 + GR_NOPTRACE = 0x00200000,
73399 + GR_SUPPRESS = 0x00400000,
73400 + GR_NOLEARN = 0x00800000,
73401 + GR_INIT_TRANSFER= 0x01000000
73402 +};
73403 +
73404 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
73405 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
73406 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
73407 +
73408 +/* ACL subject-only mode flags */
73409 +enum {
73410 + GR_KILL = 0x00000001,
73411 + GR_VIEW = 0x00000002,
73412 + GR_PROTECTED = 0x00000004,
73413 + GR_LEARN = 0x00000008,
73414 + GR_OVERRIDE = 0x00000010,
73415 + /* just a placeholder, this mode is only used in userspace */
73416 + GR_DUMMY = 0x00000020,
73417 + GR_PROTSHM = 0x00000040,
73418 + GR_KILLPROC = 0x00000080,
73419 + GR_KILLIPPROC = 0x00000100,
73420 + /* just a placeholder, this mode is only used in userspace */
73421 + GR_NOTROJAN = 0x00000200,
73422 + GR_PROTPROCFD = 0x00000400,
73423 + GR_PROCACCT = 0x00000800,
73424 + GR_RELAXPTRACE = 0x00001000,
73425 + //GR_NESTED = 0x00002000,
73426 + GR_INHERITLEARN = 0x00004000,
73427 + GR_PROCFIND = 0x00008000,
73428 + GR_POVERRIDE = 0x00010000,
73429 + GR_KERNELAUTH = 0x00020000,
73430 + GR_ATSECURE = 0x00040000,
73431 + GR_SHMEXEC = 0x00080000
73432 +};
73433 +
73434 +enum {
73435 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
73436 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
73437 + GR_PAX_ENABLE_MPROTECT = 0x0004,
73438 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
73439 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
73440 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
73441 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
73442 + GR_PAX_DISABLE_MPROTECT = 0x0400,
73443 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
73444 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
73445 +};
73446 +
73447 +enum {
73448 + GR_ID_USER = 0x01,
73449 + GR_ID_GROUP = 0x02,
73450 +};
73451 +
73452 +enum {
73453 + GR_ID_ALLOW = 0x01,
73454 + GR_ID_DENY = 0x02,
73455 +};
73456 +
73457 +#define GR_CRASH_RES 31
73458 +#define GR_UIDTABLE_MAX 500
73459 +
73460 +/* begin resource learning section */
73461 +enum {
73462 + GR_RLIM_CPU_BUMP = 60,
73463 + GR_RLIM_FSIZE_BUMP = 50000,
73464 + GR_RLIM_DATA_BUMP = 10000,
73465 + GR_RLIM_STACK_BUMP = 1000,
73466 + GR_RLIM_CORE_BUMP = 10000,
73467 + GR_RLIM_RSS_BUMP = 500000,
73468 + GR_RLIM_NPROC_BUMP = 1,
73469 + GR_RLIM_NOFILE_BUMP = 5,
73470 + GR_RLIM_MEMLOCK_BUMP = 50000,
73471 + GR_RLIM_AS_BUMP = 500000,
73472 + GR_RLIM_LOCKS_BUMP = 2,
73473 + GR_RLIM_SIGPENDING_BUMP = 5,
73474 + GR_RLIM_MSGQUEUE_BUMP = 10000,
73475 + GR_RLIM_NICE_BUMP = 1,
73476 + GR_RLIM_RTPRIO_BUMP = 1,
73477 + GR_RLIM_RTTIME_BUMP = 1000000
73478 +};
73479 +
73480 +#endif
73481 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
73482 new file mode 100644
73483 index 0000000..e337683
73484 --- /dev/null
73485 +++ b/include/linux/grinternal.h
73486 @@ -0,0 +1,229 @@
73487 +#ifndef __GRINTERNAL_H
73488 +#define __GRINTERNAL_H
73489 +
73490 +#ifdef CONFIG_GRKERNSEC
73491 +
73492 +#include <linux/fs.h>
73493 +#include <linux/mnt_namespace.h>
73494 +#include <linux/nsproxy.h>
73495 +#include <linux/gracl.h>
73496 +#include <linux/grdefs.h>
73497 +#include <linux/grmsg.h>
73498 +
73499 +void gr_add_learn_entry(const char *fmt, ...)
73500 + __attribute__ ((format (printf, 1, 2)));
73501 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
73502 + const struct vfsmount *mnt);
73503 +__u32 gr_check_create(const struct dentry *new_dentry,
73504 + const struct dentry *parent,
73505 + const struct vfsmount *mnt, const __u32 mode);
73506 +int gr_check_protected_task(const struct task_struct *task);
73507 +__u32 to_gr_audit(const __u32 reqmode);
73508 +int gr_set_acls(const int type);
73509 +int gr_apply_subject_to_task(struct task_struct *task);
73510 +int gr_acl_is_enabled(void);
73511 +char gr_roletype_to_char(void);
73512 +
73513 +void gr_handle_alertkill(struct task_struct *task);
73514 +char *gr_to_filename(const struct dentry *dentry,
73515 + const struct vfsmount *mnt);
73516 +char *gr_to_filename1(const struct dentry *dentry,
73517 + const struct vfsmount *mnt);
73518 +char *gr_to_filename2(const struct dentry *dentry,
73519 + const struct vfsmount *mnt);
73520 +char *gr_to_filename3(const struct dentry *dentry,
73521 + const struct vfsmount *mnt);
73522 +
73523 +extern int grsec_enable_ptrace_readexec;
73524 +extern int grsec_enable_harden_ptrace;
73525 +extern int grsec_enable_link;
73526 +extern int grsec_enable_fifo;
73527 +extern int grsec_enable_execve;
73528 +extern int grsec_enable_shm;
73529 +extern int grsec_enable_execlog;
73530 +extern int grsec_enable_signal;
73531 +extern int grsec_enable_audit_ptrace;
73532 +extern int grsec_enable_forkfail;
73533 +extern int grsec_enable_time;
73534 +extern int grsec_enable_rofs;
73535 +extern int grsec_deny_new_usb;
73536 +extern int grsec_enable_chroot_shmat;
73537 +extern int grsec_enable_chroot_mount;
73538 +extern int grsec_enable_chroot_double;
73539 +extern int grsec_enable_chroot_pivot;
73540 +extern int grsec_enable_chroot_chdir;
73541 +extern int grsec_enable_chroot_chmod;
73542 +extern int grsec_enable_chroot_mknod;
73543 +extern int grsec_enable_chroot_fchdir;
73544 +extern int grsec_enable_chroot_nice;
73545 +extern int grsec_enable_chroot_execlog;
73546 +extern int grsec_enable_chroot_caps;
73547 +extern int grsec_enable_chroot_sysctl;
73548 +extern int grsec_enable_chroot_unix;
73549 +extern int grsec_enable_symlinkown;
73550 +extern kgid_t grsec_symlinkown_gid;
73551 +extern int grsec_enable_tpe;
73552 +extern kgid_t grsec_tpe_gid;
73553 +extern int grsec_enable_tpe_all;
73554 +extern int grsec_enable_tpe_invert;
73555 +extern int grsec_enable_socket_all;
73556 +extern kgid_t grsec_socket_all_gid;
73557 +extern int grsec_enable_socket_client;
73558 +extern kgid_t grsec_socket_client_gid;
73559 +extern int grsec_enable_socket_server;
73560 +extern kgid_t grsec_socket_server_gid;
73561 +extern kgid_t grsec_audit_gid;
73562 +extern int grsec_enable_group;
73563 +extern int grsec_enable_log_rwxmaps;
73564 +extern int grsec_enable_mount;
73565 +extern int grsec_enable_chdir;
73566 +extern int grsec_resource_logging;
73567 +extern int grsec_enable_blackhole;
73568 +extern int grsec_lastack_retries;
73569 +extern int grsec_enable_brute;
73570 +extern int grsec_lock;
73571 +
73572 +extern spinlock_t grsec_alert_lock;
73573 +extern unsigned long grsec_alert_wtime;
73574 +extern unsigned long grsec_alert_fyet;
73575 +
73576 +extern spinlock_t grsec_audit_lock;
73577 +
73578 +extern rwlock_t grsec_exec_file_lock;
73579 +
73580 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
73581 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
73582 + (tsk)->exec_file->f_path.mnt) : "/")
73583 +
73584 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
73585 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
73586 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
73587 +
73588 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
73589 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
73590 + (tsk)->exec_file->f_path.mnt) : "/")
73591 +
73592 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
73593 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
73594 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
73595 +
73596 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
73597 +
73598 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
73599 +
73600 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
73601 +{
73602 + if (file1 && file2) {
73603 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
73604 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
73605 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
73606 + return true;
73607 + }
73608 +
73609 + return false;
73610 +}
73611 +
73612 +#define GR_CHROOT_CAPS {{ \
73613 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
73614 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
73615 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
73616 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
73617 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
73618 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
73619 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
73620 +
73621 +#define security_learn(normal_msg,args...) \
73622 +({ \
73623 + read_lock(&grsec_exec_file_lock); \
73624 + gr_add_learn_entry(normal_msg "\n", ## args); \
73625 + read_unlock(&grsec_exec_file_lock); \
73626 +})
73627 +
73628 +enum {
73629 + GR_DO_AUDIT,
73630 + GR_DONT_AUDIT,
73631 + /* used for non-audit messages that we shouldn't kill the task on */
73632 + GR_DONT_AUDIT_GOOD
73633 +};
73634 +
73635 +enum {
73636 + GR_TTYSNIFF,
73637 + GR_RBAC,
73638 + GR_RBAC_STR,
73639 + GR_STR_RBAC,
73640 + GR_RBAC_MODE2,
73641 + GR_RBAC_MODE3,
73642 + GR_FILENAME,
73643 + GR_SYSCTL_HIDDEN,
73644 + GR_NOARGS,
73645 + GR_ONE_INT,
73646 + GR_ONE_INT_TWO_STR,
73647 + GR_ONE_STR,
73648 + GR_STR_INT,
73649 + GR_TWO_STR_INT,
73650 + GR_TWO_INT,
73651 + GR_TWO_U64,
73652 + GR_THREE_INT,
73653 + GR_FIVE_INT_TWO_STR,
73654 + GR_TWO_STR,
73655 + GR_THREE_STR,
73656 + GR_FOUR_STR,
73657 + GR_STR_FILENAME,
73658 + GR_FILENAME_STR,
73659 + GR_FILENAME_TWO_INT,
73660 + GR_FILENAME_TWO_INT_STR,
73661 + GR_TEXTREL,
73662 + GR_PTRACE,
73663 + GR_RESOURCE,
73664 + GR_CAP,
73665 + GR_SIG,
73666 + GR_SIG2,
73667 + GR_CRASH1,
73668 + GR_CRASH2,
73669 + GR_PSACCT,
73670 + GR_RWXMAP,
73671 + GR_RWXMAPVMA
73672 +};
73673 +
73674 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
73675 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
73676 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
73677 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
73678 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
73679 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
73680 +#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)
73681 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
73682 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
73683 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
73684 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
73685 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
73686 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
73687 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
73688 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
73689 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
73690 +#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)
73691 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
73692 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
73693 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
73694 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
73695 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
73696 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
73697 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
73698 +#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)
73699 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
73700 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
73701 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
73702 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
73703 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
73704 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
73705 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
73706 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
73707 +#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)
73708 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
73709 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
73710 +
73711 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
73712 +
73713 +#endif
73714 +
73715 +#endif
73716 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
73717 new file mode 100644
73718 index 0000000..a4396b5
73719 --- /dev/null
73720 +++ b/include/linux/grmsg.h
73721 @@ -0,0 +1,113 @@
73722 +#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"
73723 +#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"
73724 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
73725 +#define GR_STOPMOD_MSG "denied modification of module state by "
73726 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
73727 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
73728 +#define GR_IOPERM_MSG "denied use of ioperm() by "
73729 +#define GR_IOPL_MSG "denied use of iopl() by "
73730 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
73731 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
73732 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
73733 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
73734 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
73735 +#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"
73736 +#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"
73737 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
73738 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
73739 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
73740 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
73741 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
73742 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
73743 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
73744 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
73745 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
73746 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
73747 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
73748 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
73749 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
73750 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
73751 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
73752 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
73753 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
73754 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
73755 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
73756 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
73757 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
73758 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
73759 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
73760 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
73761 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
73762 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
73763 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
73764 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
73765 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
73766 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
73767 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
73768 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
73769 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
73770 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
73771 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
73772 +#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"
73773 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
73774 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
73775 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
73776 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
73777 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
73778 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
73779 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
73780 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
73781 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
73782 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
73783 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
73784 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
73785 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
73786 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
73787 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
73788 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
73789 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
73790 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
73791 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
73792 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
73793 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
73794 +#define GR_NICE_CHROOT_MSG "denied priority change by "
73795 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
73796 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
73797 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
73798 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
73799 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
73800 +#define GR_TIME_MSG "time set by "
73801 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
73802 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
73803 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
73804 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
73805 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
73806 +#define GR_BIND_MSG "denied bind() by "
73807 +#define GR_CONNECT_MSG "denied connect() by "
73808 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
73809 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
73810 +#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"
73811 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
73812 +#define GR_CAP_ACL_MSG "use of %s denied for "
73813 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
73814 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
73815 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
73816 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
73817 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
73818 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
73819 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
73820 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
73821 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
73822 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
73823 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
73824 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
73825 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
73826 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
73827 +#define GR_VM86_MSG "denied use of vm86 by "
73828 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
73829 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
73830 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
73831 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
73832 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
73833 +#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 "
73834 +#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 "
73835 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
73836 new file mode 100644
73837 index 0000000..d6f5a21
73838 --- /dev/null
73839 +++ b/include/linux/grsecurity.h
73840 @@ -0,0 +1,244 @@
73841 +#ifndef GR_SECURITY_H
73842 +#define GR_SECURITY_H
73843 +#include <linux/fs.h>
73844 +#include <linux/fs_struct.h>
73845 +#include <linux/binfmts.h>
73846 +#include <linux/gracl.h>
73847 +
73848 +/* notify of brain-dead configs */
73849 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
73850 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
73851 +#endif
73852 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
73853 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
73854 +#endif
73855 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
73856 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
73857 +#endif
73858 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
73859 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
73860 +#endif
73861 +
73862 +int gr_handle_new_usb(void);
73863 +
73864 +void gr_handle_brute_attach(unsigned long mm_flags);
73865 +void gr_handle_brute_check(void);
73866 +void gr_handle_kernel_exploit(void);
73867 +
73868 +char gr_roletype_to_char(void);
73869 +
73870 +int gr_acl_enable_at_secure(void);
73871 +
73872 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
73873 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
73874 +
73875 +void gr_del_task_from_ip_table(struct task_struct *p);
73876 +
73877 +int gr_pid_is_chrooted(struct task_struct *p);
73878 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
73879 +int gr_handle_chroot_nice(void);
73880 +int gr_handle_chroot_sysctl(const int op);
73881 +int gr_handle_chroot_setpriority(struct task_struct *p,
73882 + const int niceval);
73883 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
73884 +int gr_handle_chroot_chroot(const struct dentry *dentry,
73885 + const struct vfsmount *mnt);
73886 +void gr_handle_chroot_chdir(const struct path *path);
73887 +int gr_handle_chroot_chmod(const struct dentry *dentry,
73888 + const struct vfsmount *mnt, const int mode);
73889 +int gr_handle_chroot_mknod(const struct dentry *dentry,
73890 + const struct vfsmount *mnt, const int mode);
73891 +int gr_handle_chroot_mount(const struct dentry *dentry,
73892 + const struct vfsmount *mnt,
73893 + const char *dev_name);
73894 +int gr_handle_chroot_pivot(void);
73895 +int gr_handle_chroot_unix(const pid_t pid);
73896 +
73897 +int gr_handle_rawio(const struct inode *inode);
73898 +
73899 +void gr_handle_ioperm(void);
73900 +void gr_handle_iopl(void);
73901 +
73902 +umode_t gr_acl_umask(void);
73903 +
73904 +int gr_tpe_allow(const struct file *file);
73905 +
73906 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
73907 +void gr_clear_chroot_entries(struct task_struct *task);
73908 +
73909 +void gr_log_forkfail(const int retval);
73910 +void gr_log_timechange(void);
73911 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
73912 +void gr_log_chdir(const struct dentry *dentry,
73913 + const struct vfsmount *mnt);
73914 +void gr_log_chroot_exec(const struct dentry *dentry,
73915 + const struct vfsmount *mnt);
73916 +void gr_log_remount(const char *devname, const int retval);
73917 +void gr_log_unmount(const char *devname, const int retval);
73918 +void gr_log_mount(const char *from, const char *to, const int retval);
73919 +void gr_log_textrel(struct vm_area_struct *vma);
73920 +void gr_log_ptgnustack(struct file *file);
73921 +void gr_log_rwxmmap(struct file *file);
73922 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
73923 +
73924 +int gr_handle_follow_link(const struct inode *parent,
73925 + const struct inode *inode,
73926 + const struct dentry *dentry,
73927 + const struct vfsmount *mnt);
73928 +int gr_handle_fifo(const struct dentry *dentry,
73929 + const struct vfsmount *mnt,
73930 + const struct dentry *dir, const int flag,
73931 + const int acc_mode);
73932 +int gr_handle_hardlink(const struct dentry *dentry,
73933 + const struct vfsmount *mnt,
73934 + struct inode *inode,
73935 + const int mode, const struct filename *to);
73936 +
73937 +int gr_is_capable(const int cap);
73938 +int gr_is_capable_nolog(const int cap);
73939 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
73940 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
73941 +
73942 +void gr_copy_label(struct task_struct *tsk);
73943 +void gr_handle_crash(struct task_struct *task, const int sig);
73944 +int gr_handle_signal(const struct task_struct *p, const int sig);
73945 +int gr_check_crash_uid(const kuid_t uid);
73946 +int gr_check_protected_task(const struct task_struct *task);
73947 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
73948 +int gr_acl_handle_mmap(const struct file *file,
73949 + const unsigned long prot);
73950 +int gr_acl_handle_mprotect(const struct file *file,
73951 + const unsigned long prot);
73952 +int gr_check_hidden_task(const struct task_struct *tsk);
73953 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
73954 + const struct vfsmount *mnt);
73955 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
73956 + const struct vfsmount *mnt);
73957 +__u32 gr_acl_handle_access(const struct dentry *dentry,
73958 + const struct vfsmount *mnt, const int fmode);
73959 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
73960 + const struct vfsmount *mnt, umode_t *mode);
73961 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
73962 + const struct vfsmount *mnt);
73963 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
73964 + const struct vfsmount *mnt);
73965 +int gr_handle_ptrace(struct task_struct *task, const long request);
73966 +int gr_handle_proc_ptrace(struct task_struct *task);
73967 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
73968 + const struct vfsmount *mnt);
73969 +int gr_check_crash_exec(const struct file *filp);
73970 +int gr_acl_is_enabled(void);
73971 +void gr_set_kernel_label(struct task_struct *task);
73972 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
73973 + const kgid_t gid);
73974 +int gr_set_proc_label(const struct dentry *dentry,
73975 + const struct vfsmount *mnt,
73976 + const int unsafe_flags);
73977 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
73978 + const struct vfsmount *mnt);
73979 +__u32 gr_acl_handle_open(const struct dentry *dentry,
73980 + const struct vfsmount *mnt, int acc_mode);
73981 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
73982 + const struct dentry *p_dentry,
73983 + const struct vfsmount *p_mnt,
73984 + int open_flags, int acc_mode, const int imode);
73985 +void gr_handle_create(const struct dentry *dentry,
73986 + const struct vfsmount *mnt);
73987 +void gr_handle_proc_create(const struct dentry *dentry,
73988 + const struct inode *inode);
73989 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
73990 + const struct dentry *parent_dentry,
73991 + const struct vfsmount *parent_mnt,
73992 + const int mode);
73993 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
73994 + const struct dentry *parent_dentry,
73995 + const struct vfsmount *parent_mnt);
73996 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
73997 + const struct vfsmount *mnt);
73998 +void gr_handle_delete(const ino_t ino, const dev_t dev);
73999 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
74000 + const struct vfsmount *mnt);
74001 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
74002 + const struct dentry *parent_dentry,
74003 + const struct vfsmount *parent_mnt,
74004 + const struct filename *from);
74005 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
74006 + const struct dentry *parent_dentry,
74007 + const struct vfsmount *parent_mnt,
74008 + const struct dentry *old_dentry,
74009 + const struct vfsmount *old_mnt, const struct filename *to);
74010 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
74011 +int gr_acl_handle_rename(struct dentry *new_dentry,
74012 + struct dentry *parent_dentry,
74013 + const struct vfsmount *parent_mnt,
74014 + struct dentry *old_dentry,
74015 + struct inode *old_parent_inode,
74016 + struct vfsmount *old_mnt, const struct filename *newname);
74017 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
74018 + struct dentry *old_dentry,
74019 + struct dentry *new_dentry,
74020 + struct vfsmount *mnt, const __u8 replace);
74021 +__u32 gr_check_link(const struct dentry *new_dentry,
74022 + const struct dentry *parent_dentry,
74023 + const struct vfsmount *parent_mnt,
74024 + const struct dentry *old_dentry,
74025 + const struct vfsmount *old_mnt);
74026 +int gr_acl_handle_filldir(const struct file *file, const char *name,
74027 + const unsigned int namelen, const ino_t ino);
74028 +
74029 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
74030 + const struct vfsmount *mnt);
74031 +void gr_acl_handle_exit(void);
74032 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
74033 +int gr_acl_handle_procpidmem(const struct task_struct *task);
74034 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
74035 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
74036 +void gr_audit_ptrace(struct task_struct *task);
74037 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
74038 +void gr_put_exec_file(struct task_struct *task);
74039 +
74040 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
74041 +
74042 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
74043 +extern void gr_learn_resource(const struct task_struct *task, const int res,
74044 + const unsigned long wanted, const int gt);
74045 +#else
74046 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
74047 + const unsigned long wanted, const int gt)
74048 +{
74049 +}
74050 +#endif
74051 +
74052 +#ifdef CONFIG_GRKERNSEC_RESLOG
74053 +extern void gr_log_resource(const struct task_struct *task, const int res,
74054 + const unsigned long wanted, const int gt);
74055 +#else
74056 +static inline void gr_log_resource(const struct task_struct *task, const int res,
74057 + const unsigned long wanted, const int gt)
74058 +{
74059 +}
74060 +#endif
74061 +
74062 +#ifdef CONFIG_GRKERNSEC
74063 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
74064 +void gr_handle_vm86(void);
74065 +void gr_handle_mem_readwrite(u64 from, u64 to);
74066 +
74067 +void gr_log_badprocpid(const char *entry);
74068 +
74069 +extern int grsec_enable_dmesg;
74070 +extern int grsec_disable_privio;
74071 +
74072 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74073 +extern kgid_t grsec_proc_gid;
74074 +#endif
74075 +
74076 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
74077 +extern int grsec_enable_chroot_findtask;
74078 +#endif
74079 +#ifdef CONFIG_GRKERNSEC_SETXID
74080 +extern int grsec_enable_setxid;
74081 +#endif
74082 +#endif
74083 +
74084 +#endif
74085 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
74086 new file mode 100644
74087 index 0000000..e7ffaaf
74088 --- /dev/null
74089 +++ b/include/linux/grsock.h
74090 @@ -0,0 +1,19 @@
74091 +#ifndef __GRSOCK_H
74092 +#define __GRSOCK_H
74093 +
74094 +extern void gr_attach_curr_ip(const struct sock *sk);
74095 +extern int gr_handle_sock_all(const int family, const int type,
74096 + const int protocol);
74097 +extern int gr_handle_sock_server(const struct sockaddr *sck);
74098 +extern int gr_handle_sock_server_other(const struct sock *sck);
74099 +extern int gr_handle_sock_client(const struct sockaddr *sck);
74100 +extern int gr_search_connect(struct socket * sock,
74101 + struct sockaddr_in * addr);
74102 +extern int gr_search_bind(struct socket * sock,
74103 + struct sockaddr_in * addr);
74104 +extern int gr_search_listen(struct socket * sock);
74105 +extern int gr_search_accept(struct socket * sock);
74106 +extern int gr_search_socket(const int domain, const int type,
74107 + const int protocol);
74108 +
74109 +#endif
74110 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
74111 index 7fb31da..08b5114 100644
74112 --- a/include/linux/highmem.h
74113 +++ b/include/linux/highmem.h
74114 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
74115 kunmap_atomic(kaddr);
74116 }
74117
74118 +static inline void sanitize_highpage(struct page *page)
74119 +{
74120 + void *kaddr;
74121 + unsigned long flags;
74122 +
74123 + local_irq_save(flags);
74124 + kaddr = kmap_atomic(page);
74125 + clear_page(kaddr);
74126 + kunmap_atomic(kaddr);
74127 + local_irq_restore(flags);
74128 +}
74129 +
74130 static inline void zero_user_segments(struct page *page,
74131 unsigned start1, unsigned end1,
74132 unsigned start2, unsigned end2)
74133 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
74134 index 1c7b89a..7f52502 100644
74135 --- a/include/linux/hwmon-sysfs.h
74136 +++ b/include/linux/hwmon-sysfs.h
74137 @@ -25,7 +25,8 @@
74138 struct sensor_device_attribute{
74139 struct device_attribute dev_attr;
74140 int index;
74141 -};
74142 +} __do_const;
74143 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
74144 #define to_sensor_dev_attr(_dev_attr) \
74145 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
74146
74147 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
74148 struct device_attribute dev_attr;
74149 u8 index;
74150 u8 nr;
74151 -};
74152 +} __do_const;
74153 #define to_sensor_dev_attr_2(_dev_attr) \
74154 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
74155
74156 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
74157 index e988fa9..ff9f17e 100644
74158 --- a/include/linux/i2c.h
74159 +++ b/include/linux/i2c.h
74160 @@ -366,6 +366,7 @@ struct i2c_algorithm {
74161 /* To determine what the adapter supports */
74162 u32 (*functionality) (struct i2c_adapter *);
74163 };
74164 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
74165
74166 /**
74167 * struct i2c_bus_recovery_info - I2C bus recovery information
74168 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
74169 index d23c3c2..eb63c81 100644
74170 --- a/include/linux/i2o.h
74171 +++ b/include/linux/i2o.h
74172 @@ -565,7 +565,7 @@ struct i2o_controller {
74173 struct i2o_device *exec; /* Executive */
74174 #if BITS_PER_LONG == 64
74175 spinlock_t context_list_lock; /* lock for context_list */
74176 - atomic_t context_list_counter; /* needed for unique contexts */
74177 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
74178 struct list_head context_list; /* list of context id's
74179 and pointers */
74180 #endif
74181 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
74182 index aff7ad8..3942bbd 100644
74183 --- a/include/linux/if_pppox.h
74184 +++ b/include/linux/if_pppox.h
74185 @@ -76,7 +76,7 @@ struct pppox_proto {
74186 int (*ioctl)(struct socket *sock, unsigned int cmd,
74187 unsigned long arg);
74188 struct module *owner;
74189 -};
74190 +} __do_const;
74191
74192 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
74193 extern void unregister_pppox_proto(int proto_num);
74194 diff --git a/include/linux/init.h b/include/linux/init.h
74195 index e73f2b7..cc996e0 100644
74196 --- a/include/linux/init.h
74197 +++ b/include/linux/init.h
74198 @@ -39,9 +39,17 @@
74199 * Also note, that this data cannot be "const".
74200 */
74201
74202 +#define add_init_latent_entropy __latent_entropy
74203 +
74204 +#ifdef CONFIG_MEMORY_HOTPLUG
74205 +#define add_meminit_latent_entropy
74206 +#else
74207 +#define add_meminit_latent_entropy __latent_entropy
74208 +#endif
74209 +
74210 /* These are for everybody (although not all archs will actually
74211 discard it in modules) */
74212 -#define __init __section(.init.text) __cold notrace
74213 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
74214 #define __initdata __section(.init.data)
74215 #define __initconst __constsection(.init.rodata)
74216 #define __exitdata __section(.exit.data)
74217 @@ -102,7 +110,7 @@
74218 #define __cpuexitconst
74219
74220 /* Used for MEMORY_HOTPLUG */
74221 -#define __meminit __section(.meminit.text) __cold notrace
74222 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
74223 #define __meminitdata __section(.meminit.data)
74224 #define __meminitconst __constsection(.meminit.rodata)
74225 #define __memexit __section(.memexit.text) __exitused __cold notrace
74226 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
74227 index 5cd0f09..c9f67cc 100644
74228 --- a/include/linux/init_task.h
74229 +++ b/include/linux/init_task.h
74230 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
74231
74232 #define INIT_TASK_COMM "swapper"
74233
74234 +#ifdef CONFIG_X86
74235 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
74236 +#else
74237 +#define INIT_TASK_THREAD_INFO
74238 +#endif
74239 +
74240 /*
74241 * INIT_TASK is used to set up the first task table, touch at
74242 * your own risk!. Base=0, limit=0x1fffff (=2MB)
74243 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
74244 RCU_POINTER_INITIALIZER(cred, &init_cred), \
74245 .comm = INIT_TASK_COMM, \
74246 .thread = INIT_THREAD, \
74247 + INIT_TASK_THREAD_INFO \
74248 .fs = &init_fs, \
74249 .files = &init_files, \
74250 .signal = &init_signals, \
74251 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
74252 index 5fa5afe..ac55b25 100644
74253 --- a/include/linux/interrupt.h
74254 +++ b/include/linux/interrupt.h
74255 @@ -430,7 +430,7 @@ enum
74256 /* map softirq index to softirq name. update 'softirq_to_name' in
74257 * kernel/softirq.c when adding a new softirq.
74258 */
74259 -extern char *softirq_to_name[NR_SOFTIRQS];
74260 +extern const char * const softirq_to_name[NR_SOFTIRQS];
74261
74262 /* softirq mask and active fields moved to irq_cpustat_t in
74263 * asm/hardirq.h to get better cache usage. KAO
74264 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
74265
74266 struct softirq_action
74267 {
74268 - void (*action)(struct softirq_action *);
74269 -};
74270 + void (*action)(void);
74271 +} __no_const;
74272
74273 asmlinkage void do_softirq(void);
74274 asmlinkage void __do_softirq(void);
74275 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
74276 +extern void open_softirq(int nr, void (*action)(void));
74277 extern void softirq_init(void);
74278 extern void __raise_softirq_irqoff(unsigned int nr);
74279
74280 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
74281 index 3aeb730..2177f39 100644
74282 --- a/include/linux/iommu.h
74283 +++ b/include/linux/iommu.h
74284 @@ -113,7 +113,7 @@ struct iommu_ops {
74285 u32 (*domain_get_windows)(struct iommu_domain *domain);
74286
74287 unsigned long pgsize_bitmap;
74288 -};
74289 +} __do_const;
74290
74291 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
74292 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
74293 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
74294 index 89b7c24..382af74 100644
74295 --- a/include/linux/ioport.h
74296 +++ b/include/linux/ioport.h
74297 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
74298 int adjust_resource(struct resource *res, resource_size_t start,
74299 resource_size_t size);
74300 resource_size_t resource_alignment(struct resource *res);
74301 -static inline resource_size_t resource_size(const struct resource *res)
74302 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
74303 {
74304 return res->end - res->start + 1;
74305 }
74306 diff --git a/include/linux/irq.h b/include/linux/irq.h
74307 index f04d3ba..bcf2cfb 100644
74308 --- a/include/linux/irq.h
74309 +++ b/include/linux/irq.h
74310 @@ -333,7 +333,8 @@ struct irq_chip {
74311 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
74312
74313 unsigned long flags;
74314 -};
74315 +} __do_const;
74316 +typedef struct irq_chip __no_const irq_chip_no_const;
74317
74318 /*
74319 * irq_chip specific flags
74320 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
74321 index 3e203eb..3fe68d0 100644
74322 --- a/include/linux/irqchip/arm-gic.h
74323 +++ b/include/linux/irqchip/arm-gic.h
74324 @@ -59,9 +59,11 @@
74325
74326 #ifndef __ASSEMBLY__
74327
74328 +#include <linux/irq.h>
74329 +
74330 struct device_node;
74331
74332 -extern struct irq_chip gic_arch_extn;
74333 +extern irq_chip_no_const gic_arch_extn;
74334
74335 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
74336 u32 offset, struct device_node *);
74337 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
74338 index 6883e19..e854fcb 100644
74339 --- a/include/linux/kallsyms.h
74340 +++ b/include/linux/kallsyms.h
74341 @@ -15,7 +15,8 @@
74342
74343 struct module;
74344
74345 -#ifdef CONFIG_KALLSYMS
74346 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
74347 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
74348 /* Lookup the address for a symbol. Returns 0 if not found. */
74349 unsigned long kallsyms_lookup_name(const char *name);
74350
74351 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
74352 /* Stupid that this does nothing, but I didn't create this mess. */
74353 #define __print_symbol(fmt, addr)
74354 #endif /*CONFIG_KALLSYMS*/
74355 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
74356 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
74357 +extern unsigned long kallsyms_lookup_name(const char *name);
74358 +extern void __print_symbol(const char *fmt, unsigned long address);
74359 +extern int sprint_backtrace(char *buffer, unsigned long address);
74360 +extern int sprint_symbol(char *buffer, unsigned long address);
74361 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
74362 +const char *kallsyms_lookup(unsigned long addr,
74363 + unsigned long *symbolsize,
74364 + unsigned long *offset,
74365 + char **modname, char *namebuf);
74366 +extern int kallsyms_lookup_size_offset(unsigned long addr,
74367 + unsigned long *symbolsize,
74368 + unsigned long *offset);
74369 +#endif
74370
74371 /* This macro allows us to keep printk typechecking */
74372 static __printf(1, 2)
74373 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
74374 index 518a53a..5e28358 100644
74375 --- a/include/linux/key-type.h
74376 +++ b/include/linux/key-type.h
74377 @@ -125,7 +125,7 @@ struct key_type {
74378 /* internal fields */
74379 struct list_head link; /* link in types list */
74380 struct lock_class_key lock_class; /* key->sem lock class */
74381 -};
74382 +} __do_const;
74383
74384 extern struct key_type key_type_keyring;
74385
74386 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
74387 index c6e091b..a940adf 100644
74388 --- a/include/linux/kgdb.h
74389 +++ b/include/linux/kgdb.h
74390 @@ -52,7 +52,7 @@ extern int kgdb_connected;
74391 extern int kgdb_io_module_registered;
74392
74393 extern atomic_t kgdb_setting_breakpoint;
74394 -extern atomic_t kgdb_cpu_doing_single_step;
74395 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
74396
74397 extern struct task_struct *kgdb_usethread;
74398 extern struct task_struct *kgdb_contthread;
74399 @@ -254,7 +254,7 @@ struct kgdb_arch {
74400 void (*correct_hw_break)(void);
74401
74402 void (*enable_nmi)(bool on);
74403 -};
74404 +} __do_const;
74405
74406 /**
74407 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
74408 @@ -279,7 +279,7 @@ struct kgdb_io {
74409 void (*pre_exception) (void);
74410 void (*post_exception) (void);
74411 int is_console;
74412 -};
74413 +} __do_const;
74414
74415 extern struct kgdb_arch arch_kgdb_ops;
74416
74417 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
74418 index 0555cc6..b16a7a4 100644
74419 --- a/include/linux/kmod.h
74420 +++ b/include/linux/kmod.h
74421 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
74422 * usually useless though. */
74423 extern __printf(2, 3)
74424 int __request_module(bool wait, const char *name, ...);
74425 +extern __printf(3, 4)
74426 +int ___request_module(bool wait, char *param_name, const char *name, ...);
74427 #define request_module(mod...) __request_module(true, mod)
74428 #define request_module_nowait(mod...) __request_module(false, mod)
74429 #define try_then_request_module(x, mod...) \
74430 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
74431 index 939b112..ed6ed51 100644
74432 --- a/include/linux/kobject.h
74433 +++ b/include/linux/kobject.h
74434 @@ -111,7 +111,7 @@ struct kobj_type {
74435 struct attribute **default_attrs;
74436 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
74437 const void *(*namespace)(struct kobject *kobj);
74438 -};
74439 +} __do_const;
74440
74441 struct kobj_uevent_env {
74442 char *envp[UEVENT_NUM_ENVP];
74443 @@ -134,6 +134,7 @@ struct kobj_attribute {
74444 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
74445 const char *buf, size_t count);
74446 };
74447 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
74448
74449 extern const struct sysfs_ops kobj_sysfs_ops;
74450
74451 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
74452 index f66b065..c2c29b4 100644
74453 --- a/include/linux/kobject_ns.h
74454 +++ b/include/linux/kobject_ns.h
74455 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
74456 const void *(*netlink_ns)(struct sock *sk);
74457 const void *(*initial_ns)(void);
74458 void (*drop_ns)(void *);
74459 -};
74460 +} __do_const;
74461
74462 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
74463 int kobj_ns_type_registered(enum kobj_ns_type type);
74464 diff --git a/include/linux/kref.h b/include/linux/kref.h
74465 index 484604d..0f6c5b6 100644
74466 --- a/include/linux/kref.h
74467 +++ b/include/linux/kref.h
74468 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
74469 static inline int kref_sub(struct kref *kref, unsigned int count,
74470 void (*release)(struct kref *kref))
74471 {
74472 - WARN_ON(release == NULL);
74473 + BUG_ON(release == NULL);
74474
74475 if (atomic_sub_and_test((int) count, &kref->refcount)) {
74476 release(kref);
74477 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
74478 index a63d83e..77fd685 100644
74479 --- a/include/linux/kvm_host.h
74480 +++ b/include/linux/kvm_host.h
74481 @@ -446,7 +446,7 @@ static inline void kvm_irqfd_exit(void)
74482 {
74483 }
74484 #endif
74485 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74486 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
74487 struct module *module);
74488 void kvm_exit(void);
74489
74490 @@ -618,7 +618,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
74491 struct kvm_guest_debug *dbg);
74492 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
74493
74494 -int kvm_arch_init(void *opaque);
74495 +int kvm_arch_init(const void *opaque);
74496 void kvm_arch_exit(void);
74497
74498 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
74499 diff --git a/include/linux/libata.h b/include/linux/libata.h
74500 index 4ea55bb..dcd2601 100644
74501 --- a/include/linux/libata.h
74502 +++ b/include/linux/libata.h
74503 @@ -924,7 +924,7 @@ struct ata_port_operations {
74504 * fields must be pointers.
74505 */
74506 const struct ata_port_operations *inherits;
74507 -};
74508 +} __do_const;
74509
74510 struct ata_port_info {
74511 unsigned long flags;
74512 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
74513 index d3e8ad2..a949f68 100644
74514 --- a/include/linux/linkage.h
74515 +++ b/include/linux/linkage.h
74516 @@ -31,6 +31,7 @@
74517 #endif
74518
74519 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
74520 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
74521 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
74522
74523 /*
74524 diff --git a/include/linux/list.h b/include/linux/list.h
74525 index f4d8a2f..38e6e46 100644
74526 --- a/include/linux/list.h
74527 +++ b/include/linux/list.h
74528 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
74529 extern void list_del(struct list_head *entry);
74530 #endif
74531
74532 +extern void __pax_list_add(struct list_head *new,
74533 + struct list_head *prev,
74534 + struct list_head *next);
74535 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
74536 +{
74537 + __pax_list_add(new, head, head->next);
74538 +}
74539 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
74540 +{
74541 + __pax_list_add(new, head->prev, head);
74542 +}
74543 +extern void pax_list_del(struct list_head *entry);
74544 +
74545 /**
74546 * list_replace - replace old entry by new one
74547 * @old : the element to be replaced
74548 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
74549 INIT_LIST_HEAD(entry);
74550 }
74551
74552 +extern void pax_list_del_init(struct list_head *entry);
74553 +
74554 /**
74555 * list_move - delete from one list and add as another's head
74556 * @list: the entry to move
74557 diff --git a/include/linux/math64.h b/include/linux/math64.h
74558 index 2913b86..8dcbb1e 100644
74559 --- a/include/linux/math64.h
74560 +++ b/include/linux/math64.h
74561 @@ -15,7 +15,7 @@
74562 * This is commonly provided by 32bit archs to provide an optimized 64bit
74563 * divide.
74564 */
74565 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74566 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74567 {
74568 *remainder = dividend % divisor;
74569 return dividend / divisor;
74570 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
74571 /**
74572 * div64_u64 - unsigned 64bit divide with 64bit divisor
74573 */
74574 -static inline u64 div64_u64(u64 dividend, u64 divisor)
74575 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
74576 {
74577 return dividend / divisor;
74578 }
74579 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
74580 #define div64_ul(x, y) div_u64((x), (y))
74581
74582 #ifndef div_u64_rem
74583 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74584 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
74585 {
74586 *remainder = do_div(dividend, divisor);
74587 return dividend;
74588 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
74589 * divide.
74590 */
74591 #ifndef div_u64
74592 -static inline u64 div_u64(u64 dividend, u32 divisor)
74593 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
74594 {
74595 u32 remainder;
74596 return div_u64_rem(dividend, divisor, &remainder);
74597 diff --git a/include/linux/mm.h b/include/linux/mm.h
74598 index f022460..6ecf4f9 100644
74599 --- a/include/linux/mm.h
74600 +++ b/include/linux/mm.h
74601 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
74602 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
74603 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
74604 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
74605 +
74606 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
74607 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
74608 +#endif
74609 +
74610 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
74611
74612 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
74613 @@ -208,8 +213,8 @@ struct vm_operations_struct {
74614 /* called by access_process_vm when get_user_pages() fails, typically
74615 * for use by special VMAs that can switch between memory and hardware
74616 */
74617 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
74618 - void *buf, int len, int write);
74619 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
74620 + void *buf, size_t len, int write);
74621 #ifdef CONFIG_NUMA
74622 /*
74623 * set_policy() op must add a reference to any non-NULL @new mempolicy
74624 @@ -239,6 +244,7 @@ struct vm_operations_struct {
74625 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
74626 unsigned long size, pgoff_t pgoff);
74627 };
74628 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
74629
74630 struct mmu_gather;
74631 struct inode;
74632 @@ -983,8 +989,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
74633 unsigned long *pfn);
74634 int follow_phys(struct vm_area_struct *vma, unsigned long address,
74635 unsigned int flags, unsigned long *prot, resource_size_t *phys);
74636 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
74637 - void *buf, int len, int write);
74638 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
74639 + void *buf, size_t len, int write);
74640
74641 static inline void unmap_shared_mapping_range(struct address_space *mapping,
74642 loff_t const holebegin, loff_t const holelen)
74643 @@ -1023,9 +1029,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
74644 }
74645 #endif
74646
74647 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
74648 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
74649 - void *buf, int len, int write);
74650 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
74651 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
74652 + void *buf, size_t len, int write);
74653
74654 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
74655 unsigned long start, unsigned long nr_pages,
74656 @@ -1057,34 +1063,6 @@ int set_page_dirty(struct page *page);
74657 int set_page_dirty_lock(struct page *page);
74658 int clear_page_dirty_for_io(struct page *page);
74659
74660 -/* Is the vma a continuation of the stack vma above it? */
74661 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
74662 -{
74663 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
74664 -}
74665 -
74666 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
74667 - unsigned long addr)
74668 -{
74669 - return (vma->vm_flags & VM_GROWSDOWN) &&
74670 - (vma->vm_start == addr) &&
74671 - !vma_growsdown(vma->vm_prev, addr);
74672 -}
74673 -
74674 -/* Is the vma a continuation of the stack vma below it? */
74675 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
74676 -{
74677 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
74678 -}
74679 -
74680 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
74681 - unsigned long addr)
74682 -{
74683 - return (vma->vm_flags & VM_GROWSUP) &&
74684 - (vma->vm_end == addr) &&
74685 - !vma_growsup(vma->vm_next, addr);
74686 -}
74687 -
74688 extern pid_t
74689 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
74690
74691 @@ -1184,6 +1162,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
74692 }
74693 #endif
74694
74695 +#ifdef CONFIG_MMU
74696 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
74697 +#else
74698 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
74699 +{
74700 + return __pgprot(0);
74701 +}
74702 +#endif
74703 +
74704 int vma_wants_writenotify(struct vm_area_struct *vma);
74705
74706 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
74707 @@ -1202,8 +1189,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
74708 {
74709 return 0;
74710 }
74711 +
74712 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
74713 + unsigned long address)
74714 +{
74715 + return 0;
74716 +}
74717 #else
74718 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
74719 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
74720 #endif
74721
74722 #ifdef __PAGETABLE_PMD_FOLDED
74723 @@ -1212,8 +1206,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
74724 {
74725 return 0;
74726 }
74727 +
74728 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
74729 + unsigned long address)
74730 +{
74731 + return 0;
74732 +}
74733 #else
74734 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
74735 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
74736 #endif
74737
74738 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
74739 @@ -1231,11 +1232,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
74740 NULL: pud_offset(pgd, address);
74741 }
74742
74743 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
74744 +{
74745 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
74746 + NULL: pud_offset(pgd, address);
74747 +}
74748 +
74749 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
74750 {
74751 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
74752 NULL: pmd_offset(pud, address);
74753 }
74754 +
74755 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
74756 +{
74757 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
74758 + NULL: pmd_offset(pud, address);
74759 +}
74760 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
74761
74762 #if USE_SPLIT_PTLOCKS
74763 @@ -1531,6 +1544,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
74764 unsigned long len, unsigned long prot, unsigned long flags,
74765 unsigned long pgoff, unsigned long *populate);
74766 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
74767 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
74768
74769 #ifdef CONFIG_MMU
74770 extern int __mm_populate(unsigned long addr, unsigned long len,
74771 @@ -1559,10 +1573,11 @@ struct vm_unmapped_area_info {
74772 unsigned long high_limit;
74773 unsigned long align_mask;
74774 unsigned long align_offset;
74775 + unsigned long threadstack_offset;
74776 };
74777
74778 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
74779 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
74780 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
74781 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
74782
74783 /*
74784 * Search for an unmapped address range.
74785 @@ -1574,7 +1589,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
74786 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
74787 */
74788 static inline unsigned long
74789 -vm_unmapped_area(struct vm_unmapped_area_info *info)
74790 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
74791 {
74792 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
74793 return unmapped_area(info);
74794 @@ -1637,6 +1652,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
74795 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
74796 struct vm_area_struct **pprev);
74797
74798 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
74799 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
74800 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
74801 +
74802 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
74803 NULL if none. Assume start_addr < end_addr. */
74804 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
74805 @@ -1665,15 +1684,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
74806 return vma;
74807 }
74808
74809 -#ifdef CONFIG_MMU
74810 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
74811 -#else
74812 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
74813 -{
74814 - return __pgprot(0);
74815 -}
74816 -#endif
74817 -
74818 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
74819 unsigned long change_prot_numa(struct vm_area_struct *vma,
74820 unsigned long start, unsigned long end);
74821 @@ -1725,6 +1735,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
74822 static inline void vm_stat_account(struct mm_struct *mm,
74823 unsigned long flags, struct file *file, long pages)
74824 {
74825 +
74826 +#ifdef CONFIG_PAX_RANDMMAP
74827 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
74828 +#endif
74829 +
74830 mm->total_vm += pages;
74831 }
74832 #endif /* CONFIG_PROC_FS */
74833 @@ -1805,7 +1820,7 @@ extern int unpoison_memory(unsigned long pfn);
74834 extern int sysctl_memory_failure_early_kill;
74835 extern int sysctl_memory_failure_recovery;
74836 extern void shake_page(struct page *p, int access);
74837 -extern atomic_long_t num_poisoned_pages;
74838 +extern atomic_long_unchecked_t num_poisoned_pages;
74839 extern int soft_offline_page(struct page *page, int flags);
74840
74841 extern void dump_page(struct page *page);
74842 @@ -1842,5 +1857,11 @@ void __init setup_nr_node_ids(void);
74843 static inline void setup_nr_node_ids(void) {}
74844 #endif
74845
74846 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
74847 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
74848 +#else
74849 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
74850 +#endif
74851 +
74852 #endif /* __KERNEL__ */
74853 #endif /* _LINUX_MM_H */
74854 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
74855 index faf4b7c..1e70c6e 100644
74856 --- a/include/linux/mm_types.h
74857 +++ b/include/linux/mm_types.h
74858 @@ -289,6 +289,8 @@ struct vm_area_struct {
74859 #ifdef CONFIG_NUMA
74860 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
74861 #endif
74862 +
74863 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
74864 };
74865
74866 struct core_thread {
74867 @@ -435,6 +437,24 @@ struct mm_struct {
74868 int first_nid;
74869 #endif
74870 struct uprobes_state uprobes_state;
74871 +
74872 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74873 + unsigned long pax_flags;
74874 +#endif
74875 +
74876 +#ifdef CONFIG_PAX_DLRESOLVE
74877 + unsigned long call_dl_resolve;
74878 +#endif
74879 +
74880 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
74881 + unsigned long call_syscall;
74882 +#endif
74883 +
74884 +#ifdef CONFIG_PAX_ASLR
74885 + unsigned long delta_mmap; /* randomized offset */
74886 + unsigned long delta_stack; /* randomized offset */
74887 +#endif
74888 +
74889 };
74890
74891 /* first nid will either be a valid NID or one of these values */
74892 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
74893 index c5d5278..f0b68c8 100644
74894 --- a/include/linux/mmiotrace.h
74895 +++ b/include/linux/mmiotrace.h
74896 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
74897 /* Called from ioremap.c */
74898 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
74899 void __iomem *addr);
74900 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
74901 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
74902
74903 /* For anyone to insert markers. Remember trailing newline. */
74904 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
74905 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
74906 {
74907 }
74908
74909 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
74910 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
74911 {
74912 }
74913
74914 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
74915 index af4a3b7..9ad8889 100644
74916 --- a/include/linux/mmzone.h
74917 +++ b/include/linux/mmzone.h
74918 @@ -396,7 +396,7 @@ struct zone {
74919 unsigned long flags; /* zone flags, see below */
74920
74921 /* Zone statistics */
74922 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
74923 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
74924
74925 /*
74926 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
74927 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
74928 index 45e9214..a7227d6 100644
74929 --- a/include/linux/mod_devicetable.h
74930 +++ b/include/linux/mod_devicetable.h
74931 @@ -13,7 +13,7 @@
74932 typedef unsigned long kernel_ulong_t;
74933 #endif
74934
74935 -#define PCI_ANY_ID (~0)
74936 +#define PCI_ANY_ID ((__u16)~0)
74937
74938 struct pci_device_id {
74939 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
74940 @@ -139,7 +139,7 @@ struct usb_device_id {
74941 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
74942 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
74943
74944 -#define HID_ANY_ID (~0)
74945 +#define HID_ANY_ID (~0U)
74946 #define HID_BUS_ANY 0xffff
74947 #define HID_GROUP_ANY 0x0000
74948
74949 @@ -467,7 +467,7 @@ struct dmi_system_id {
74950 const char *ident;
74951 struct dmi_strmatch matches[4];
74952 void *driver_data;
74953 -};
74954 +} __do_const;
74955 /*
74956 * struct dmi_device_id appears during expansion of
74957 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
74958 diff --git a/include/linux/module.h b/include/linux/module.h
74959 index 46f1ea0..a34ca37 100644
74960 --- a/include/linux/module.h
74961 +++ b/include/linux/module.h
74962 @@ -17,9 +17,11 @@
74963 #include <linux/moduleparam.h>
74964 #include <linux/tracepoint.h>
74965 #include <linux/export.h>
74966 +#include <linux/fs.h>
74967
74968 #include <linux/percpu.h>
74969 #include <asm/module.h>
74970 +#include <asm/pgtable.h>
74971
74972 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
74973 #define MODULE_SIG_STRING "~Module signature appended~\n"
74974 @@ -54,12 +56,13 @@ struct module_attribute {
74975 int (*test)(struct module *);
74976 void (*free)(struct module *);
74977 };
74978 +typedef struct module_attribute __no_const module_attribute_no_const;
74979
74980 struct module_version_attribute {
74981 struct module_attribute mattr;
74982 const char *module_name;
74983 const char *version;
74984 -} __attribute__ ((__aligned__(sizeof(void *))));
74985 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
74986
74987 extern ssize_t __modver_version_show(struct module_attribute *,
74988 struct module_kobject *, char *);
74989 @@ -232,7 +235,7 @@ struct module
74990
74991 /* Sysfs stuff. */
74992 struct module_kobject mkobj;
74993 - struct module_attribute *modinfo_attrs;
74994 + module_attribute_no_const *modinfo_attrs;
74995 const char *version;
74996 const char *srcversion;
74997 struct kobject *holders_dir;
74998 @@ -281,19 +284,16 @@ struct module
74999 int (*init)(void);
75000
75001 /* If this is non-NULL, vfree after init() returns */
75002 - void *module_init;
75003 + void *module_init_rx, *module_init_rw;
75004
75005 /* Here is the actual code + data, vfree'd on unload. */
75006 - void *module_core;
75007 + void *module_core_rx, *module_core_rw;
75008
75009 /* Here are the sizes of the init and core sections */
75010 - unsigned int init_size, core_size;
75011 + unsigned int init_size_rw, core_size_rw;
75012
75013 /* The size of the executable code in each section. */
75014 - unsigned int init_text_size, core_text_size;
75015 -
75016 - /* Size of RO sections of the module (text+rodata) */
75017 - unsigned int init_ro_size, core_ro_size;
75018 + unsigned int init_size_rx, core_size_rx;
75019
75020 /* Arch-specific module values */
75021 struct mod_arch_specific arch;
75022 @@ -349,6 +349,10 @@ struct module
75023 #ifdef CONFIG_EVENT_TRACING
75024 struct ftrace_event_call **trace_events;
75025 unsigned int num_trace_events;
75026 + struct file_operations trace_id;
75027 + struct file_operations trace_enable;
75028 + struct file_operations trace_format;
75029 + struct file_operations trace_filter;
75030 #endif
75031 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
75032 unsigned int num_ftrace_callsites;
75033 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
75034 bool is_module_percpu_address(unsigned long addr);
75035 bool is_module_text_address(unsigned long addr);
75036
75037 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
75038 +{
75039 +
75040 +#ifdef CONFIG_PAX_KERNEXEC
75041 + if (ktla_ktva(addr) >= (unsigned long)start &&
75042 + ktla_ktva(addr) < (unsigned long)start + size)
75043 + return 1;
75044 +#endif
75045 +
75046 + return ((void *)addr >= start && (void *)addr < start + size);
75047 +}
75048 +
75049 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
75050 +{
75051 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
75052 +}
75053 +
75054 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
75055 +{
75056 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
75057 +}
75058 +
75059 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
75060 +{
75061 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
75062 +}
75063 +
75064 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
75065 +{
75066 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
75067 +}
75068 +
75069 static inline int within_module_core(unsigned long addr, const struct module *mod)
75070 {
75071 - return (unsigned long)mod->module_core <= addr &&
75072 - addr < (unsigned long)mod->module_core + mod->core_size;
75073 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
75074 }
75075
75076 static inline int within_module_init(unsigned long addr, const struct module *mod)
75077 {
75078 - return (unsigned long)mod->module_init <= addr &&
75079 - addr < (unsigned long)mod->module_init + mod->init_size;
75080 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
75081 }
75082
75083 /* Search for module by name: must hold module_mutex. */
75084 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
75085 index 560ca53..ef621ef 100644
75086 --- a/include/linux/moduleloader.h
75087 +++ b/include/linux/moduleloader.h
75088 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
75089 sections. Returns NULL on failure. */
75090 void *module_alloc(unsigned long size);
75091
75092 +#ifdef CONFIG_PAX_KERNEXEC
75093 +void *module_alloc_exec(unsigned long size);
75094 +#else
75095 +#define module_alloc_exec(x) module_alloc(x)
75096 +#endif
75097 +
75098 /* Free memory returned from module_alloc. */
75099 void module_free(struct module *mod, void *module_region);
75100
75101 +#ifdef CONFIG_PAX_KERNEXEC
75102 +void module_free_exec(struct module *mod, void *module_region);
75103 +#else
75104 +#define module_free_exec(x, y) module_free((x), (y))
75105 +#endif
75106 +
75107 /*
75108 * Apply the given relocation to the (simplified) ELF. Return -error
75109 * or 0.
75110 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
75111 unsigned int relsec,
75112 struct module *me)
75113 {
75114 +#ifdef CONFIG_MODULES
75115 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75116 +#endif
75117 return -ENOEXEC;
75118 }
75119 #endif
75120 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
75121 unsigned int relsec,
75122 struct module *me)
75123 {
75124 +#ifdef CONFIG_MODULES
75125 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75126 +#endif
75127 return -ENOEXEC;
75128 }
75129 #endif
75130 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
75131 index 27d9da3..5d94aa3 100644
75132 --- a/include/linux/moduleparam.h
75133 +++ b/include/linux/moduleparam.h
75134 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
75135 * @len is usually just sizeof(string).
75136 */
75137 #define module_param_string(name, string, len, perm) \
75138 - static const struct kparam_string __param_string_##name \
75139 + static const struct kparam_string __param_string_##name __used \
75140 = { len, string }; \
75141 __module_param_call(MODULE_PARAM_PREFIX, name, \
75142 &param_ops_string, \
75143 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
75144 */
75145 #define module_param_array_named(name, array, type, nump, perm) \
75146 param_check_##type(name, &(array)[0]); \
75147 - static const struct kparam_array __param_arr_##name \
75148 + static const struct kparam_array __param_arr_##name __used \
75149 = { .max = ARRAY_SIZE(array), .num = nump, \
75150 .ops = &param_ops_##type, \
75151 .elemsize = sizeof(array[0]), .elem = array }; \
75152 diff --git a/include/linux/namei.h b/include/linux/namei.h
75153 index 5a5ff57..5ae5070 100644
75154 --- a/include/linux/namei.h
75155 +++ b/include/linux/namei.h
75156 @@ -19,7 +19,7 @@ struct nameidata {
75157 unsigned seq;
75158 int last_type;
75159 unsigned depth;
75160 - char *saved_names[MAX_NESTED_LINKS + 1];
75161 + const char *saved_names[MAX_NESTED_LINKS + 1];
75162 };
75163
75164 /*
75165 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
75166
75167 extern void nd_jump_link(struct nameidata *nd, struct path *path);
75168
75169 -static inline void nd_set_link(struct nameidata *nd, char *path)
75170 +static inline void nd_set_link(struct nameidata *nd, const char *path)
75171 {
75172 nd->saved_names[nd->depth] = path;
75173 }
75174
75175 -static inline char *nd_get_link(struct nameidata *nd)
75176 +static inline const char *nd_get_link(const struct nameidata *nd)
75177 {
75178 return nd->saved_names[nd->depth];
75179 }
75180 diff --git a/include/linux/net.h b/include/linux/net.h
75181 index 4f27575..fc8a65f 100644
75182 --- a/include/linux/net.h
75183 +++ b/include/linux/net.h
75184 @@ -183,7 +183,7 @@ struct net_proto_family {
75185 int (*create)(struct net *net, struct socket *sock,
75186 int protocol, int kern);
75187 struct module *owner;
75188 -};
75189 +} __do_const;
75190
75191 struct iovec;
75192 struct kvec;
75193 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
75194 index 9a41568..203d903 100644
75195 --- a/include/linux/netdevice.h
75196 +++ b/include/linux/netdevice.h
75197 @@ -1061,6 +1061,7 @@ struct net_device_ops {
75198 int (*ndo_change_carrier)(struct net_device *dev,
75199 bool new_carrier);
75200 };
75201 +typedef struct net_device_ops __no_const net_device_ops_no_const;
75202
75203 /*
75204 * The DEVICE structure.
75205 @@ -1131,7 +1132,7 @@ struct net_device {
75206 int iflink;
75207
75208 struct net_device_stats stats;
75209 - atomic_long_t rx_dropped; /* dropped packets by core network
75210 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
75211 * Do not use this in drivers.
75212 */
75213
75214 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
75215 index de70f7b..2675e91 100644
75216 --- a/include/linux/netfilter.h
75217 +++ b/include/linux/netfilter.h
75218 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
75219 #endif
75220 /* Use the module struct to lock set/get code in place */
75221 struct module *owner;
75222 -};
75223 +} __do_const;
75224
75225 /* Function to register/unregister hook points. */
75226 int nf_register_hook(struct nf_hook_ops *reg);
75227 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
75228 index d80e275..c3510b8 100644
75229 --- a/include/linux/netfilter/ipset/ip_set.h
75230 +++ b/include/linux/netfilter/ipset/ip_set.h
75231 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
75232 /* Return true if "b" set is the same as "a"
75233 * according to the create set parameters */
75234 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
75235 -};
75236 +} __do_const;
75237
75238 /* The core set type structure */
75239 struct ip_set_type {
75240 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
75241 index cadb740..d7c37c0 100644
75242 --- a/include/linux/netfilter/nfnetlink.h
75243 +++ b/include/linux/netfilter/nfnetlink.h
75244 @@ -16,7 +16,7 @@ struct nfnl_callback {
75245 const struct nlattr * const cda[]);
75246 const struct nla_policy *policy; /* netlink attribute policy */
75247 const u_int16_t attr_count; /* number of nlattr's */
75248 -};
75249 +} __do_const;
75250
75251 struct nfnetlink_subsystem {
75252 const char *name;
75253 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
75254 new file mode 100644
75255 index 0000000..33f4af8
75256 --- /dev/null
75257 +++ b/include/linux/netfilter/xt_gradm.h
75258 @@ -0,0 +1,9 @@
75259 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
75260 +#define _LINUX_NETFILTER_XT_GRADM_H 1
75261 +
75262 +struct xt_gradm_mtinfo {
75263 + __u16 flags;
75264 + __u16 invflags;
75265 +};
75266 +
75267 +#endif
75268 diff --git a/include/linux/nls.h b/include/linux/nls.h
75269 index 5dc635f..35f5e11 100644
75270 --- a/include/linux/nls.h
75271 +++ b/include/linux/nls.h
75272 @@ -31,7 +31,7 @@ struct nls_table {
75273 const unsigned char *charset2upper;
75274 struct module *owner;
75275 struct nls_table *next;
75276 -};
75277 +} __do_const;
75278
75279 /* this value hold the maximum octet of charset */
75280 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
75281 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
75282 index d14a4c3..a078786 100644
75283 --- a/include/linux/notifier.h
75284 +++ b/include/linux/notifier.h
75285 @@ -54,7 +54,8 @@ struct notifier_block {
75286 notifier_fn_t notifier_call;
75287 struct notifier_block __rcu *next;
75288 int priority;
75289 -};
75290 +} __do_const;
75291 +typedef struct notifier_block __no_const notifier_block_no_const;
75292
75293 struct atomic_notifier_head {
75294 spinlock_t lock;
75295 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
75296 index a4c5624..79d6d88 100644
75297 --- a/include/linux/oprofile.h
75298 +++ b/include/linux/oprofile.h
75299 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
75300 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
75301 char const * name, ulong * val);
75302
75303 -/** Create a file for read-only access to an atomic_t. */
75304 +/** Create a file for read-only access to an atomic_unchecked_t. */
75305 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
75306 - char const * name, atomic_t * val);
75307 + char const * name, atomic_unchecked_t * val);
75308
75309 /** create a directory */
75310 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
75311 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
75312 index 8db71dc..a76bf2c 100644
75313 --- a/include/linux/pci_hotplug.h
75314 +++ b/include/linux/pci_hotplug.h
75315 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
75316 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
75317 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
75318 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
75319 -};
75320 +} __do_const;
75321 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
75322
75323 /**
75324 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
75325 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
75326 index c43f6ea..2d4416f 100644
75327 --- a/include/linux/perf_event.h
75328 +++ b/include/linux/perf_event.h
75329 @@ -328,8 +328,8 @@ struct perf_event {
75330
75331 enum perf_event_active_state state;
75332 unsigned int attach_state;
75333 - local64_t count;
75334 - atomic64_t child_count;
75335 + local64_t count; /* PaX: fix it one day */
75336 + atomic64_unchecked_t child_count;
75337
75338 /*
75339 * These are the total time in nanoseconds that the event
75340 @@ -380,8 +380,8 @@ struct perf_event {
75341 * These accumulate total time (in nanoseconds) that children
75342 * events have been enabled and running, respectively.
75343 */
75344 - atomic64_t child_total_time_enabled;
75345 - atomic64_t child_total_time_running;
75346 + atomic64_unchecked_t child_total_time_enabled;
75347 + atomic64_unchecked_t child_total_time_running;
75348
75349 /*
75350 * Protect attach/detach and child_list:
75351 @@ -703,7 +703,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
75352 entry->ip[entry->nr++] = ip;
75353 }
75354
75355 -extern int sysctl_perf_event_paranoid;
75356 +extern int sysctl_perf_event_legitimately_concerned;
75357 extern int sysctl_perf_event_mlock;
75358 extern int sysctl_perf_event_sample_rate;
75359 extern int sysctl_perf_cpu_time_max_percent;
75360 @@ -718,19 +718,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
75361 loff_t *ppos);
75362
75363
75364 +static inline bool perf_paranoid_any(void)
75365 +{
75366 + return sysctl_perf_event_legitimately_concerned > 2;
75367 +}
75368 +
75369 static inline bool perf_paranoid_tracepoint_raw(void)
75370 {
75371 - return sysctl_perf_event_paranoid > -1;
75372 + return sysctl_perf_event_legitimately_concerned > -1;
75373 }
75374
75375 static inline bool perf_paranoid_cpu(void)
75376 {
75377 - return sysctl_perf_event_paranoid > 0;
75378 + return sysctl_perf_event_legitimately_concerned > 0;
75379 }
75380
75381 static inline bool perf_paranoid_kernel(void)
75382 {
75383 - return sysctl_perf_event_paranoid > 1;
75384 + return sysctl_perf_event_legitimately_concerned > 1;
75385 }
75386
75387 extern void perf_event_init(void);
75388 @@ -846,7 +851,7 @@ struct perf_pmu_events_attr {
75389 struct device_attribute attr;
75390 u64 id;
75391 const char *event_str;
75392 -};
75393 +} __do_const;
75394
75395 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
75396 static struct perf_pmu_events_attr _var = { \
75397 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
75398 index b8809fe..ae4ccd0 100644
75399 --- a/include/linux/pipe_fs_i.h
75400 +++ b/include/linux/pipe_fs_i.h
75401 @@ -47,10 +47,10 @@ struct pipe_inode_info {
75402 struct mutex mutex;
75403 wait_queue_head_t wait;
75404 unsigned int nrbufs, curbuf, buffers;
75405 - unsigned int readers;
75406 - unsigned int writers;
75407 - unsigned int files;
75408 - unsigned int waiting_writers;
75409 + atomic_t readers;
75410 + atomic_t writers;
75411 + atomic_t files;
75412 + atomic_t waiting_writers;
75413 unsigned int r_counter;
75414 unsigned int w_counter;
75415 struct page *tmp_page;
75416 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
75417 index 5f28cae..3d23723 100644
75418 --- a/include/linux/platform_data/usb-ehci-s5p.h
75419 +++ b/include/linux/platform_data/usb-ehci-s5p.h
75420 @@ -14,7 +14,7 @@
75421 struct s5p_ehci_platdata {
75422 int (*phy_init)(struct platform_device *pdev, int type);
75423 int (*phy_exit)(struct platform_device *pdev, int type);
75424 -};
75425 +} __no_const;
75426
75427 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
75428
75429 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
75430 index c256c59..8ea94c7 100644
75431 --- a/include/linux/platform_data/usb-ohci-exynos.h
75432 +++ b/include/linux/platform_data/usb-ohci-exynos.h
75433 @@ -14,7 +14,7 @@
75434 struct exynos4_ohci_platdata {
75435 int (*phy_init)(struct platform_device *pdev, int type);
75436 int (*phy_exit)(struct platform_device *pdev, int type);
75437 -};
75438 +} __no_const;
75439
75440 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
75441
75442 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
75443 index 7c1d252..c5c773e 100644
75444 --- a/include/linux/pm_domain.h
75445 +++ b/include/linux/pm_domain.h
75446 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
75447
75448 struct gpd_cpu_data {
75449 unsigned int saved_exit_latency;
75450 - struct cpuidle_state *idle_state;
75451 + cpuidle_state_no_const *idle_state;
75452 };
75453
75454 struct generic_pm_domain {
75455 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
75456 index 6fa7cea..7bf6415 100644
75457 --- a/include/linux/pm_runtime.h
75458 +++ b/include/linux/pm_runtime.h
75459 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
75460
75461 static inline void pm_runtime_mark_last_busy(struct device *dev)
75462 {
75463 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
75464 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
75465 }
75466
75467 #else /* !CONFIG_PM_RUNTIME */
75468 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
75469 index 195aafc..49a7bc2 100644
75470 --- a/include/linux/pnp.h
75471 +++ b/include/linux/pnp.h
75472 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
75473 struct pnp_fixup {
75474 char id[7];
75475 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
75476 -};
75477 +} __do_const;
75478
75479 /* config parameters */
75480 #define PNP_CONFIG_NORMAL 0x0001
75481 diff --git a/include/linux/poison.h b/include/linux/poison.h
75482 index 2110a81..13a11bb 100644
75483 --- a/include/linux/poison.h
75484 +++ b/include/linux/poison.h
75485 @@ -19,8 +19,8 @@
75486 * under normal circumstances, used to verify that nobody uses
75487 * non-initialized list entries.
75488 */
75489 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
75490 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
75491 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
75492 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
75493
75494 /********** include/linux/timer.h **********/
75495 /*
75496 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
75497 index d8b187c3..9a9257a 100644
75498 --- a/include/linux/power/smartreflex.h
75499 +++ b/include/linux/power/smartreflex.h
75500 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
75501 int (*notify)(struct omap_sr *sr, u32 status);
75502 u8 notify_flags;
75503 u8 class_type;
75504 -};
75505 +} __do_const;
75506
75507 /**
75508 * struct omap_sr_nvalue_table - Smartreflex n-target value info
75509 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
75510 index 4ea1d37..80f4b33 100644
75511 --- a/include/linux/ppp-comp.h
75512 +++ b/include/linux/ppp-comp.h
75513 @@ -84,7 +84,7 @@ struct compressor {
75514 struct module *owner;
75515 /* Extra skb space needed by the compressor algorithm */
75516 unsigned int comp_extra;
75517 -};
75518 +} __do_const;
75519
75520 /*
75521 * The return value from decompress routine is the length of the
75522 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
75523 index f5d4723..a6ea2fa 100644
75524 --- a/include/linux/preempt.h
75525 +++ b/include/linux/preempt.h
75526 @@ -18,8 +18,13 @@
75527 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75528 #endif
75529
75530 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
75531 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
75532 +
75533 #define inc_preempt_count() add_preempt_count(1)
75534 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
75535 #define dec_preempt_count() sub_preempt_count(1)
75536 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
75537
75538 #define preempt_count() (current_thread_info()->preempt_count)
75539
75540 @@ -64,6 +69,12 @@ do { \
75541 barrier(); \
75542 } while (0)
75543
75544 +#define raw_preempt_disable() \
75545 +do { \
75546 + raw_inc_preempt_count(); \
75547 + barrier(); \
75548 +} while (0)
75549 +
75550 #define sched_preempt_enable_no_resched() \
75551 do { \
75552 barrier(); \
75553 @@ -72,6 +83,12 @@ do { \
75554
75555 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
75556
75557 +#define raw_preempt_enable_no_resched() \
75558 +do { \
75559 + barrier(); \
75560 + raw_dec_preempt_count(); \
75561 +} while (0)
75562 +
75563 #define preempt_enable() \
75564 do { \
75565 preempt_enable_no_resched(); \
75566 @@ -116,8 +133,10 @@ do { \
75567 * region.
75568 */
75569 #define preempt_disable() barrier()
75570 +#define raw_preempt_disable() barrier()
75571 #define sched_preempt_enable_no_resched() barrier()
75572 #define preempt_enable_no_resched() barrier()
75573 +#define raw_preempt_enable_no_resched() barrier()
75574 #define preempt_enable() barrier()
75575
75576 #define preempt_disable_notrace() barrier()
75577 diff --git a/include/linux/printk.h b/include/linux/printk.h
75578 index 22c7052..ad3fa0a 100644
75579 --- a/include/linux/printk.h
75580 +++ b/include/linux/printk.h
75581 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
75582 void early_printk(const char *s, ...) { }
75583 #endif
75584
75585 +extern int kptr_restrict;
75586 +
75587 #ifdef CONFIG_PRINTK
75588 asmlinkage __printf(5, 0)
75589 int vprintk_emit(int facility, int level,
75590 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
75591
75592 extern int printk_delay_msec;
75593 extern int dmesg_restrict;
75594 -extern int kptr_restrict;
75595
75596 extern void wake_up_klogd(void);
75597
75598 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
75599 index 608e60a..c26f864 100644
75600 --- a/include/linux/proc_fs.h
75601 +++ b/include/linux/proc_fs.h
75602 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
75603 return proc_create_data(name, mode, parent, proc_fops, NULL);
75604 }
75605
75606 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
75607 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
75608 +{
75609 +#ifdef CONFIG_GRKERNSEC_PROC_USER
75610 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
75611 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75612 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
75613 +#else
75614 + return proc_create_data(name, mode, parent, proc_fops, NULL);
75615 +#endif
75616 +}
75617 +
75618 +
75619 extern void proc_set_size(struct proc_dir_entry *, loff_t);
75620 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
75621 extern void *PDE_DATA(const struct inode *);
75622 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
75623 index 34a1e10..03a6d03 100644
75624 --- a/include/linux/proc_ns.h
75625 +++ b/include/linux/proc_ns.h
75626 @@ -14,7 +14,7 @@ struct proc_ns_operations {
75627 void (*put)(void *ns);
75628 int (*install)(struct nsproxy *nsproxy, void *ns);
75629 unsigned int (*inum)(void *ns);
75630 -};
75631 +} __do_const;
75632
75633 struct proc_ns {
75634 void *ns;
75635 diff --git a/include/linux/random.h b/include/linux/random.h
75636 index 3b9377d..e418336 100644
75637 --- a/include/linux/random.h
75638 +++ b/include/linux/random.h
75639 @@ -10,9 +10,19 @@
75640
75641
75642 extern void add_device_randomness(const void *, unsigned int);
75643 +
75644 +static inline void add_latent_entropy(void)
75645 +{
75646 +
75647 +#ifdef LATENT_ENTROPY_PLUGIN
75648 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
75649 +#endif
75650 +
75651 +}
75652 +
75653 extern void add_input_randomness(unsigned int type, unsigned int code,
75654 - unsigned int value);
75655 -extern void add_interrupt_randomness(int irq, int irq_flags);
75656 + unsigned int value) __latent_entropy;
75657 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
75658
75659 extern void get_random_bytes(void *buf, int nbytes);
75660 extern void get_random_bytes_arch(void *buf, int nbytes);
75661 @@ -32,6 +42,11 @@ void prandom_seed(u32 seed);
75662 u32 prandom_u32_state(struct rnd_state *);
75663 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
75664
75665 +static inline unsigned long pax_get_random_long(void)
75666 +{
75667 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
75668 +}
75669 +
75670 /*
75671 * Handle minimum values for seeds
75672 */
75673 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
75674 index 4106721..132d42c 100644
75675 --- a/include/linux/rculist.h
75676 +++ b/include/linux/rculist.h
75677 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
75678 struct list_head *prev, struct list_head *next);
75679 #endif
75680
75681 +extern void __pax_list_add_rcu(struct list_head *new,
75682 + struct list_head *prev, struct list_head *next);
75683 +
75684 /**
75685 * list_add_rcu - add a new entry to rcu-protected list
75686 * @new: new entry to be added
75687 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
75688 __list_add_rcu(new, head, head->next);
75689 }
75690
75691 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
75692 +{
75693 + __pax_list_add_rcu(new, head, head->next);
75694 +}
75695 +
75696 /**
75697 * list_add_tail_rcu - add a new entry to rcu-protected list
75698 * @new: new entry to be added
75699 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
75700 __list_add_rcu(new, head->prev, head);
75701 }
75702
75703 +static inline void pax_list_add_tail_rcu(struct list_head *new,
75704 + struct list_head *head)
75705 +{
75706 + __pax_list_add_rcu(new, head->prev, head);
75707 +}
75708 +
75709 /**
75710 * list_del_rcu - deletes entry from list without re-initialization
75711 * @entry: the element to delete from the list.
75712 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
75713 entry->prev = LIST_POISON2;
75714 }
75715
75716 +extern void pax_list_del_rcu(struct list_head *entry);
75717 +
75718 /**
75719 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
75720 * @n: the element to delete from the hash list.
75721 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
75722 index 8e00f9f..9449b55 100644
75723 --- a/include/linux/reboot.h
75724 +++ b/include/linux/reboot.h
75725 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
75726 * Architecture-specific implementations of sys_reboot commands.
75727 */
75728
75729 -extern void machine_restart(char *cmd);
75730 -extern void machine_halt(void);
75731 -extern void machine_power_off(void);
75732 +extern void machine_restart(char *cmd) __noreturn;
75733 +extern void machine_halt(void) __noreturn;
75734 +extern void machine_power_off(void) __noreturn;
75735
75736 extern void machine_shutdown(void);
75737 struct pt_regs;
75738 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
75739 */
75740
75741 extern void kernel_restart_prepare(char *cmd);
75742 -extern void kernel_restart(char *cmd);
75743 -extern void kernel_halt(void);
75744 -extern void kernel_power_off(void);
75745 +extern void kernel_restart(char *cmd) __noreturn;
75746 +extern void kernel_halt(void) __noreturn;
75747 +extern void kernel_power_off(void) __noreturn;
75748
75749 extern int C_A_D; /* for sysctl */
75750 void ctrl_alt_del(void);
75751 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
75752 * Emergency restart, callable from an interrupt handler.
75753 */
75754
75755 -extern void emergency_restart(void);
75756 +extern void emergency_restart(void) __noreturn;
75757 #include <asm/emergency-restart.h>
75758
75759 #endif /* _LINUX_REBOOT_H */
75760 diff --git a/include/linux/regset.h b/include/linux/regset.h
75761 index 8e0c9fe..ac4d221 100644
75762 --- a/include/linux/regset.h
75763 +++ b/include/linux/regset.h
75764 @@ -161,7 +161,8 @@ struct user_regset {
75765 unsigned int align;
75766 unsigned int bias;
75767 unsigned int core_note_type;
75768 -};
75769 +} __do_const;
75770 +typedef struct user_regset __no_const user_regset_no_const;
75771
75772 /**
75773 * struct user_regset_view - available regsets
75774 diff --git a/include/linux/relay.h b/include/linux/relay.h
75775 index d7c8359..818daf5 100644
75776 --- a/include/linux/relay.h
75777 +++ b/include/linux/relay.h
75778 @@ -157,7 +157,7 @@ struct rchan_callbacks
75779 * The callback should return 0 if successful, negative if not.
75780 */
75781 int (*remove_buf_file)(struct dentry *dentry);
75782 -};
75783 +} __no_const;
75784
75785 /*
75786 * CONFIG_RELAY kernel API, kernel/relay.c
75787 diff --git a/include/linux/rio.h b/include/linux/rio.h
75788 index b71d573..2f940bd 100644
75789 --- a/include/linux/rio.h
75790 +++ b/include/linux/rio.h
75791 @@ -355,7 +355,7 @@ struct rio_ops {
75792 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
75793 u64 rstart, u32 size, u32 flags);
75794 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
75795 -};
75796 +} __no_const;
75797
75798 #define RIO_RESOURCE_MEM 0x00000100
75799 #define RIO_RESOURCE_DOORBELL 0x00000200
75800 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
75801 index 6dacb93..6174423 100644
75802 --- a/include/linux/rmap.h
75803 +++ b/include/linux/rmap.h
75804 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
75805 void anon_vma_init(void); /* create anon_vma_cachep */
75806 int anon_vma_prepare(struct vm_area_struct *);
75807 void unlink_anon_vmas(struct vm_area_struct *);
75808 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
75809 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
75810 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
75811 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
75812
75813 static inline void anon_vma_merge(struct vm_area_struct *vma,
75814 struct vm_area_struct *next)
75815 diff --git a/include/linux/sched.h b/include/linux/sched.h
75816 index 078066d..4090b3b 100644
75817 --- a/include/linux/sched.h
75818 +++ b/include/linux/sched.h
75819 @@ -62,6 +62,7 @@ struct bio_list;
75820 struct fs_struct;
75821 struct perf_event_context;
75822 struct blk_plug;
75823 +struct linux_binprm;
75824
75825 /*
75826 * List of flags we want to share for kernel threads,
75827 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
75828 extern int in_sched_functions(unsigned long addr);
75829
75830 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
75831 -extern signed long schedule_timeout(signed long timeout);
75832 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
75833 extern signed long schedule_timeout_interruptible(signed long timeout);
75834 extern signed long schedule_timeout_killable(signed long timeout);
75835 extern signed long schedule_timeout_uninterruptible(signed long timeout);
75836 @@ -314,6 +315,19 @@ struct nsproxy;
75837 struct user_namespace;
75838
75839 #ifdef CONFIG_MMU
75840 +
75841 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
75842 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
75843 +#else
75844 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
75845 +{
75846 + return 0;
75847 +}
75848 +#endif
75849 +
75850 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
75851 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
75852 +
75853 extern void arch_pick_mmap_layout(struct mm_struct *mm);
75854 extern unsigned long
75855 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
75856 @@ -589,6 +603,17 @@ struct signal_struct {
75857 #ifdef CONFIG_TASKSTATS
75858 struct taskstats *stats;
75859 #endif
75860 +
75861 +#ifdef CONFIG_GRKERNSEC
75862 + u32 curr_ip;
75863 + u32 saved_ip;
75864 + u32 gr_saddr;
75865 + u32 gr_daddr;
75866 + u16 gr_sport;
75867 + u16 gr_dport;
75868 + u8 used_accept:1;
75869 +#endif
75870 +
75871 #ifdef CONFIG_AUDIT
75872 unsigned audit_tty;
75873 unsigned audit_tty_log_passwd;
75874 @@ -669,6 +694,14 @@ struct user_struct {
75875 struct key *session_keyring; /* UID's default session keyring */
75876 #endif
75877
75878 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
75879 + unsigned char kernel_banned;
75880 +#endif
75881 +#ifdef CONFIG_GRKERNSEC_BRUTE
75882 + unsigned char suid_banned;
75883 + unsigned long suid_ban_expires;
75884 +#endif
75885 +
75886 /* Hash table maintenance information */
75887 struct hlist_node uidhash_node;
75888 kuid_t uid;
75889 @@ -1151,8 +1184,8 @@ struct task_struct {
75890 struct list_head thread_group;
75891
75892 struct completion *vfork_done; /* for vfork() */
75893 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
75894 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
75895 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
75896 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
75897
75898 cputime_t utime, stime, utimescaled, stimescaled;
75899 cputime_t gtime;
75900 @@ -1177,11 +1210,6 @@ struct task_struct {
75901 struct task_cputime cputime_expires;
75902 struct list_head cpu_timers[3];
75903
75904 -/* process credentials */
75905 - const struct cred __rcu *real_cred; /* objective and real subjective task
75906 - * credentials (COW) */
75907 - const struct cred __rcu *cred; /* effective (overridable) subjective task
75908 - * credentials (COW) */
75909 char comm[TASK_COMM_LEN]; /* executable name excluding path
75910 - access with [gs]et_task_comm (which lock
75911 it with task_lock())
75912 @@ -1198,6 +1226,10 @@ struct task_struct {
75913 #endif
75914 /* CPU-specific state of this task */
75915 struct thread_struct thread;
75916 +/* thread_info moved to task_struct */
75917 +#ifdef CONFIG_X86
75918 + struct thread_info tinfo;
75919 +#endif
75920 /* filesystem information */
75921 struct fs_struct *fs;
75922 /* open file information */
75923 @@ -1271,6 +1303,10 @@ struct task_struct {
75924 gfp_t lockdep_reclaim_gfp;
75925 #endif
75926
75927 +/* process credentials */
75928 + const struct cred __rcu *real_cred; /* objective and real subjective task
75929 + * credentials (COW) */
75930 +
75931 /* journalling filesystem info */
75932 void *journal_info;
75933
75934 @@ -1309,6 +1345,10 @@ struct task_struct {
75935 /* cg_list protected by css_set_lock and tsk->alloc_lock */
75936 struct list_head cg_list;
75937 #endif
75938 +
75939 + const struct cred __rcu *cred; /* effective (overridable) subjective task
75940 + * credentials (COW) */
75941 +
75942 #ifdef CONFIG_FUTEX
75943 struct robust_list_head __user *robust_list;
75944 #ifdef CONFIG_COMPAT
75945 @@ -1406,8 +1446,76 @@ struct task_struct {
75946 unsigned int sequential_io;
75947 unsigned int sequential_io_avg;
75948 #endif
75949 +
75950 +#ifdef CONFIG_GRKERNSEC
75951 + /* grsecurity */
75952 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
75953 + u64 exec_id;
75954 +#endif
75955 +#ifdef CONFIG_GRKERNSEC_SETXID
75956 + const struct cred *delayed_cred;
75957 +#endif
75958 + struct dentry *gr_chroot_dentry;
75959 + struct acl_subject_label *acl;
75960 + struct acl_role_label *role;
75961 + struct file *exec_file;
75962 + unsigned long brute_expires;
75963 + u16 acl_role_id;
75964 + /* is this the task that authenticated to the special role */
75965 + u8 acl_sp_role;
75966 + u8 is_writable;
75967 + u8 brute;
75968 + u8 gr_is_chrooted;
75969 +#endif
75970 +
75971 };
75972
75973 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
75974 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
75975 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
75976 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
75977 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
75978 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
75979 +
75980 +#ifdef CONFIG_PAX_SOFTMODE
75981 +extern int pax_softmode;
75982 +#endif
75983 +
75984 +extern int pax_check_flags(unsigned long *);
75985 +
75986 +/* if tsk != current then task_lock must be held on it */
75987 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
75988 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
75989 +{
75990 + if (likely(tsk->mm))
75991 + return tsk->mm->pax_flags;
75992 + else
75993 + return 0UL;
75994 +}
75995 +
75996 +/* if tsk != current then task_lock must be held on it */
75997 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
75998 +{
75999 + if (likely(tsk->mm)) {
76000 + tsk->mm->pax_flags = flags;
76001 + return 0;
76002 + }
76003 + return -EINVAL;
76004 +}
76005 +#endif
76006 +
76007 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76008 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
76009 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
76010 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76011 +#endif
76012 +
76013 +struct path;
76014 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
76015 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
76016 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
76017 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
76018 +
76019 /* Future-safe accessor for struct task_struct's cpus_allowed. */
76020 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
76021
76022 @@ -1466,7 +1574,7 @@ struct pid_namespace;
76023 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
76024 struct pid_namespace *ns);
76025
76026 -static inline pid_t task_pid_nr(struct task_struct *tsk)
76027 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
76028 {
76029 return tsk->pid;
76030 }
76031 @@ -1916,7 +2024,9 @@ void yield(void);
76032 extern struct exec_domain default_exec_domain;
76033
76034 union thread_union {
76035 +#ifndef CONFIG_X86
76036 struct thread_info thread_info;
76037 +#endif
76038 unsigned long stack[THREAD_SIZE/sizeof(long)];
76039 };
76040
76041 @@ -1949,6 +2059,7 @@ extern struct pid_namespace init_pid_ns;
76042 */
76043
76044 extern struct task_struct *find_task_by_vpid(pid_t nr);
76045 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
76046 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
76047 struct pid_namespace *ns);
76048
76049 @@ -2113,7 +2224,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
76050 extern void exit_itimers(struct signal_struct *);
76051 extern void flush_itimer_signals(void);
76052
76053 -extern void do_group_exit(int);
76054 +extern __noreturn void do_group_exit(int);
76055
76056 extern int allow_signal(int);
76057 extern int disallow_signal(int);
76058 @@ -2304,9 +2415,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
76059
76060 #endif
76061
76062 -static inline int object_is_on_stack(void *obj)
76063 +static inline int object_starts_on_stack(void *obj)
76064 {
76065 - void *stack = task_stack_page(current);
76066 + const void *stack = task_stack_page(current);
76067
76068 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
76069 }
76070 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
76071 index bf8086b..962b035 100644
76072 --- a/include/linux/sched/sysctl.h
76073 +++ b/include/linux/sched/sysctl.h
76074 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
76075 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
76076
76077 extern int sysctl_max_map_count;
76078 +extern unsigned long sysctl_heap_stack_gap;
76079
76080 extern unsigned int sysctl_sched_latency;
76081 extern unsigned int sysctl_sched_min_granularity;
76082 diff --git a/include/linux/security.h b/include/linux/security.h
76083 index 7ce53ae..8ee24a5 100644
76084 --- a/include/linux/security.h
76085 +++ b/include/linux/security.h
76086 @@ -27,6 +27,7 @@
76087 #include <linux/slab.h>
76088 #include <linux/err.h>
76089 #include <linux/string.h>
76090 +#include <linux/grsecurity.h>
76091
76092 struct linux_binprm;
76093 struct cred;
76094 @@ -116,8 +117,6 @@ struct seq_file;
76095
76096 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
76097
76098 -void reset_security_ops(void);
76099 -
76100 #ifdef CONFIG_MMU
76101 extern unsigned long mmap_min_addr;
76102 extern unsigned long dac_mmap_min_addr;
76103 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
76104 index 4e32edc..f8f2d18 100644
76105 --- a/include/linux/seq_file.h
76106 +++ b/include/linux/seq_file.h
76107 @@ -26,6 +26,9 @@ struct seq_file {
76108 struct mutex lock;
76109 const struct seq_operations *op;
76110 int poll_event;
76111 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76112 + u64 exec_id;
76113 +#endif
76114 #ifdef CONFIG_USER_NS
76115 struct user_namespace *user_ns;
76116 #endif
76117 @@ -38,6 +41,7 @@ struct seq_operations {
76118 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
76119 int (*show) (struct seq_file *m, void *v);
76120 };
76121 +typedef struct seq_operations __no_const seq_operations_no_const;
76122
76123 #define SEQ_SKIP 1
76124
76125 diff --git a/include/linux/shm.h b/include/linux/shm.h
76126 index 429c199..4d42e38 100644
76127 --- a/include/linux/shm.h
76128 +++ b/include/linux/shm.h
76129 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
76130
76131 /* The task created the shm object. NULL if the task is dead. */
76132 struct task_struct *shm_creator;
76133 +#ifdef CONFIG_GRKERNSEC
76134 + time_t shm_createtime;
76135 + pid_t shm_lapid;
76136 +#endif
76137 };
76138
76139 /* shm_mode upper byte flags */
76140 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
76141 index 3b71a4e..5c9f309 100644
76142 --- a/include/linux/skbuff.h
76143 +++ b/include/linux/skbuff.h
76144 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
76145 extern struct sk_buff *__alloc_skb(unsigned int size,
76146 gfp_t priority, int flags, int node);
76147 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
76148 -static inline struct sk_buff *alloc_skb(unsigned int size,
76149 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
76150 gfp_t priority)
76151 {
76152 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
76153 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
76154 */
76155 static inline int skb_queue_empty(const struct sk_buff_head *list)
76156 {
76157 - return list->next == (struct sk_buff *)list;
76158 + return list->next == (const struct sk_buff *)list;
76159 }
76160
76161 /**
76162 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
76163 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76164 const struct sk_buff *skb)
76165 {
76166 - return skb->next == (struct sk_buff *)list;
76167 + return skb->next == (const struct sk_buff *)list;
76168 }
76169
76170 /**
76171 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76172 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
76173 const struct sk_buff *skb)
76174 {
76175 - return skb->prev == (struct sk_buff *)list;
76176 + return skb->prev == (const struct sk_buff *)list;
76177 }
76178
76179 /**
76180 @@ -1750,7 +1750,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
76181 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
76182 */
76183 #ifndef NET_SKB_PAD
76184 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
76185 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
76186 #endif
76187
76188 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
76189 @@ -2345,7 +2345,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
76190 int noblock, int *err);
76191 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
76192 struct poll_table_struct *wait);
76193 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
76194 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
76195 int offset, struct iovec *to,
76196 int size);
76197 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
76198 @@ -2636,6 +2636,9 @@ static inline void nf_reset(struct sk_buff *skb)
76199 nf_bridge_put(skb->nf_bridge);
76200 skb->nf_bridge = NULL;
76201 #endif
76202 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
76203 + skb->nf_trace = 0;
76204 +#endif
76205 }
76206
76207 static inline void nf_reset_trace(struct sk_buff *skb)
76208 diff --git a/include/linux/slab.h b/include/linux/slab.h
76209 index 6c5cc0e..9ca0fd6 100644
76210 --- a/include/linux/slab.h
76211 +++ b/include/linux/slab.h
76212 @@ -12,15 +12,29 @@
76213 #include <linux/gfp.h>
76214 #include <linux/types.h>
76215 #include <linux/workqueue.h>
76216 -
76217 +#include <linux/err.h>
76218
76219 /*
76220 * Flags to pass to kmem_cache_create().
76221 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
76222 */
76223 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
76224 +
76225 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76226 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
76227 +#else
76228 +#define SLAB_USERCOPY 0x00000000UL
76229 +#endif
76230 +
76231 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
76232 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
76233 +
76234 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76235 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
76236 +#else
76237 +#define SLAB_NO_SANITIZE 0x00000000UL
76238 +#endif
76239 +
76240 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
76241 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
76242 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
76243 @@ -89,10 +103,13 @@
76244 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
76245 * Both make kfree a no-op.
76246 */
76247 -#define ZERO_SIZE_PTR ((void *)16)
76248 +#define ZERO_SIZE_PTR \
76249 +({ \
76250 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
76251 + (void *)(-MAX_ERRNO-1L); \
76252 +})
76253
76254 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
76255 - (unsigned long)ZERO_SIZE_PTR)
76256 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
76257
76258
76259 struct mem_cgroup;
76260 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
76261 void kfree(const void *);
76262 void kzfree(const void *);
76263 size_t ksize(const void *);
76264 +const char *check_heap_object(const void *ptr, unsigned long n);
76265 +bool is_usercopy_object(const void *ptr);
76266
76267 /*
76268 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
76269 @@ -164,7 +183,7 @@ struct kmem_cache {
76270 unsigned int align; /* Alignment as calculated */
76271 unsigned long flags; /* Active flags on the slab */
76272 const char *name; /* Slab name for sysfs */
76273 - int refcount; /* Use counter */
76274 + atomic_t refcount; /* Use counter */
76275 void (*ctor)(void *); /* Called on object slot creation */
76276 struct list_head list; /* List of all slab caches on the system */
76277 };
76278 @@ -238,6 +257,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
76279 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76280 #endif
76281
76282 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76283 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
76284 +#endif
76285 +
76286 /*
76287 * Figure out which kmalloc slab an allocation of a certain size
76288 * belongs to.
76289 @@ -246,7 +269,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76290 * 2 = 120 .. 192 bytes
76291 * n = 2^(n-1) .. 2^n -1
76292 */
76293 -static __always_inline int kmalloc_index(size_t size)
76294 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
76295 {
76296 if (!size)
76297 return 0;
76298 @@ -492,7 +515,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
76299 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76300 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76301 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76302 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76303 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
76304 #define kmalloc_track_caller(size, flags) \
76305 __kmalloc_track_caller(size, flags, _RET_IP_)
76306 #else
76307 @@ -512,7 +535,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76308 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76309 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76310 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76311 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
76312 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
76313 #define kmalloc_node_track_caller(size, flags, node) \
76314 __kmalloc_node_track_caller(size, flags, node, \
76315 _RET_IP_)
76316 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
76317 index cd40158..4e2f7af 100644
76318 --- a/include/linux/slab_def.h
76319 +++ b/include/linux/slab_def.h
76320 @@ -50,7 +50,7 @@ struct kmem_cache {
76321 /* 4) cache creation/removal */
76322 const char *name;
76323 struct list_head list;
76324 - int refcount;
76325 + atomic_t refcount;
76326 int object_size;
76327 int align;
76328
76329 @@ -66,10 +66,14 @@ struct kmem_cache {
76330 unsigned long node_allocs;
76331 unsigned long node_frees;
76332 unsigned long node_overflow;
76333 - atomic_t allochit;
76334 - atomic_t allocmiss;
76335 - atomic_t freehit;
76336 - atomic_t freemiss;
76337 + atomic_unchecked_t allochit;
76338 + atomic_unchecked_t allocmiss;
76339 + atomic_unchecked_t freehit;
76340 + atomic_unchecked_t freemiss;
76341 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76342 + atomic_unchecked_t sanitized;
76343 + atomic_unchecked_t not_sanitized;
76344 +#endif
76345
76346 /*
76347 * If debugging is enabled, then the allocator can add additional
76348 @@ -103,7 +107,7 @@ struct kmem_cache {
76349 };
76350
76351 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76352 -void *__kmalloc(size_t size, gfp_t flags);
76353 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
76354
76355 #ifdef CONFIG_TRACING
76356 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
76357 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76358 cachep = kmalloc_dma_caches[i];
76359 else
76360 #endif
76361 +
76362 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76363 + if (flags & GFP_USERCOPY)
76364 + cachep = kmalloc_usercopy_caches[i];
76365 + else
76366 +#endif
76367 +
76368 cachep = kmalloc_caches[i];
76369
76370 ret = kmem_cache_alloc_trace(cachep, flags, size);
76371 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76372 }
76373
76374 #ifdef CONFIG_NUMA
76375 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
76376 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76377 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76378
76379 #ifdef CONFIG_TRACING
76380 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76381 cachep = kmalloc_dma_caches[i];
76382 else
76383 #endif
76384 +
76385 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76386 + if (flags & GFP_USERCOPY)
76387 + cachep = kmalloc_usercopy_caches[i];
76388 + else
76389 +#endif
76390 +
76391 cachep = kmalloc_caches[i];
76392
76393 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
76394 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
76395 index 095a5a4..4b82027 100644
76396 --- a/include/linux/slob_def.h
76397 +++ b/include/linux/slob_def.h
76398 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
76399 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
76400 }
76401
76402 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76403 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76404
76405 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76406 {
76407 @@ -23,7 +23,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76408 return __kmalloc_node(size, flags, NUMA_NO_NODE);
76409 }
76410
76411 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
76412 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
76413 {
76414 return kmalloc(size, flags);
76415 }
76416 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
76417 index 027276f..092bfe8 100644
76418 --- a/include/linux/slub_def.h
76419 +++ b/include/linux/slub_def.h
76420 @@ -80,7 +80,7 @@ struct kmem_cache {
76421 struct kmem_cache_order_objects max;
76422 struct kmem_cache_order_objects min;
76423 gfp_t allocflags; /* gfp flags to use on each alloc */
76424 - int refcount; /* Refcount for slab cache destroy */
76425 + atomic_t refcount; /* Refcount for slab cache destroy */
76426 void (*ctor)(void *);
76427 int inuse; /* Offset to metadata */
76428 int align; /* Alignment */
76429 @@ -105,7 +105,7 @@ struct kmem_cache {
76430 };
76431
76432 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76433 -void *__kmalloc(size_t size, gfp_t flags);
76434 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
76435
76436 static __always_inline void *
76437 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
76438 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
76439 }
76440 #endif
76441
76442 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
76443 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
76444 {
76445 unsigned int order = get_order(size);
76446 return kmalloc_order_trace(size, flags, order);
76447 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76448 }
76449
76450 #ifdef CONFIG_NUMA
76451 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76452 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76453 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76454
76455 #ifdef CONFIG_TRACING
76456 diff --git a/include/linux/smp.h b/include/linux/smp.h
76457 index c181399..09d7b92 100644
76458 --- a/include/linux/smp.h
76459 +++ b/include/linux/smp.h
76460 @@ -217,7 +217,9 @@ static inline void kick_all_cpus_sync(void) { }
76461 #endif
76462
76463 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
76464 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
76465 #define put_cpu() preempt_enable()
76466 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
76467
76468 /*
76469 * Callback to arch code if there's nosmp or maxcpus=0 on the
76470 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
76471 index 54f91d3..be2c379 100644
76472 --- a/include/linux/sock_diag.h
76473 +++ b/include/linux/sock_diag.h
76474 @@ -11,7 +11,7 @@ struct sock;
76475 struct sock_diag_handler {
76476 __u8 family;
76477 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
76478 -};
76479 +} __do_const;
76480
76481 int sock_diag_register(const struct sock_diag_handler *h);
76482 void sock_diag_unregister(const struct sock_diag_handler *h);
76483 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
76484 index 680f9a3..f13aeb0 100644
76485 --- a/include/linux/sonet.h
76486 +++ b/include/linux/sonet.h
76487 @@ -7,7 +7,7 @@
76488 #include <uapi/linux/sonet.h>
76489
76490 struct k_sonet_stats {
76491 -#define __HANDLE_ITEM(i) atomic_t i
76492 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
76493 __SONET_ITEMS
76494 #undef __HANDLE_ITEM
76495 };
76496 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
76497 index 07d8e53..dc934c9 100644
76498 --- a/include/linux/sunrpc/addr.h
76499 +++ b/include/linux/sunrpc/addr.h
76500 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
76501 {
76502 switch (sap->sa_family) {
76503 case AF_INET:
76504 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
76505 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
76506 case AF_INET6:
76507 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
76508 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
76509 }
76510 return 0;
76511 }
76512 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
76513 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
76514 const struct sockaddr *src)
76515 {
76516 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
76517 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
76518 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
76519
76520 dsin->sin_family = ssin->sin_family;
76521 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
76522 if (sa->sa_family != AF_INET6)
76523 return 0;
76524
76525 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
76526 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
76527 }
76528
76529 #endif /* _LINUX_SUNRPC_ADDR_H */
76530 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
76531 index bfe11be..12bc8c4 100644
76532 --- a/include/linux/sunrpc/clnt.h
76533 +++ b/include/linux/sunrpc/clnt.h
76534 @@ -96,7 +96,7 @@ struct rpc_procinfo {
76535 unsigned int p_timer; /* Which RTT timer to use */
76536 u32 p_statidx; /* Which procedure to account */
76537 const char * p_name; /* name of procedure */
76538 -};
76539 +} __do_const;
76540
76541 #ifdef __KERNEL__
76542
76543 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
76544 index 1f0216b..6a4fa50 100644
76545 --- a/include/linux/sunrpc/svc.h
76546 +++ b/include/linux/sunrpc/svc.h
76547 @@ -411,7 +411,7 @@ struct svc_procedure {
76548 unsigned int pc_count; /* call count */
76549 unsigned int pc_cachetype; /* cache info (NFS) */
76550 unsigned int pc_xdrressize; /* maximum size of XDR reply */
76551 -};
76552 +} __do_const;
76553
76554 /*
76555 * Function prototypes.
76556 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
76557 index 0b8e3e6..33e0a01 100644
76558 --- a/include/linux/sunrpc/svc_rdma.h
76559 +++ b/include/linux/sunrpc/svc_rdma.h
76560 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
76561 extern unsigned int svcrdma_max_requests;
76562 extern unsigned int svcrdma_max_req_size;
76563
76564 -extern atomic_t rdma_stat_recv;
76565 -extern atomic_t rdma_stat_read;
76566 -extern atomic_t rdma_stat_write;
76567 -extern atomic_t rdma_stat_sq_starve;
76568 -extern atomic_t rdma_stat_rq_starve;
76569 -extern atomic_t rdma_stat_rq_poll;
76570 -extern atomic_t rdma_stat_rq_prod;
76571 -extern atomic_t rdma_stat_sq_poll;
76572 -extern atomic_t rdma_stat_sq_prod;
76573 +extern atomic_unchecked_t rdma_stat_recv;
76574 +extern atomic_unchecked_t rdma_stat_read;
76575 +extern atomic_unchecked_t rdma_stat_write;
76576 +extern atomic_unchecked_t rdma_stat_sq_starve;
76577 +extern atomic_unchecked_t rdma_stat_rq_starve;
76578 +extern atomic_unchecked_t rdma_stat_rq_poll;
76579 +extern atomic_unchecked_t rdma_stat_rq_prod;
76580 +extern atomic_unchecked_t rdma_stat_sq_poll;
76581 +extern atomic_unchecked_t rdma_stat_sq_prod;
76582
76583 #define RPCRDMA_VERSION 1
76584
76585 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
76586 index 8d71d65..f79586e 100644
76587 --- a/include/linux/sunrpc/svcauth.h
76588 +++ b/include/linux/sunrpc/svcauth.h
76589 @@ -120,7 +120,7 @@ struct auth_ops {
76590 int (*release)(struct svc_rqst *rq);
76591 void (*domain_release)(struct auth_domain *);
76592 int (*set_client)(struct svc_rqst *rq);
76593 -};
76594 +} __do_const;
76595
76596 #define SVC_GARBAGE 1
76597 #define SVC_SYSERR 2
76598 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
76599 index a5ffd32..0935dea 100644
76600 --- a/include/linux/swiotlb.h
76601 +++ b/include/linux/swiotlb.h
76602 @@ -60,7 +60,8 @@ extern void
76603
76604 extern void
76605 swiotlb_free_coherent(struct device *hwdev, size_t size,
76606 - void *vaddr, dma_addr_t dma_handle);
76607 + void *vaddr, dma_addr_t dma_handle,
76608 + struct dma_attrs *attrs);
76609
76610 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
76611 unsigned long offset, size_t size,
76612 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
76613 index 84662ec..5271947 100644
76614 --- a/include/linux/syscalls.h
76615 +++ b/include/linux/syscalls.h
76616 @@ -97,8 +97,14 @@ struct sigaltstack;
76617 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
76618
76619 #define __SC_DECL(t, a) t a
76620 +#define __TYPE_IS_U(t) (__same_type((t)0, 0UL) || __same_type((t)0, 0U) || __same_type((t)0, (unsigned short)0) || __same_type((t)0, (unsigned char)0))
76621 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
76622 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
76623 +#define __SC_LONG(t, a) __typeof( \
76624 + __builtin_choose_expr( \
76625 + sizeof(t) > sizeof(int), \
76626 + (t) 0, \
76627 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
76628 + )) a
76629 #define __SC_CAST(t, a) (t) a
76630 #define __SC_ARGS(t, a) a
76631 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
76632 @@ -362,11 +368,11 @@ asmlinkage long sys_sync(void);
76633 asmlinkage long sys_fsync(unsigned int fd);
76634 asmlinkage long sys_fdatasync(unsigned int fd);
76635 asmlinkage long sys_bdflush(int func, long data);
76636 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
76637 - char __user *type, unsigned long flags,
76638 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
76639 + const char __user *type, unsigned long flags,
76640 void __user *data);
76641 -asmlinkage long sys_umount(char __user *name, int flags);
76642 -asmlinkage long sys_oldumount(char __user *name);
76643 +asmlinkage long sys_umount(const char __user *name, int flags);
76644 +asmlinkage long sys_oldumount(const char __user *name);
76645 asmlinkage long sys_truncate(const char __user *path, long length);
76646 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
76647 asmlinkage long sys_stat(const char __user *filename,
76648 @@ -578,7 +584,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
76649 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
76650 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
76651 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
76652 - struct sockaddr __user *, int);
76653 + struct sockaddr __user *, int) __intentional_overflow(0);
76654 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
76655 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
76656 unsigned int vlen, unsigned flags);
76657 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
76658 index 27b3b0b..e093dd9 100644
76659 --- a/include/linux/syscore_ops.h
76660 +++ b/include/linux/syscore_ops.h
76661 @@ -16,7 +16,7 @@ struct syscore_ops {
76662 int (*suspend)(void);
76663 void (*resume)(void);
76664 void (*shutdown)(void);
76665 -};
76666 +} __do_const;
76667
76668 extern void register_syscore_ops(struct syscore_ops *ops);
76669 extern void unregister_syscore_ops(struct syscore_ops *ops);
76670 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
76671 index 14a8ff2..af52bad 100644
76672 --- a/include/linux/sysctl.h
76673 +++ b/include/linux/sysctl.h
76674 @@ -34,13 +34,13 @@ struct ctl_table_root;
76675 struct ctl_table_header;
76676 struct ctl_dir;
76677
76678 -typedef struct ctl_table ctl_table;
76679 -
76680 typedef int proc_handler (struct ctl_table *ctl, int write,
76681 void __user *buffer, size_t *lenp, loff_t *ppos);
76682
76683 extern int proc_dostring(struct ctl_table *, int,
76684 void __user *, size_t *, loff_t *);
76685 +extern int proc_dostring_modpriv(struct ctl_table *, int,
76686 + void __user *, size_t *, loff_t *);
76687 extern int proc_dointvec(struct ctl_table *, int,
76688 void __user *, size_t *, loff_t *);
76689 extern int proc_dointvec_minmax(struct ctl_table *, int,
76690 @@ -115,7 +115,9 @@ struct ctl_table
76691 struct ctl_table_poll *poll;
76692 void *extra1;
76693 void *extra2;
76694 -};
76695 +} __do_const;
76696 +typedef struct ctl_table __no_const ctl_table_no_const;
76697 +typedef struct ctl_table ctl_table;
76698
76699 struct ctl_node {
76700 struct rb_node node;
76701 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
76702 index 9e8a9b5..753de68 100644
76703 --- a/include/linux/sysfs.h
76704 +++ b/include/linux/sysfs.h
76705 @@ -33,7 +33,8 @@ struct attribute {
76706 struct lock_class_key *key;
76707 struct lock_class_key skey;
76708 #endif
76709 -};
76710 +} __do_const;
76711 +typedef struct attribute __no_const attribute_no_const;
76712
76713 /**
76714 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
76715 @@ -62,7 +63,8 @@ struct attribute_group {
76716 struct attribute *, int);
76717 struct attribute **attrs;
76718 struct bin_attribute **bin_attrs;
76719 -};
76720 +} __do_const;
76721 +typedef struct attribute_group __no_const attribute_group_no_const;
76722
76723 /**
76724 * Use these macros to make defining attributes easier. See include/linux/device.h
76725 @@ -123,7 +125,8 @@ struct bin_attribute {
76726 char *, loff_t, size_t);
76727 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
76728 struct vm_area_struct *vma);
76729 -};
76730 +} __do_const;
76731 +typedef struct bin_attribute __no_const bin_attribute_no_const;
76732
76733 /**
76734 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
76735 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
76736 index 7faf933..9b85a0c 100644
76737 --- a/include/linux/sysrq.h
76738 +++ b/include/linux/sysrq.h
76739 @@ -16,6 +16,7 @@
76740
76741 #include <linux/errno.h>
76742 #include <linux/types.h>
76743 +#include <linux/compiler.h>
76744
76745 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
76746 #define SYSRQ_DEFAULT_ENABLE 1
76747 @@ -36,7 +37,7 @@ struct sysrq_key_op {
76748 char *help_msg;
76749 char *action_msg;
76750 int enable_mask;
76751 -};
76752 +} __do_const;
76753
76754 #ifdef CONFIG_MAGIC_SYSRQ
76755
76756 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
76757 index e7e0473..7989295 100644
76758 --- a/include/linux/thread_info.h
76759 +++ b/include/linux/thread_info.h
76760 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
76761 #error "no set_restore_sigmask() provided and default one won't work"
76762 #endif
76763
76764 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
76765 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
76766 +{
76767 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
76768 + if (!__builtin_constant_p(n))
76769 +#endif
76770 + __check_object_size(ptr, n, to_user);
76771 +}
76772 +
76773 #endif /* __KERNEL__ */
76774
76775 #endif /* _LINUX_THREAD_INFO_H */
76776 diff --git a/include/linux/tty.h b/include/linux/tty.h
76777 index 01ac30e..bf18a71 100644
76778 --- a/include/linux/tty.h
76779 +++ b/include/linux/tty.h
76780 @@ -194,7 +194,7 @@ struct tty_port {
76781 const struct tty_port_operations *ops; /* Port operations */
76782 spinlock_t lock; /* Lock protecting tty field */
76783 int blocked_open; /* Waiting to open */
76784 - int count; /* Usage count */
76785 + atomic_t count; /* Usage count */
76786 wait_queue_head_t open_wait; /* Open waiters */
76787 wait_queue_head_t close_wait; /* Close waiters */
76788 wait_queue_head_t delta_msr_wait; /* Modem status change */
76789 @@ -547,7 +547,7 @@ extern int tty_port_open(struct tty_port *port,
76790 struct tty_struct *tty, struct file *filp);
76791 static inline int tty_port_users(struct tty_port *port)
76792 {
76793 - return port->count + port->blocked_open;
76794 + return atomic_read(&port->count) + port->blocked_open;
76795 }
76796
76797 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
76798 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
76799 index 756a609..b302dd6 100644
76800 --- a/include/linux/tty_driver.h
76801 +++ b/include/linux/tty_driver.h
76802 @@ -285,7 +285,7 @@ struct tty_operations {
76803 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
76804 #endif
76805 const struct file_operations *proc_fops;
76806 -};
76807 +} __do_const;
76808
76809 struct tty_driver {
76810 int magic; /* magic number for this structure */
76811 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
76812 index a1b0489..f02e17c 100644
76813 --- a/include/linux/tty_ldisc.h
76814 +++ b/include/linux/tty_ldisc.h
76815 @@ -198,7 +198,7 @@ struct tty_ldisc_ops {
76816
76817 struct module *owner;
76818
76819 - int refcount;
76820 + atomic_t refcount;
76821 };
76822
76823 struct tty_ldisc {
76824 diff --git a/include/linux/types.h b/include/linux/types.h
76825 index 4d118ba..c3ee9bf 100644
76826 --- a/include/linux/types.h
76827 +++ b/include/linux/types.h
76828 @@ -176,10 +176,26 @@ typedef struct {
76829 int counter;
76830 } atomic_t;
76831
76832 +#ifdef CONFIG_PAX_REFCOUNT
76833 +typedef struct {
76834 + int counter;
76835 +} atomic_unchecked_t;
76836 +#else
76837 +typedef atomic_t atomic_unchecked_t;
76838 +#endif
76839 +
76840 #ifdef CONFIG_64BIT
76841 typedef struct {
76842 long counter;
76843 } atomic64_t;
76844 +
76845 +#ifdef CONFIG_PAX_REFCOUNT
76846 +typedef struct {
76847 + long counter;
76848 +} atomic64_unchecked_t;
76849 +#else
76850 +typedef atomic64_t atomic64_unchecked_t;
76851 +#endif
76852 #endif
76853
76854 struct list_head {
76855 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
76856 index 5ca0951..ab496a5 100644
76857 --- a/include/linux/uaccess.h
76858 +++ b/include/linux/uaccess.h
76859 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
76860 long ret; \
76861 mm_segment_t old_fs = get_fs(); \
76862 \
76863 - set_fs(KERNEL_DS); \
76864 pagefault_disable(); \
76865 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
76866 - pagefault_enable(); \
76867 + set_fs(KERNEL_DS); \
76868 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
76869 set_fs(old_fs); \
76870 + pagefault_enable(); \
76871 ret; \
76872 })
76873
76874 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
76875 index 8e522cbc..aa8572d 100644
76876 --- a/include/linux/uidgid.h
76877 +++ b/include/linux/uidgid.h
76878 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
76879
76880 #endif /* CONFIG_USER_NS */
76881
76882 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
76883 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
76884 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
76885 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
76886 +
76887 #endif /* _LINUX_UIDGID_H */
76888 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
76889 index 99c1b4d..562e6f3 100644
76890 --- a/include/linux/unaligned/access_ok.h
76891 +++ b/include/linux/unaligned/access_ok.h
76892 @@ -4,34 +4,34 @@
76893 #include <linux/kernel.h>
76894 #include <asm/byteorder.h>
76895
76896 -static inline u16 get_unaligned_le16(const void *p)
76897 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
76898 {
76899 - return le16_to_cpup((__le16 *)p);
76900 + return le16_to_cpup((const __le16 *)p);
76901 }
76902
76903 -static inline u32 get_unaligned_le32(const void *p)
76904 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
76905 {
76906 - return le32_to_cpup((__le32 *)p);
76907 + return le32_to_cpup((const __le32 *)p);
76908 }
76909
76910 -static inline u64 get_unaligned_le64(const void *p)
76911 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
76912 {
76913 - return le64_to_cpup((__le64 *)p);
76914 + return le64_to_cpup((const __le64 *)p);
76915 }
76916
76917 -static inline u16 get_unaligned_be16(const void *p)
76918 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
76919 {
76920 - return be16_to_cpup((__be16 *)p);
76921 + return be16_to_cpup((const __be16 *)p);
76922 }
76923
76924 -static inline u32 get_unaligned_be32(const void *p)
76925 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
76926 {
76927 - return be32_to_cpup((__be32 *)p);
76928 + return be32_to_cpup((const __be32 *)p);
76929 }
76930
76931 -static inline u64 get_unaligned_be64(const void *p)
76932 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
76933 {
76934 - return be64_to_cpup((__be64 *)p);
76935 + return be64_to_cpup((const __be64 *)p);
76936 }
76937
76938 static inline void put_unaligned_le16(u16 val, void *p)
76939 diff --git a/include/linux/usb.h b/include/linux/usb.h
76940 index 0eec268..4496526 100644
76941 --- a/include/linux/usb.h
76942 +++ b/include/linux/usb.h
76943 @@ -560,7 +560,7 @@ struct usb_device {
76944 int maxchild;
76945
76946 u32 quirks;
76947 - atomic_t urbnum;
76948 + atomic_unchecked_t urbnum;
76949
76950 unsigned long active_duration;
76951
76952 @@ -1617,7 +1617,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
76953
76954 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
76955 __u8 request, __u8 requesttype, __u16 value, __u16 index,
76956 - void *data, __u16 size, int timeout);
76957 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
76958 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
76959 void *data, int len, int *actual_length, int timeout);
76960 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
76961 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
76962 index e452ba6..78f8e80 100644
76963 --- a/include/linux/usb/renesas_usbhs.h
76964 +++ b/include/linux/usb/renesas_usbhs.h
76965 @@ -39,7 +39,7 @@ enum {
76966 */
76967 struct renesas_usbhs_driver_callback {
76968 int (*notify_hotplug)(struct platform_device *pdev);
76969 -};
76970 +} __no_const;
76971
76972 /*
76973 * callback functions for platform
76974 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
76975 index 6f8fbcf..8259001 100644
76976 --- a/include/linux/vermagic.h
76977 +++ b/include/linux/vermagic.h
76978 @@ -25,9 +25,35 @@
76979 #define MODULE_ARCH_VERMAGIC ""
76980 #endif
76981
76982 +#ifdef CONFIG_PAX_REFCOUNT
76983 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
76984 +#else
76985 +#define MODULE_PAX_REFCOUNT ""
76986 +#endif
76987 +
76988 +#ifdef CONSTIFY_PLUGIN
76989 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
76990 +#else
76991 +#define MODULE_CONSTIFY_PLUGIN ""
76992 +#endif
76993 +
76994 +#ifdef STACKLEAK_PLUGIN
76995 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
76996 +#else
76997 +#define MODULE_STACKLEAK_PLUGIN ""
76998 +#endif
76999 +
77000 +#ifdef CONFIG_GRKERNSEC
77001 +#define MODULE_GRSEC "GRSEC "
77002 +#else
77003 +#define MODULE_GRSEC ""
77004 +#endif
77005 +
77006 #define VERMAGIC_STRING \
77007 UTS_RELEASE " " \
77008 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
77009 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
77010 - MODULE_ARCH_VERMAGIC
77011 + MODULE_ARCH_VERMAGIC \
77012 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
77013 + MODULE_GRSEC
77014
77015 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
77016 index 4b8a891..c20e936 100644
77017 --- a/include/linux/vmalloc.h
77018 +++ b/include/linux/vmalloc.h
77019 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
77020 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
77021 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
77022 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
77023 +
77024 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
77025 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
77026 +#endif
77027 +
77028 /* bits [20..32] reserved for arch specific ioremap internals */
77029
77030 /*
77031 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
77032 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
77033 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
77034 unsigned long start, unsigned long end, gfp_t gfp_mask,
77035 - pgprot_t prot, int node, const void *caller);
77036 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
77037 extern void vfree(const void *addr);
77038
77039 extern void *vmap(struct page **pages, unsigned int count,
77040 @@ -141,8 +146,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
77041 extern void free_vm_area(struct vm_struct *area);
77042
77043 /* for /dev/kmem */
77044 -extern long vread(char *buf, char *addr, unsigned long count);
77045 -extern long vwrite(char *buf, char *addr, unsigned long count);
77046 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
77047 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
77048
77049 /*
77050 * Internals. Dont't use..
77051 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
77052 index c586679..f06b389 100644
77053 --- a/include/linux/vmstat.h
77054 +++ b/include/linux/vmstat.h
77055 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
77056 /*
77057 * Zone based page accounting with per cpu differentials.
77058 */
77059 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77060 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77061
77062 static inline void zone_page_state_add(long x, struct zone *zone,
77063 enum zone_stat_item item)
77064 {
77065 - atomic_long_add(x, &zone->vm_stat[item]);
77066 - atomic_long_add(x, &vm_stat[item]);
77067 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
77068 + atomic_long_add_unchecked(x, &vm_stat[item]);
77069 }
77070
77071 static inline unsigned long global_page_state(enum zone_stat_item item)
77072 {
77073 - long x = atomic_long_read(&vm_stat[item]);
77074 + long x = atomic_long_read_unchecked(&vm_stat[item]);
77075 #ifdef CONFIG_SMP
77076 if (x < 0)
77077 x = 0;
77078 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
77079 static inline unsigned long zone_page_state(struct zone *zone,
77080 enum zone_stat_item item)
77081 {
77082 - long x = atomic_long_read(&zone->vm_stat[item]);
77083 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77084 #ifdef CONFIG_SMP
77085 if (x < 0)
77086 x = 0;
77087 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
77088 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
77089 enum zone_stat_item item)
77090 {
77091 - long x = atomic_long_read(&zone->vm_stat[item]);
77092 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77093
77094 #ifdef CONFIG_SMP
77095 int cpu;
77096 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
77097
77098 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
77099 {
77100 - atomic_long_inc(&zone->vm_stat[item]);
77101 - atomic_long_inc(&vm_stat[item]);
77102 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
77103 + atomic_long_inc_unchecked(&vm_stat[item]);
77104 }
77105
77106 static inline void __inc_zone_page_state(struct page *page,
77107 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
77108
77109 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
77110 {
77111 - atomic_long_dec(&zone->vm_stat[item]);
77112 - atomic_long_dec(&vm_stat[item]);
77113 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
77114 + atomic_long_dec_unchecked(&vm_stat[item]);
77115 }
77116
77117 static inline void __dec_zone_page_state(struct page *page,
77118 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
77119 index fdbafc6..49dfe4f 100644
77120 --- a/include/linux/xattr.h
77121 +++ b/include/linux/xattr.h
77122 @@ -28,7 +28,7 @@ struct xattr_handler {
77123 size_t size, int handler_flags);
77124 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
77125 size_t size, int flags, int handler_flags);
77126 -};
77127 +} __do_const;
77128
77129 struct xattr {
77130 char *name;
77131 @@ -37,6 +37,9 @@ struct xattr {
77132 };
77133
77134 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
77135 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
77136 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
77137 +#endif
77138 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
77139 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
77140 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
77141 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
77142 index 9c5a6b4..09c9438 100644
77143 --- a/include/linux/zlib.h
77144 +++ b/include/linux/zlib.h
77145 @@ -31,6 +31,7 @@
77146 #define _ZLIB_H
77147
77148 #include <linux/zconf.h>
77149 +#include <linux/compiler.h>
77150
77151 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
77152 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
77153 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
77154
77155 /* basic functions */
77156
77157 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
77158 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
77159 /*
77160 Returns the number of bytes that needs to be allocated for a per-
77161 stream workspace with the specified parameters. A pointer to this
77162 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
77163 index c768c9f..bdcaa5a 100644
77164 --- a/include/media/v4l2-dev.h
77165 +++ b/include/media/v4l2-dev.h
77166 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
77167 int (*mmap) (struct file *, struct vm_area_struct *);
77168 int (*open) (struct file *);
77169 int (*release) (struct file *);
77170 -};
77171 +} __do_const;
77172
77173 /*
77174 * Newer version of video_device, handled by videodev2.c
77175 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
77176 index c9b1593..a572459 100644
77177 --- a/include/media/v4l2-device.h
77178 +++ b/include/media/v4l2-device.h
77179 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
77180 this function returns 0. If the name ends with a digit (e.g. cx18),
77181 then the name will be set to cx18-0 since cx180 looks really odd. */
77182 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
77183 - atomic_t *instance);
77184 + atomic_unchecked_t *instance);
77185
77186 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
77187 Since the parent disappears this ensures that v4l2_dev doesn't have an
77188 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
77189 index d9fa68f..45c88d1 100644
77190 --- a/include/net/9p/transport.h
77191 +++ b/include/net/9p/transport.h
77192 @@ -63,7 +63,7 @@ struct p9_trans_module {
77193 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
77194 int (*zc_request)(struct p9_client *, struct p9_req_t *,
77195 char *, char *, int , int, int, int);
77196 -};
77197 +} __do_const;
77198
77199 void v9fs_register_trans(struct p9_trans_module *m);
77200 void v9fs_unregister_trans(struct p9_trans_module *m);
77201 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
77202 index 1a966af..2767cf6 100644
77203 --- a/include/net/bluetooth/l2cap.h
77204 +++ b/include/net/bluetooth/l2cap.h
77205 @@ -551,7 +551,7 @@ struct l2cap_ops {
77206 void (*defer) (struct l2cap_chan *chan);
77207 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
77208 unsigned long len, int nb);
77209 -};
77210 +} __do_const;
77211
77212 struct l2cap_conn {
77213 struct hci_conn *hcon;
77214 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
77215 index f2ae33d..c457cf0 100644
77216 --- a/include/net/caif/cfctrl.h
77217 +++ b/include/net/caif/cfctrl.h
77218 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
77219 void (*radioset_rsp)(void);
77220 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
77221 struct cflayer *client_layer);
77222 -};
77223 +} __no_const;
77224
77225 /* Link Setup Parameters for CAIF-Links. */
77226 struct cfctrl_link_param {
77227 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
77228 struct cfctrl {
77229 struct cfsrvl serv;
77230 struct cfctrl_rsp res;
77231 - atomic_t req_seq_no;
77232 - atomic_t rsp_seq_no;
77233 + atomic_unchecked_t req_seq_no;
77234 + atomic_unchecked_t rsp_seq_no;
77235 struct list_head list;
77236 /* Protects from simultaneous access to first_req list */
77237 spinlock_t info_list_lock;
77238 diff --git a/include/net/flow.h b/include/net/flow.h
77239 index 628e11b..4c475df 100644
77240 --- a/include/net/flow.h
77241 +++ b/include/net/flow.h
77242 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
77243
77244 extern void flow_cache_flush(void);
77245 extern void flow_cache_flush_deferred(void);
77246 -extern atomic_t flow_cache_genid;
77247 +extern atomic_unchecked_t flow_cache_genid;
77248
77249 #endif
77250 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
77251 index 8e0b6c8..73cf605 100644
77252 --- a/include/net/genetlink.h
77253 +++ b/include/net/genetlink.h
77254 @@ -120,7 +120,7 @@ struct genl_ops {
77255 struct netlink_callback *cb);
77256 int (*done)(struct netlink_callback *cb);
77257 struct list_head ops_list;
77258 -};
77259 +} __do_const;
77260
77261 extern int __genl_register_family(struct genl_family *family);
77262
77263 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
77264 index 734d9b5..48a9a4b 100644
77265 --- a/include/net/gro_cells.h
77266 +++ b/include/net/gro_cells.h
77267 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
77268 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
77269
77270 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
77271 - atomic_long_inc(&dev->rx_dropped);
77272 + atomic_long_inc_unchecked(&dev->rx_dropped);
77273 kfree_skb(skb);
77274 return;
77275 }
77276 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
77277 index de2c785..0588a6b 100644
77278 --- a/include/net/inet_connection_sock.h
77279 +++ b/include/net/inet_connection_sock.h
77280 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
77281 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
77282 int (*bind_conflict)(const struct sock *sk,
77283 const struct inet_bind_bucket *tb, bool relax);
77284 -};
77285 +} __do_const;
77286
77287 /** inet_connection_sock - INET connection oriented sock
77288 *
77289 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
77290 index 53f464d..0bd0b49 100644
77291 --- a/include/net/inetpeer.h
77292 +++ b/include/net/inetpeer.h
77293 @@ -47,8 +47,8 @@ struct inet_peer {
77294 */
77295 union {
77296 struct {
77297 - atomic_t rid; /* Frag reception counter */
77298 - atomic_t ip_id_count; /* IP ID for the next packet */
77299 + atomic_unchecked_t rid; /* Frag reception counter */
77300 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
77301 };
77302 struct rcu_head rcu;
77303 struct inet_peer *gc_next;
77304 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
77305 /* can be called with or without local BH being disabled */
77306 static inline int inet_getid(struct inet_peer *p, int more)
77307 {
77308 - int old, new;
77309 + int id;
77310 more++;
77311 inet_peer_refcheck(p);
77312 - do {
77313 - old = atomic_read(&p->ip_id_count);
77314 - new = old + more;
77315 - if (!new)
77316 - new = 1;
77317 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
77318 - return new;
77319 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
77320 + if (!id)
77321 + id = atomic_inc_return_unchecked(&p->ip_id_count);
77322 + return id;
77323 }
77324
77325 #endif /* _NET_INETPEER_H */
77326 diff --git a/include/net/ip.h b/include/net/ip.h
77327 index a68f838..74518ab 100644
77328 --- a/include/net/ip.h
77329 +++ b/include/net/ip.h
77330 @@ -202,7 +202,7 @@ extern struct local_ports {
77331 } sysctl_local_ports;
77332 extern void inet_get_local_port_range(int *low, int *high);
77333
77334 -extern unsigned long *sysctl_local_reserved_ports;
77335 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
77336 static inline int inet_is_reserved_local_port(int port)
77337 {
77338 return test_bit(port, sysctl_local_reserved_ports);
77339 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
77340 index cbf2be3..3683f6d 100644
77341 --- a/include/net/ip_fib.h
77342 +++ b/include/net/ip_fib.h
77343 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
77344
77345 #define FIB_RES_SADDR(net, res) \
77346 ((FIB_RES_NH(res).nh_saddr_genid == \
77347 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
77348 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
77349 FIB_RES_NH(res).nh_saddr : \
77350 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
77351 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
77352 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
77353 index f0d70f0..185f15b 100644
77354 --- a/include/net/ip_vs.h
77355 +++ b/include/net/ip_vs.h
77356 @@ -588,7 +588,7 @@ struct ip_vs_conn {
77357 struct ip_vs_conn *control; /* Master control connection */
77358 atomic_t n_control; /* Number of controlled ones */
77359 struct ip_vs_dest *dest; /* real server */
77360 - atomic_t in_pkts; /* incoming packet counter */
77361 + atomic_unchecked_t in_pkts; /* incoming packet counter */
77362
77363 /* packet transmitter for different forwarding methods. If it
77364 mangles the packet, it must return NF_DROP or better NF_STOLEN,
77365 @@ -737,7 +737,7 @@ struct ip_vs_dest {
77366 __be16 port; /* port number of the server */
77367 union nf_inet_addr addr; /* IP address of the server */
77368 volatile unsigned int flags; /* dest status flags */
77369 - atomic_t conn_flags; /* flags to copy to conn */
77370 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
77371 atomic_t weight; /* server weight */
77372
77373 atomic_t refcnt; /* reference counter */
77374 @@ -993,11 +993,11 @@ struct netns_ipvs {
77375 /* ip_vs_lblc */
77376 int sysctl_lblc_expiration;
77377 struct ctl_table_header *lblc_ctl_header;
77378 - struct ctl_table *lblc_ctl_table;
77379 + ctl_table_no_const *lblc_ctl_table;
77380 /* ip_vs_lblcr */
77381 int sysctl_lblcr_expiration;
77382 struct ctl_table_header *lblcr_ctl_header;
77383 - struct ctl_table *lblcr_ctl_table;
77384 + ctl_table_no_const *lblcr_ctl_table;
77385 /* ip_vs_est */
77386 struct list_head est_list; /* estimator list */
77387 spinlock_t est_lock;
77388 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
77389 index 80ffde3..968b0f4 100644
77390 --- a/include/net/irda/ircomm_tty.h
77391 +++ b/include/net/irda/ircomm_tty.h
77392 @@ -35,6 +35,7 @@
77393 #include <linux/termios.h>
77394 #include <linux/timer.h>
77395 #include <linux/tty.h> /* struct tty_struct */
77396 +#include <asm/local.h>
77397
77398 #include <net/irda/irias_object.h>
77399 #include <net/irda/ircomm_core.h>
77400 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
77401 index 714cc9a..ea05f3e 100644
77402 --- a/include/net/iucv/af_iucv.h
77403 +++ b/include/net/iucv/af_iucv.h
77404 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
77405 struct iucv_sock_list {
77406 struct hlist_head head;
77407 rwlock_t lock;
77408 - atomic_t autobind_name;
77409 + atomic_unchecked_t autobind_name;
77410 };
77411
77412 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
77413 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
77414 index df83f69..9b640b8 100644
77415 --- a/include/net/llc_c_ac.h
77416 +++ b/include/net/llc_c_ac.h
77417 @@ -87,7 +87,7 @@
77418 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
77419 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
77420
77421 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77422 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77423
77424 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
77425 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
77426 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
77427 index 6ca3113..f8026dd 100644
77428 --- a/include/net/llc_c_ev.h
77429 +++ b/include/net/llc_c_ev.h
77430 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
77431 return (struct llc_conn_state_ev *)skb->cb;
77432 }
77433
77434 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77435 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77436 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77437 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77438
77439 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
77440 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
77441 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
77442 index 0e79cfb..f46db31 100644
77443 --- a/include/net/llc_c_st.h
77444 +++ b/include/net/llc_c_st.h
77445 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
77446 u8 next_state;
77447 llc_conn_ev_qfyr_t *ev_qualifiers;
77448 llc_conn_action_t *ev_actions;
77449 -};
77450 +} __do_const;
77451
77452 struct llc_conn_state {
77453 u8 current_state;
77454 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
77455 index 37a3bbd..55a4241 100644
77456 --- a/include/net/llc_s_ac.h
77457 +++ b/include/net/llc_s_ac.h
77458 @@ -23,7 +23,7 @@
77459 #define SAP_ACT_TEST_IND 9
77460
77461 /* All action functions must look like this */
77462 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77463 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
77464
77465 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
77466 struct sk_buff *skb);
77467 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
77468 index 567c681..cd73ac0 100644
77469 --- a/include/net/llc_s_st.h
77470 +++ b/include/net/llc_s_st.h
77471 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
77472 llc_sap_ev_t ev;
77473 u8 next_state;
77474 llc_sap_action_t *ev_actions;
77475 -};
77476 +} __do_const;
77477
77478 struct llc_sap_state {
77479 u8 curr_state;
77480 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
77481 index 551ba6a..11c99c1 100644
77482 --- a/include/net/mac80211.h
77483 +++ b/include/net/mac80211.h
77484 @@ -4221,7 +4221,7 @@ struct rate_control_ops {
77485 void (*add_sta_debugfs)(void *priv, void *priv_sta,
77486 struct dentry *dir);
77487 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
77488 -};
77489 +} __do_const;
77490
77491 static inline int rate_supported(struct ieee80211_sta *sta,
77492 enum ieee80211_band band,
77493 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
77494 index 7e748ad..5c6229b 100644
77495 --- a/include/net/neighbour.h
77496 +++ b/include/net/neighbour.h
77497 @@ -123,7 +123,7 @@ struct neigh_ops {
77498 void (*error_report)(struct neighbour *, struct sk_buff *);
77499 int (*output)(struct neighbour *, struct sk_buff *);
77500 int (*connected_output)(struct neighbour *, struct sk_buff *);
77501 -};
77502 +} __do_const;
77503
77504 struct pneigh_entry {
77505 struct pneigh_entry *next;
77506 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
77507 index 84e37b1..8eba19a 100644
77508 --- a/include/net/net_namespace.h
77509 +++ b/include/net/net_namespace.h
77510 @@ -119,8 +119,8 @@ struct net {
77511 struct netns_ipvs *ipvs;
77512 #endif
77513 struct sock *diag_nlsk;
77514 - atomic_t rt_genid;
77515 - atomic_t fnhe_genid;
77516 + atomic_unchecked_t rt_genid;
77517 + atomic_unchecked_t fnhe_genid;
77518 };
77519
77520 /*
77521 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
77522 #define __net_init __init
77523 #define __net_exit __exit_refok
77524 #define __net_initdata __initdata
77525 +#ifdef CONSTIFY_PLUGIN
77526 #define __net_initconst __initconst
77527 +#else
77528 +#define __net_initconst __initdata
77529 +#endif
77530 #endif
77531
77532 struct pernet_operations {
77533 @@ -287,7 +291,7 @@ struct pernet_operations {
77534 void (*exit_batch)(struct list_head *net_exit_list);
77535 int *id;
77536 size_t size;
77537 -};
77538 +} __do_const;
77539
77540 /*
77541 * Use these carefully. If you implement a network device and it
77542 @@ -335,22 +339,22 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
77543
77544 static inline int rt_genid(struct net *net)
77545 {
77546 - return atomic_read(&net->rt_genid);
77547 + return atomic_read_unchecked(&net->rt_genid);
77548 }
77549
77550 static inline void rt_genid_bump(struct net *net)
77551 {
77552 - atomic_inc(&net->rt_genid);
77553 + atomic_inc_unchecked(&net->rt_genid);
77554 }
77555
77556 static inline int fnhe_genid(struct net *net)
77557 {
77558 - return atomic_read(&net->fnhe_genid);
77559 + return atomic_read_unchecked(&net->fnhe_genid);
77560 }
77561
77562 static inline void fnhe_genid_bump(struct net *net)
77563 {
77564 - atomic_inc(&net->fnhe_genid);
77565 + atomic_inc_unchecked(&net->fnhe_genid);
77566 }
77567
77568 #endif /* __NET_NET_NAMESPACE_H */
77569 diff --git a/include/net/netdma.h b/include/net/netdma.h
77570 index 8ba8ce2..99b7fff 100644
77571 --- a/include/net/netdma.h
77572 +++ b/include/net/netdma.h
77573 @@ -24,7 +24,7 @@
77574 #include <linux/dmaengine.h>
77575 #include <linux/skbuff.h>
77576
77577 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
77578 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
77579 struct sk_buff *skb, int offset, struct iovec *to,
77580 size_t len, struct dma_pinned_list *pinned_list);
77581
77582 diff --git a/include/net/netlink.h b/include/net/netlink.h
77583 index 9690b0f..87aded7 100644
77584 --- a/include/net/netlink.h
77585 +++ b/include/net/netlink.h
77586 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
77587 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
77588 {
77589 if (mark)
77590 - skb_trim(skb, (unsigned char *) mark - skb->data);
77591 + skb_trim(skb, (const unsigned char *) mark - skb->data);
77592 }
77593
77594 /**
77595 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
77596 index c9c0c53..53f24c3 100644
77597 --- a/include/net/netns/conntrack.h
77598 +++ b/include/net/netns/conntrack.h
77599 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
77600 struct nf_proto_net {
77601 #ifdef CONFIG_SYSCTL
77602 struct ctl_table_header *ctl_table_header;
77603 - struct ctl_table *ctl_table;
77604 + ctl_table_no_const *ctl_table;
77605 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
77606 struct ctl_table_header *ctl_compat_header;
77607 - struct ctl_table *ctl_compat_table;
77608 + ctl_table_no_const *ctl_compat_table;
77609 #endif
77610 #endif
77611 unsigned int users;
77612 @@ -58,7 +58,7 @@ struct nf_ip_net {
77613 struct nf_icmp_net icmpv6;
77614 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
77615 struct ctl_table_header *ctl_table_header;
77616 - struct ctl_table *ctl_table;
77617 + ctl_table_no_const *ctl_table;
77618 #endif
77619 };
77620
77621 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
77622 index 2ba9de8..47bd6c7 100644
77623 --- a/include/net/netns/ipv4.h
77624 +++ b/include/net/netns/ipv4.h
77625 @@ -67,7 +67,7 @@ struct netns_ipv4 {
77626 kgid_t sysctl_ping_group_range[2];
77627 long sysctl_tcp_mem[3];
77628
77629 - atomic_t dev_addr_genid;
77630 + atomic_unchecked_t dev_addr_genid;
77631
77632 #ifdef CONFIG_IP_MROUTE
77633 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
77634 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
77635 index 005e2c2..023d340 100644
77636 --- a/include/net/netns/ipv6.h
77637 +++ b/include/net/netns/ipv6.h
77638 @@ -71,7 +71,7 @@ struct netns_ipv6 {
77639 struct fib_rules_ops *mr6_rules_ops;
77640 #endif
77641 #endif
77642 - atomic_t dev_addr_genid;
77643 + atomic_unchecked_t dev_addr_genid;
77644 };
77645
77646 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
77647 diff --git a/include/net/ping.h b/include/net/ping.h
77648 index 5db0224..0d65365 100644
77649 --- a/include/net/ping.h
77650 +++ b/include/net/ping.h
77651 @@ -55,7 +55,7 @@ struct ping_iter_state {
77652 extern struct proto ping_prot;
77653 extern struct ping_table ping_table;
77654 #if IS_ENABLED(CONFIG_IPV6)
77655 -extern struct pingv6_ops pingv6_ops;
77656 +extern struct pingv6_ops *pingv6_ops;
77657 #endif
77658
77659 struct pingfakehdr {
77660 diff --git a/include/net/protocol.h b/include/net/protocol.h
77661 index 047c047..b9dad15 100644
77662 --- a/include/net/protocol.h
77663 +++ b/include/net/protocol.h
77664 @@ -44,7 +44,7 @@ struct net_protocol {
77665 void (*err_handler)(struct sk_buff *skb, u32 info);
77666 unsigned int no_policy:1,
77667 netns_ok:1;
77668 -};
77669 +} __do_const;
77670
77671 #if IS_ENABLED(CONFIG_IPV6)
77672 struct inet6_protocol {
77673 @@ -57,7 +57,7 @@ struct inet6_protocol {
77674 u8 type, u8 code, int offset,
77675 __be32 info);
77676 unsigned int flags; /* INET6_PROTO_xxx */
77677 -};
77678 +} __do_const;
77679
77680 #define INET6_PROTO_NOPOLICY 0x1
77681 #define INET6_PROTO_FINAL 0x2
77682 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
77683 index 7026648..584cc8c 100644
77684 --- a/include/net/rtnetlink.h
77685 +++ b/include/net/rtnetlink.h
77686 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
77687 const struct net_device *dev);
77688 unsigned int (*get_num_tx_queues)(void);
77689 unsigned int (*get_num_rx_queues)(void);
77690 -};
77691 +} __do_const;
77692
77693 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
77694 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
77695 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
77696 index 2a82d13..62a31c2 100644
77697 --- a/include/net/sctp/sm.h
77698 +++ b/include/net/sctp/sm.h
77699 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
77700 typedef struct {
77701 sctp_state_fn_t *fn;
77702 const char *name;
77703 -} sctp_sm_table_entry_t;
77704 +} __do_const sctp_sm_table_entry_t;
77705
77706 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
77707 * currently in use.
77708 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
77709 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
77710
77711 /* Extern declarations for major data structures. */
77712 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
77713 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
77714
77715
77716 /* Get the size of a DATA chunk payload. */
77717 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
77718 index e745c92..3641448 100644
77719 --- a/include/net/sctp/structs.h
77720 +++ b/include/net/sctp/structs.h
77721 @@ -516,7 +516,7 @@ struct sctp_pf {
77722 struct sctp_association *asoc);
77723 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
77724 struct sctp_af *af;
77725 -};
77726 +} __do_const;
77727
77728
77729 /* Structure to track chunk fragments that have been acked, but peer
77730 diff --git a/include/net/sock.h b/include/net/sock.h
77731 index 31d5cfb..9ee0602 100644
77732 --- a/include/net/sock.h
77733 +++ b/include/net/sock.h
77734 @@ -331,7 +331,7 @@ struct sock {
77735 unsigned int sk_napi_id;
77736 unsigned int sk_ll_usec;
77737 #endif
77738 - atomic_t sk_drops;
77739 + atomic_unchecked_t sk_drops;
77740 int sk_rcvbuf;
77741
77742 struct sk_filter __rcu *sk_filter;
77743 @@ -1803,7 +1803,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
77744 }
77745
77746 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
77747 - char __user *from, char *to,
77748 + char __user *from, unsigned char *to,
77749 int copy, int offset)
77750 {
77751 if (skb->ip_summed == CHECKSUM_NONE) {
77752 @@ -2065,7 +2065,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
77753 }
77754 }
77755
77756 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
77757 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
77758
77759 /**
77760 * sk_page_frag - return an appropriate page_frag
77761 diff --git a/include/net/tcp.h b/include/net/tcp.h
77762 index d198005..c974a393 100644
77763 --- a/include/net/tcp.h
77764 +++ b/include/net/tcp.h
77765 @@ -521,7 +521,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
77766 extern void tcp_xmit_retransmit_queue(struct sock *);
77767 extern void tcp_simple_retransmit(struct sock *);
77768 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
77769 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
77770 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
77771
77772 extern void tcp_send_probe0(struct sock *);
77773 extern void tcp_send_partial(struct sock *);
77774 @@ -694,8 +694,8 @@ struct tcp_skb_cb {
77775 struct inet6_skb_parm h6;
77776 #endif
77777 } header; /* For incoming frames */
77778 - __u32 seq; /* Starting sequence number */
77779 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
77780 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
77781 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
77782 __u32 when; /* used to compute rtt's */
77783 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
77784
77785 @@ -709,7 +709,7 @@ struct tcp_skb_cb {
77786
77787 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
77788 /* 1 byte hole */
77789 - __u32 ack_seq; /* Sequence number ACK'd */
77790 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
77791 };
77792
77793 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
77794 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
77795 index e823786..53b0608 100644
77796 --- a/include/net/xfrm.h
77797 +++ b/include/net/xfrm.h
77798 @@ -287,7 +287,6 @@ struct xfrm_dst;
77799 struct xfrm_policy_afinfo {
77800 unsigned short family;
77801 struct dst_ops *dst_ops;
77802 - void (*garbage_collect)(struct net *net);
77803 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
77804 const xfrm_address_t *saddr,
77805 const xfrm_address_t *daddr);
77806 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
77807 struct net_device *dev,
77808 const struct flowi *fl);
77809 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
77810 -};
77811 +} __do_const;
77812
77813 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
77814 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
77815 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
77816 int (*transport_finish)(struct sk_buff *skb,
77817 int async);
77818 void (*local_error)(struct sk_buff *skb, u32 mtu);
77819 -};
77820 +} __do_const;
77821
77822 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
77823 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
77824 @@ -427,7 +426,7 @@ struct xfrm_mode {
77825 struct module *owner;
77826 unsigned int encap;
77827 int flags;
77828 -};
77829 +} __do_const;
77830
77831 /* Flags for xfrm_mode. */
77832 enum {
77833 @@ -524,7 +523,7 @@ struct xfrm_policy {
77834 struct timer_list timer;
77835
77836 struct flow_cache_object flo;
77837 - atomic_t genid;
77838 + atomic_unchecked_t genid;
77839 u32 priority;
77840 u32 index;
77841 struct xfrm_mark mark;
77842 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
77843 }
77844
77845 extern void xfrm_garbage_collect(struct net *net);
77846 +extern void xfrm_garbage_collect_deferred(struct net *net);
77847
77848 #else
77849
77850 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
77851 static inline void xfrm_garbage_collect(struct net *net)
77852 {
77853 }
77854 +static inline void xfrm_garbage_collect_deferred(struct net *net)
77855 +{
77856 +}
77857 #endif
77858
77859 static __inline__
77860 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
77861 index 1a046b1..ee0bef0 100644
77862 --- a/include/rdma/iw_cm.h
77863 +++ b/include/rdma/iw_cm.h
77864 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
77865 int backlog);
77866
77867 int (*destroy_listen)(struct iw_cm_id *cm_id);
77868 -};
77869 +} __no_const;
77870
77871 /**
77872 * iw_create_cm_id - Create an IW CM identifier.
77873 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
77874 index e1379b4..67eafbe 100644
77875 --- a/include/scsi/libfc.h
77876 +++ b/include/scsi/libfc.h
77877 @@ -762,6 +762,7 @@ struct libfc_function_template {
77878 */
77879 void (*disc_stop_final) (struct fc_lport *);
77880 };
77881 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
77882
77883 /**
77884 * struct fc_disc - Discovery context
77885 @@ -866,7 +867,7 @@ struct fc_lport {
77886 struct fc_vport *vport;
77887
77888 /* Operational Information */
77889 - struct libfc_function_template tt;
77890 + libfc_function_template_no_const tt;
77891 u8 link_up;
77892 u8 qfull;
77893 enum fc_lport_state state;
77894 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
77895 index a44954c..5da04b2 100644
77896 --- a/include/scsi/scsi_device.h
77897 +++ b/include/scsi/scsi_device.h
77898 @@ -172,9 +172,9 @@ struct scsi_device {
77899 unsigned int max_device_blocked; /* what device_blocked counts down from */
77900 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
77901
77902 - atomic_t iorequest_cnt;
77903 - atomic_t iodone_cnt;
77904 - atomic_t ioerr_cnt;
77905 + atomic_unchecked_t iorequest_cnt;
77906 + atomic_unchecked_t iodone_cnt;
77907 + atomic_unchecked_t ioerr_cnt;
77908
77909 struct device sdev_gendev,
77910 sdev_dev;
77911 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
77912 index b797e8f..8e2c3aa 100644
77913 --- a/include/scsi/scsi_transport_fc.h
77914 +++ b/include/scsi/scsi_transport_fc.h
77915 @@ -751,7 +751,8 @@ struct fc_function_template {
77916 unsigned long show_host_system_hostname:1;
77917
77918 unsigned long disable_target_scan:1;
77919 -};
77920 +} __do_const;
77921 +typedef struct fc_function_template __no_const fc_function_template_no_const;
77922
77923
77924 /**
77925 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
77926 index 9031a26..750d592 100644
77927 --- a/include/sound/compress_driver.h
77928 +++ b/include/sound/compress_driver.h
77929 @@ -128,7 +128,7 @@ struct snd_compr_ops {
77930 struct snd_compr_caps *caps);
77931 int (*get_codec_caps) (struct snd_compr_stream *stream,
77932 struct snd_compr_codec_caps *codec);
77933 -};
77934 +} __no_const;
77935
77936 /**
77937 * struct snd_compr: Compressed device
77938 diff --git a/include/sound/soc.h b/include/sound/soc.h
77939 index 6eabee7..58afb50 100644
77940 --- a/include/sound/soc.h
77941 +++ b/include/sound/soc.h
77942 @@ -783,7 +783,7 @@ struct snd_soc_codec_driver {
77943 /* probe ordering - for components with runtime dependencies */
77944 int probe_order;
77945 int remove_order;
77946 -};
77947 +} __do_const;
77948
77949 /* SoC platform interface */
77950 struct snd_soc_platform_driver {
77951 @@ -829,7 +829,7 @@ struct snd_soc_platform_driver {
77952 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
77953 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
77954 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
77955 -};
77956 +} __do_const;
77957
77958 struct snd_soc_platform {
77959 const char *name;
77960 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
77961 index e34fc90..ecefa2c 100644
77962 --- a/include/target/target_core_base.h
77963 +++ b/include/target/target_core_base.h
77964 @@ -643,7 +643,7 @@ struct se_device {
77965 spinlock_t stats_lock;
77966 /* Active commands on this virtual SE device */
77967 atomic_t simple_cmds;
77968 - atomic_t dev_ordered_id;
77969 + atomic_unchecked_t dev_ordered_id;
77970 atomic_t dev_ordered_sync;
77971 atomic_t dev_qf_count;
77972 int export_count;
77973 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
77974 new file mode 100644
77975 index 0000000..fb634b7
77976 --- /dev/null
77977 +++ b/include/trace/events/fs.h
77978 @@ -0,0 +1,53 @@
77979 +#undef TRACE_SYSTEM
77980 +#define TRACE_SYSTEM fs
77981 +
77982 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
77983 +#define _TRACE_FS_H
77984 +
77985 +#include <linux/fs.h>
77986 +#include <linux/tracepoint.h>
77987 +
77988 +TRACE_EVENT(do_sys_open,
77989 +
77990 + TP_PROTO(const char *filename, int flags, int mode),
77991 +
77992 + TP_ARGS(filename, flags, mode),
77993 +
77994 + TP_STRUCT__entry(
77995 + __string( filename, filename )
77996 + __field( int, flags )
77997 + __field( int, mode )
77998 + ),
77999 +
78000 + TP_fast_assign(
78001 + __assign_str(filename, filename);
78002 + __entry->flags = flags;
78003 + __entry->mode = mode;
78004 + ),
78005 +
78006 + TP_printk("\"%s\" %x %o",
78007 + __get_str(filename), __entry->flags, __entry->mode)
78008 +);
78009 +
78010 +TRACE_EVENT(open_exec,
78011 +
78012 + TP_PROTO(const char *filename),
78013 +
78014 + TP_ARGS(filename),
78015 +
78016 + TP_STRUCT__entry(
78017 + __string( filename, filename )
78018 + ),
78019 +
78020 + TP_fast_assign(
78021 + __assign_str(filename, filename);
78022 + ),
78023 +
78024 + TP_printk("\"%s\"",
78025 + __get_str(filename))
78026 +);
78027 +
78028 +#endif /* _TRACE_FS_H */
78029 +
78030 +/* This part must be outside protection */
78031 +#include <trace/define_trace.h>
78032 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
78033 index 1c09820..7f5ec79 100644
78034 --- a/include/trace/events/irq.h
78035 +++ b/include/trace/events/irq.h
78036 @@ -36,7 +36,7 @@ struct softirq_action;
78037 */
78038 TRACE_EVENT(irq_handler_entry,
78039
78040 - TP_PROTO(int irq, struct irqaction *action),
78041 + TP_PROTO(int irq, const struct irqaction *action),
78042
78043 TP_ARGS(irq, action),
78044
78045 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
78046 */
78047 TRACE_EVENT(irq_handler_exit,
78048
78049 - TP_PROTO(int irq, struct irqaction *action, int ret),
78050 + TP_PROTO(int irq, const struct irqaction *action, int ret),
78051
78052 TP_ARGS(irq, action, ret),
78053
78054 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
78055 index 7caf44c..23c6f27 100644
78056 --- a/include/uapi/linux/a.out.h
78057 +++ b/include/uapi/linux/a.out.h
78058 @@ -39,6 +39,14 @@ enum machine_type {
78059 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
78060 };
78061
78062 +/* Constants for the N_FLAGS field */
78063 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78064 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
78065 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
78066 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
78067 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78068 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78069 +
78070 #if !defined (N_MAGIC)
78071 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
78072 #endif
78073 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
78074 index d876736..ccce5c0 100644
78075 --- a/include/uapi/linux/byteorder/little_endian.h
78076 +++ b/include/uapi/linux/byteorder/little_endian.h
78077 @@ -42,51 +42,51 @@
78078
78079 static inline __le64 __cpu_to_le64p(const __u64 *p)
78080 {
78081 - return (__force __le64)*p;
78082 + return (__force const __le64)*p;
78083 }
78084 -static inline __u64 __le64_to_cpup(const __le64 *p)
78085 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
78086 {
78087 - return (__force __u64)*p;
78088 + return (__force const __u64)*p;
78089 }
78090 static inline __le32 __cpu_to_le32p(const __u32 *p)
78091 {
78092 - return (__force __le32)*p;
78093 + return (__force const __le32)*p;
78094 }
78095 static inline __u32 __le32_to_cpup(const __le32 *p)
78096 {
78097 - return (__force __u32)*p;
78098 + return (__force const __u32)*p;
78099 }
78100 static inline __le16 __cpu_to_le16p(const __u16 *p)
78101 {
78102 - return (__force __le16)*p;
78103 + return (__force const __le16)*p;
78104 }
78105 static inline __u16 __le16_to_cpup(const __le16 *p)
78106 {
78107 - return (__force __u16)*p;
78108 + return (__force const __u16)*p;
78109 }
78110 static inline __be64 __cpu_to_be64p(const __u64 *p)
78111 {
78112 - return (__force __be64)__swab64p(p);
78113 + return (__force const __be64)__swab64p(p);
78114 }
78115 static inline __u64 __be64_to_cpup(const __be64 *p)
78116 {
78117 - return __swab64p((__u64 *)p);
78118 + return __swab64p((const __u64 *)p);
78119 }
78120 static inline __be32 __cpu_to_be32p(const __u32 *p)
78121 {
78122 - return (__force __be32)__swab32p(p);
78123 + return (__force const __be32)__swab32p(p);
78124 }
78125 -static inline __u32 __be32_to_cpup(const __be32 *p)
78126 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
78127 {
78128 - return __swab32p((__u32 *)p);
78129 + return __swab32p((const __u32 *)p);
78130 }
78131 static inline __be16 __cpu_to_be16p(const __u16 *p)
78132 {
78133 - return (__force __be16)__swab16p(p);
78134 + return (__force const __be16)__swab16p(p);
78135 }
78136 static inline __u16 __be16_to_cpup(const __be16 *p)
78137 {
78138 - return __swab16p((__u16 *)p);
78139 + return __swab16p((const __u16 *)p);
78140 }
78141 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
78142 #define __le64_to_cpus(x) do { (void)(x); } while (0)
78143 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
78144 index ef6103b..d4e65dd 100644
78145 --- a/include/uapi/linux/elf.h
78146 +++ b/include/uapi/linux/elf.h
78147 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
78148 #define PT_GNU_EH_FRAME 0x6474e550
78149
78150 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
78151 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
78152 +
78153 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
78154 +
78155 +/* Constants for the e_flags field */
78156 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78157 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
78158 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
78159 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
78160 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78161 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78162
78163 /*
78164 * Extended Numbering
78165 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
78166 #define DT_DEBUG 21
78167 #define DT_TEXTREL 22
78168 #define DT_JMPREL 23
78169 +#define DT_FLAGS 30
78170 + #define DF_TEXTREL 0x00000004
78171 #define DT_ENCODING 32
78172 #define OLD_DT_LOOS 0x60000000
78173 #define DT_LOOS 0x6000000d
78174 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
78175 #define PF_W 0x2
78176 #define PF_X 0x1
78177
78178 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
78179 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
78180 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
78181 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
78182 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
78183 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
78184 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
78185 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
78186 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
78187 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
78188 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
78189 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
78190 +
78191 typedef struct elf32_phdr{
78192 Elf32_Word p_type;
78193 Elf32_Off p_offset;
78194 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
78195 #define EI_OSABI 7
78196 #define EI_PAD 8
78197
78198 +#define EI_PAX 14
78199 +
78200 #define ELFMAG0 0x7f /* EI_MAG */
78201 #define ELFMAG1 'E'
78202 #define ELFMAG2 'L'
78203 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
78204 index aa169c4..6a2771d 100644
78205 --- a/include/uapi/linux/personality.h
78206 +++ b/include/uapi/linux/personality.h
78207 @@ -30,6 +30,7 @@ enum {
78208 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
78209 ADDR_NO_RANDOMIZE | \
78210 ADDR_COMPAT_LAYOUT | \
78211 + ADDR_LIMIT_3GB | \
78212 MMAP_PAGE_ZERO)
78213
78214 /*
78215 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
78216 index 7530e74..e714828 100644
78217 --- a/include/uapi/linux/screen_info.h
78218 +++ b/include/uapi/linux/screen_info.h
78219 @@ -43,7 +43,8 @@ struct screen_info {
78220 __u16 pages; /* 0x32 */
78221 __u16 vesa_attributes; /* 0x34 */
78222 __u32 capabilities; /* 0x36 */
78223 - __u8 _reserved[6]; /* 0x3a */
78224 + __u16 vesapm_size; /* 0x3a */
78225 + __u8 _reserved[4]; /* 0x3c */
78226 } __attribute__((packed));
78227
78228 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
78229 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
78230 index 0e011eb..82681b1 100644
78231 --- a/include/uapi/linux/swab.h
78232 +++ b/include/uapi/linux/swab.h
78233 @@ -43,7 +43,7 @@
78234 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
78235 */
78236
78237 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
78238 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
78239 {
78240 #ifdef __HAVE_BUILTIN_BSWAP16__
78241 return __builtin_bswap16(val);
78242 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
78243 #endif
78244 }
78245
78246 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
78247 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
78248 {
78249 #ifdef __HAVE_BUILTIN_BSWAP32__
78250 return __builtin_bswap32(val);
78251 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
78252 #endif
78253 }
78254
78255 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
78256 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
78257 {
78258 #ifdef __HAVE_BUILTIN_BSWAP64__
78259 return __builtin_bswap64(val);
78260 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
78261 index 6d67213..8dab561 100644
78262 --- a/include/uapi/linux/sysctl.h
78263 +++ b/include/uapi/linux/sysctl.h
78264 @@ -155,7 +155,11 @@ enum
78265 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
78266 };
78267
78268 -
78269 +#ifdef CONFIG_PAX_SOFTMODE
78270 +enum {
78271 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
78272 +};
78273 +#endif
78274
78275 /* CTL_VM names: */
78276 enum
78277 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
78278 index e4629b9..6958086 100644
78279 --- a/include/uapi/linux/xattr.h
78280 +++ b/include/uapi/linux/xattr.h
78281 @@ -63,5 +63,9 @@
78282 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
78283 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
78284
78285 +/* User namespace */
78286 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
78287 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
78288 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
78289
78290 #endif /* _UAPI_LINUX_XATTR_H */
78291 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
78292 index f9466fa..f4e2b81 100644
78293 --- a/include/video/udlfb.h
78294 +++ b/include/video/udlfb.h
78295 @@ -53,10 +53,10 @@ struct dlfb_data {
78296 u32 pseudo_palette[256];
78297 int blank_mode; /*one of FB_BLANK_ */
78298 /* blit-only rendering path metrics, exposed through sysfs */
78299 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78300 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
78301 - atomic_t bytes_sent; /* to usb, after compression including overhead */
78302 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
78303 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78304 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
78305 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
78306 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
78307 };
78308
78309 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
78310 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
78311 index 30f5362..8ed8ac9 100644
78312 --- a/include/video/uvesafb.h
78313 +++ b/include/video/uvesafb.h
78314 @@ -122,6 +122,7 @@ struct uvesafb_par {
78315 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
78316 u8 pmi_setpal; /* PMI for palette changes */
78317 u16 *pmi_base; /* protected mode interface location */
78318 + u8 *pmi_code; /* protected mode code location */
78319 void *pmi_start;
78320 void *pmi_pal;
78321 u8 *vbe_state_orig; /*
78322 diff --git a/init/Kconfig b/init/Kconfig
78323 index fed81b5..0d3b964 100644
78324 --- a/init/Kconfig
78325 +++ b/init/Kconfig
78326 @@ -1069,6 +1069,7 @@ endif # CGROUPS
78327
78328 config CHECKPOINT_RESTORE
78329 bool "Checkpoint/restore support" if EXPERT
78330 + depends on !GRKERNSEC
78331 default n
78332 help
78333 Enables additional kernel features in a sake of checkpoint/restore.
78334 @@ -1553,7 +1554,7 @@ config SLUB_DEBUG
78335
78336 config COMPAT_BRK
78337 bool "Disable heap randomization"
78338 - default y
78339 + default n
78340 help
78341 Randomizing heap placement makes heap exploits harder, but it
78342 also breaks ancient binaries (including anything libc5 based).
78343 @@ -1827,7 +1828,7 @@ config INIT_ALL_POSSIBLE
78344 config STOP_MACHINE
78345 bool
78346 default y
78347 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
78348 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
78349 help
78350 Need stop_machine() primitive.
78351
78352 diff --git a/init/Makefile b/init/Makefile
78353 index 7bc47ee..6da2dc7 100644
78354 --- a/init/Makefile
78355 +++ b/init/Makefile
78356 @@ -2,6 +2,9 @@
78357 # Makefile for the linux kernel.
78358 #
78359
78360 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
78361 +asflags-y := $(GCC_PLUGINS_AFLAGS)
78362 +
78363 obj-y := main.o version.o mounts.o
78364 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
78365 obj-y += noinitramfs.o
78366 diff --git a/init/do_mounts.c b/init/do_mounts.c
78367 index 816014c..c2054db 100644
78368 --- a/init/do_mounts.c
78369 +++ b/init/do_mounts.c
78370 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
78371 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
78372 {
78373 struct super_block *s;
78374 - int err = sys_mount(name, "/root", fs, flags, data);
78375 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
78376 if (err)
78377 return err;
78378
78379 - sys_chdir("/root");
78380 + sys_chdir((const char __force_user *)"/root");
78381 s = current->fs->pwd.dentry->d_sb;
78382 ROOT_DEV = s->s_dev;
78383 printk(KERN_INFO
78384 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
78385 va_start(args, fmt);
78386 vsprintf(buf, fmt, args);
78387 va_end(args);
78388 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
78389 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
78390 if (fd >= 0) {
78391 sys_ioctl(fd, FDEJECT, 0);
78392 sys_close(fd);
78393 }
78394 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
78395 - fd = sys_open("/dev/console", O_RDWR, 0);
78396 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
78397 if (fd >= 0) {
78398 sys_ioctl(fd, TCGETS, (long)&termios);
78399 termios.c_lflag &= ~ICANON;
78400 sys_ioctl(fd, TCSETSF, (long)&termios);
78401 - sys_read(fd, &c, 1);
78402 + sys_read(fd, (char __user *)&c, 1);
78403 termios.c_lflag |= ICANON;
78404 sys_ioctl(fd, TCSETSF, (long)&termios);
78405 sys_close(fd);
78406 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
78407 mount_root();
78408 out:
78409 devtmpfs_mount("dev");
78410 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78411 - sys_chroot(".");
78412 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78413 + sys_chroot((const char __force_user *)".");
78414 }
78415 diff --git a/init/do_mounts.h b/init/do_mounts.h
78416 index f5b978a..69dbfe8 100644
78417 --- a/init/do_mounts.h
78418 +++ b/init/do_mounts.h
78419 @@ -15,15 +15,15 @@ extern int root_mountflags;
78420
78421 static inline int create_dev(char *name, dev_t dev)
78422 {
78423 - sys_unlink(name);
78424 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
78425 + sys_unlink((char __force_user *)name);
78426 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
78427 }
78428
78429 #if BITS_PER_LONG == 32
78430 static inline u32 bstat(char *name)
78431 {
78432 struct stat64 stat;
78433 - if (sys_stat64(name, &stat) != 0)
78434 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
78435 return 0;
78436 if (!S_ISBLK(stat.st_mode))
78437 return 0;
78438 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
78439 static inline u32 bstat(char *name)
78440 {
78441 struct stat stat;
78442 - if (sys_newstat(name, &stat) != 0)
78443 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
78444 return 0;
78445 if (!S_ISBLK(stat.st_mode))
78446 return 0;
78447 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
78448 index 3e0878e..8a9d7a0 100644
78449 --- a/init/do_mounts_initrd.c
78450 +++ b/init/do_mounts_initrd.c
78451 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
78452 {
78453 sys_unshare(CLONE_FS | CLONE_FILES);
78454 /* stdin/stdout/stderr for /linuxrc */
78455 - sys_open("/dev/console", O_RDWR, 0);
78456 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
78457 sys_dup(0);
78458 sys_dup(0);
78459 /* move initrd over / and chdir/chroot in initrd root */
78460 - sys_chdir("/root");
78461 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78462 - sys_chroot(".");
78463 + sys_chdir((const char __force_user *)"/root");
78464 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78465 + sys_chroot((const char __force_user *)".");
78466 sys_setsid();
78467 return 0;
78468 }
78469 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
78470 create_dev("/dev/root.old", Root_RAM0);
78471 /* mount initrd on rootfs' /root */
78472 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
78473 - sys_mkdir("/old", 0700);
78474 - sys_chdir("/old");
78475 + sys_mkdir((const char __force_user *)"/old", 0700);
78476 + sys_chdir((const char __force_user *)"/old");
78477
78478 /* try loading default modules from initrd */
78479 load_default_modules();
78480 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
78481 current->flags &= ~PF_FREEZER_SKIP;
78482
78483 /* move initrd to rootfs' /old */
78484 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
78485 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
78486 /* switch root and cwd back to / of rootfs */
78487 - sys_chroot("..");
78488 + sys_chroot((const char __force_user *)"..");
78489
78490 if (new_decode_dev(real_root_dev) == Root_RAM0) {
78491 - sys_chdir("/old");
78492 + sys_chdir((const char __force_user *)"/old");
78493 return;
78494 }
78495
78496 - sys_chdir("/");
78497 + sys_chdir((const char __force_user *)"/");
78498 ROOT_DEV = new_decode_dev(real_root_dev);
78499 mount_root();
78500
78501 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
78502 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
78503 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
78504 if (!error)
78505 printk("okay\n");
78506 else {
78507 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
78508 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
78509 if (error == -ENOENT)
78510 printk("/initrd does not exist. Ignored.\n");
78511 else
78512 printk("failed\n");
78513 printk(KERN_NOTICE "Unmounting old root\n");
78514 - sys_umount("/old", MNT_DETACH);
78515 + sys_umount((char __force_user *)"/old", MNT_DETACH);
78516 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
78517 if (fd < 0) {
78518 error = fd;
78519 @@ -127,11 +127,11 @@ int __init initrd_load(void)
78520 * mounted in the normal path.
78521 */
78522 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
78523 - sys_unlink("/initrd.image");
78524 + sys_unlink((const char __force_user *)"/initrd.image");
78525 handle_initrd();
78526 return 1;
78527 }
78528 }
78529 - sys_unlink("/initrd.image");
78530 + sys_unlink((const char __force_user *)"/initrd.image");
78531 return 0;
78532 }
78533 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
78534 index 8cb6db5..d729f50 100644
78535 --- a/init/do_mounts_md.c
78536 +++ b/init/do_mounts_md.c
78537 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
78538 partitioned ? "_d" : "", minor,
78539 md_setup_args[ent].device_names);
78540
78541 - fd = sys_open(name, 0, 0);
78542 + fd = sys_open((char __force_user *)name, 0, 0);
78543 if (fd < 0) {
78544 printk(KERN_ERR "md: open failed - cannot start "
78545 "array %s\n", name);
78546 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
78547 * array without it
78548 */
78549 sys_close(fd);
78550 - fd = sys_open(name, 0, 0);
78551 + fd = sys_open((char __force_user *)name, 0, 0);
78552 sys_ioctl(fd, BLKRRPART, 0);
78553 }
78554 sys_close(fd);
78555 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
78556
78557 wait_for_device_probe();
78558
78559 - fd = sys_open("/dev/md0", 0, 0);
78560 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
78561 if (fd >= 0) {
78562 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
78563 sys_close(fd);
78564 diff --git a/init/init_task.c b/init/init_task.c
78565 index ba0a7f36..2bcf1d5 100644
78566 --- a/init/init_task.c
78567 +++ b/init/init_task.c
78568 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
78569 * Initial thread structure. Alignment of this is handled by a special
78570 * linker map entry.
78571 */
78572 +#ifdef CONFIG_X86
78573 +union thread_union init_thread_union __init_task_data;
78574 +#else
78575 union thread_union init_thread_union __init_task_data =
78576 { INIT_THREAD_INFO(init_task) };
78577 +#endif
78578 diff --git a/init/initramfs.c b/init/initramfs.c
78579 index a67ef9d..2d17ed9 100644
78580 --- a/init/initramfs.c
78581 +++ b/init/initramfs.c
78582 @@ -84,7 +84,7 @@ static void __init free_hash(void)
78583 }
78584 }
78585
78586 -static long __init do_utime(char *filename, time_t mtime)
78587 +static long __init do_utime(char __force_user *filename, time_t mtime)
78588 {
78589 struct timespec t[2];
78590
78591 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
78592 struct dir_entry *de, *tmp;
78593 list_for_each_entry_safe(de, tmp, &dir_list, list) {
78594 list_del(&de->list);
78595 - do_utime(de->name, de->mtime);
78596 + do_utime((char __force_user *)de->name, de->mtime);
78597 kfree(de->name);
78598 kfree(de);
78599 }
78600 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
78601 if (nlink >= 2) {
78602 char *old = find_link(major, minor, ino, mode, collected);
78603 if (old)
78604 - return (sys_link(old, collected) < 0) ? -1 : 1;
78605 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
78606 }
78607 return 0;
78608 }
78609 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
78610 {
78611 struct stat st;
78612
78613 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
78614 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
78615 if (S_ISDIR(st.st_mode))
78616 - sys_rmdir(path);
78617 + sys_rmdir((char __force_user *)path);
78618 else
78619 - sys_unlink(path);
78620 + sys_unlink((char __force_user *)path);
78621 }
78622 }
78623
78624 @@ -315,7 +315,7 @@ static int __init do_name(void)
78625 int openflags = O_WRONLY|O_CREAT;
78626 if (ml != 1)
78627 openflags |= O_TRUNC;
78628 - wfd = sys_open(collected, openflags, mode);
78629 + wfd = sys_open((char __force_user *)collected, openflags, mode);
78630
78631 if (wfd >= 0) {
78632 sys_fchown(wfd, uid, gid);
78633 @@ -327,17 +327,17 @@ static int __init do_name(void)
78634 }
78635 }
78636 } else if (S_ISDIR(mode)) {
78637 - sys_mkdir(collected, mode);
78638 - sys_chown(collected, uid, gid);
78639 - sys_chmod(collected, mode);
78640 + sys_mkdir((char __force_user *)collected, mode);
78641 + sys_chown((char __force_user *)collected, uid, gid);
78642 + sys_chmod((char __force_user *)collected, mode);
78643 dir_add(collected, mtime);
78644 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
78645 S_ISFIFO(mode) || S_ISSOCK(mode)) {
78646 if (maybe_link() == 0) {
78647 - sys_mknod(collected, mode, rdev);
78648 - sys_chown(collected, uid, gid);
78649 - sys_chmod(collected, mode);
78650 - do_utime(collected, mtime);
78651 + sys_mknod((char __force_user *)collected, mode, rdev);
78652 + sys_chown((char __force_user *)collected, uid, gid);
78653 + sys_chmod((char __force_user *)collected, mode);
78654 + do_utime((char __force_user *)collected, mtime);
78655 }
78656 }
78657 return 0;
78658 @@ -346,15 +346,15 @@ static int __init do_name(void)
78659 static int __init do_copy(void)
78660 {
78661 if (count >= body_len) {
78662 - sys_write(wfd, victim, body_len);
78663 + sys_write(wfd, (char __force_user *)victim, body_len);
78664 sys_close(wfd);
78665 - do_utime(vcollected, mtime);
78666 + do_utime((char __force_user *)vcollected, mtime);
78667 kfree(vcollected);
78668 eat(body_len);
78669 state = SkipIt;
78670 return 0;
78671 } else {
78672 - sys_write(wfd, victim, count);
78673 + sys_write(wfd, (char __force_user *)victim, count);
78674 body_len -= count;
78675 eat(count);
78676 return 1;
78677 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
78678 {
78679 collected[N_ALIGN(name_len) + body_len] = '\0';
78680 clean_path(collected, 0);
78681 - sys_symlink(collected + N_ALIGN(name_len), collected);
78682 - sys_lchown(collected, uid, gid);
78683 - do_utime(collected, mtime);
78684 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
78685 + sys_lchown((char __force_user *)collected, uid, gid);
78686 + do_utime((char __force_user *)collected, mtime);
78687 state = SkipIt;
78688 next_state = Reset;
78689 return 0;
78690 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
78691 {
78692 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
78693 if (err)
78694 - panic(err); /* Failed to decompress INTERNAL initramfs */
78695 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
78696 if (initrd_start) {
78697 #ifdef CONFIG_BLK_DEV_RAM
78698 int fd;
78699 diff --git a/init/main.c b/init/main.c
78700 index d03d2ec..9fc4737 100644
78701 --- a/init/main.c
78702 +++ b/init/main.c
78703 @@ -101,6 +101,8 @@ static inline void mark_rodata_ro(void) { }
78704 extern void tc_init(void);
78705 #endif
78706
78707 +extern void grsecurity_init(void);
78708 +
78709 /*
78710 * Debug helper: via this flag we know that we are in 'early bootup code'
78711 * where only the boot processor is running with IRQ disabled. This means
78712 @@ -154,6 +156,74 @@ static int __init set_reset_devices(char *str)
78713
78714 __setup("reset_devices", set_reset_devices);
78715
78716 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
78717 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
78718 +static int __init setup_grsec_proc_gid(char *str)
78719 +{
78720 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
78721 + return 1;
78722 +}
78723 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
78724 +#endif
78725 +
78726 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
78727 +unsigned long pax_user_shadow_base __read_only;
78728 +EXPORT_SYMBOL(pax_user_shadow_base);
78729 +extern char pax_enter_kernel_user[];
78730 +extern char pax_exit_kernel_user[];
78731 +#endif
78732 +
78733 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
78734 +static int __init setup_pax_nouderef(char *str)
78735 +{
78736 +#ifdef CONFIG_X86_32
78737 + unsigned int cpu;
78738 + struct desc_struct *gdt;
78739 +
78740 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
78741 + gdt = get_cpu_gdt_table(cpu);
78742 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
78743 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
78744 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
78745 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
78746 + }
78747 + loadsegment(ds, __KERNEL_DS);
78748 + loadsegment(es, __KERNEL_DS);
78749 + loadsegment(ss, __KERNEL_DS);
78750 +#else
78751 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
78752 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
78753 + clone_pgd_mask = ~(pgdval_t)0UL;
78754 + pax_user_shadow_base = 0UL;
78755 + setup_clear_cpu_cap(X86_FEATURE_PCID);
78756 +#endif
78757 +
78758 + return 0;
78759 +}
78760 +early_param("pax_nouderef", setup_pax_nouderef);
78761 +
78762 +#ifdef CONFIG_X86_64
78763 +static int __init setup_pax_weakuderef(char *str)
78764 +{
78765 + if (clone_pgd_mask != ~(pgdval_t)0UL)
78766 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
78767 + return 1;
78768 +}
78769 +__setup("pax_weakuderef", setup_pax_weakuderef);
78770 +#endif
78771 +#endif
78772 +
78773 +#ifdef CONFIG_PAX_SOFTMODE
78774 +int pax_softmode;
78775 +
78776 +static int __init setup_pax_softmode(char *str)
78777 +{
78778 + get_option(&str, &pax_softmode);
78779 + return 1;
78780 +}
78781 +__setup("pax_softmode=", setup_pax_softmode);
78782 +#endif
78783 +
78784 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
78785 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
78786 static const char *panic_later, *panic_param;
78787 @@ -679,25 +749,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
78788 {
78789 int count = preempt_count();
78790 int ret;
78791 - char msgbuf[64];
78792 + const char *msg1 = "", *msg2 = "";
78793
78794 if (initcall_debug)
78795 ret = do_one_initcall_debug(fn);
78796 else
78797 ret = fn();
78798
78799 - msgbuf[0] = 0;
78800 -
78801 if (preempt_count() != count) {
78802 - sprintf(msgbuf, "preemption imbalance ");
78803 + msg1 = " preemption imbalance";
78804 preempt_count() = count;
78805 }
78806 if (irqs_disabled()) {
78807 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
78808 + msg2 = " disabled interrupts";
78809 local_irq_enable();
78810 }
78811 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
78812 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
78813
78814 + add_latent_entropy();
78815 return ret;
78816 }
78817
78818 @@ -803,8 +872,8 @@ static int run_init_process(const char *init_filename)
78819 {
78820 argv_init[0] = init_filename;
78821 return do_execve(init_filename,
78822 - (const char __user *const __user *)argv_init,
78823 - (const char __user *const __user *)envp_init);
78824 + (const char __user *const __force_user *)argv_init,
78825 + (const char __user *const __force_user *)envp_init);
78826 }
78827
78828 static noinline void __init kernel_init_freeable(void);
78829 @@ -881,7 +950,7 @@ static noinline void __init kernel_init_freeable(void)
78830 do_basic_setup();
78831
78832 /* Open the /dev/console on the rootfs, this should never fail */
78833 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
78834 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
78835 pr_err("Warning: unable to open an initial console.\n");
78836
78837 (void) sys_dup(0);
78838 @@ -894,11 +963,13 @@ static noinline void __init kernel_init_freeable(void)
78839 if (!ramdisk_execute_command)
78840 ramdisk_execute_command = "/init";
78841
78842 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
78843 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
78844 ramdisk_execute_command = NULL;
78845 prepare_namespace();
78846 }
78847
78848 + grsecurity_init();
78849 +
78850 /*
78851 * Ok, we have completed the initial bootup, and
78852 * we're essentially up and running. Get rid of the
78853 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
78854 index 130dfec..cc88451 100644
78855 --- a/ipc/ipc_sysctl.c
78856 +++ b/ipc/ipc_sysctl.c
78857 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
78858 static int proc_ipc_dointvec(ctl_table *table, int write,
78859 void __user *buffer, size_t *lenp, loff_t *ppos)
78860 {
78861 - struct ctl_table ipc_table;
78862 + ctl_table_no_const ipc_table;
78863
78864 memcpy(&ipc_table, table, sizeof(ipc_table));
78865 ipc_table.data = get_ipc(table);
78866 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
78867 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
78868 void __user *buffer, size_t *lenp, loff_t *ppos)
78869 {
78870 - struct ctl_table ipc_table;
78871 + ctl_table_no_const ipc_table;
78872
78873 memcpy(&ipc_table, table, sizeof(ipc_table));
78874 ipc_table.data = get_ipc(table);
78875 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
78876 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
78877 void __user *buffer, size_t *lenp, loff_t *ppos)
78878 {
78879 - struct ctl_table ipc_table;
78880 + ctl_table_no_const ipc_table;
78881 size_t lenp_bef = *lenp;
78882 int rc;
78883
78884 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
78885 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
78886 void __user *buffer, size_t *lenp, loff_t *ppos)
78887 {
78888 - struct ctl_table ipc_table;
78889 + ctl_table_no_const ipc_table;
78890 memcpy(&ipc_table, table, sizeof(ipc_table));
78891 ipc_table.data = get_ipc(table);
78892
78893 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
78894 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
78895 void __user *buffer, size_t *lenp, loff_t *ppos)
78896 {
78897 - struct ctl_table ipc_table;
78898 + ctl_table_no_const ipc_table;
78899 size_t lenp_bef = *lenp;
78900 int oldval;
78901 int rc;
78902 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
78903 index 383d638..943fdbb 100644
78904 --- a/ipc/mq_sysctl.c
78905 +++ b/ipc/mq_sysctl.c
78906 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
78907 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
78908 void __user *buffer, size_t *lenp, loff_t *ppos)
78909 {
78910 - struct ctl_table mq_table;
78911 + ctl_table_no_const mq_table;
78912 memcpy(&mq_table, table, sizeof(mq_table));
78913 mq_table.data = get_mq(table);
78914
78915 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
78916 index ae1996d..a35f2cc 100644
78917 --- a/ipc/mqueue.c
78918 +++ b/ipc/mqueue.c
78919 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
78920 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
78921 info->attr.mq_msgsize);
78922
78923 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
78924 spin_lock(&mq_lock);
78925 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
78926 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
78927 diff --git a/ipc/msg.c b/ipc/msg.c
78928 index b65fdf1..89ec2b1 100644
78929 --- a/ipc/msg.c
78930 +++ b/ipc/msg.c
78931 @@ -291,18 +291,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
78932 return security_msg_queue_associate(msq, msgflg);
78933 }
78934
78935 +static struct ipc_ops msg_ops = {
78936 + .getnew = newque,
78937 + .associate = msg_security,
78938 + .more_checks = NULL
78939 +};
78940 +
78941 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
78942 {
78943 struct ipc_namespace *ns;
78944 - struct ipc_ops msg_ops;
78945 struct ipc_params msg_params;
78946
78947 ns = current->nsproxy->ipc_ns;
78948
78949 - msg_ops.getnew = newque;
78950 - msg_ops.associate = msg_security;
78951 - msg_ops.more_checks = NULL;
78952 -
78953 msg_params.key = key;
78954 msg_params.flg = msgflg;
78955
78956 diff --git a/ipc/sem.c b/ipc/sem.c
78957 index 4108889..511ada1 100644
78958 --- a/ipc/sem.c
78959 +++ b/ipc/sem.c
78960 @@ -517,10 +517,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
78961 return 0;
78962 }
78963
78964 +static struct ipc_ops sem_ops = {
78965 + .getnew = newary,
78966 + .associate = sem_security,
78967 + .more_checks = sem_more_checks
78968 +};
78969 +
78970 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
78971 {
78972 struct ipc_namespace *ns;
78973 - struct ipc_ops sem_ops;
78974 struct ipc_params sem_params;
78975
78976 ns = current->nsproxy->ipc_ns;
78977 @@ -528,10 +533,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
78978 if (nsems < 0 || nsems > ns->sc_semmsl)
78979 return -EINVAL;
78980
78981 - sem_ops.getnew = newary;
78982 - sem_ops.associate = sem_security;
78983 - sem_ops.more_checks = sem_more_checks;
78984 -
78985 sem_params.key = key;
78986 sem_params.flg = semflg;
78987 sem_params.u.nsems = nsems;
78988 diff --git a/ipc/shm.c b/ipc/shm.c
78989 index c6b4ad5..3ec3254 100644
78990 --- a/ipc/shm.c
78991 +++ b/ipc/shm.c
78992 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
78993 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
78994 #endif
78995
78996 +#ifdef CONFIG_GRKERNSEC
78997 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
78998 + const time_t shm_createtime, const kuid_t cuid,
78999 + const int shmid);
79000 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79001 + const time_t shm_createtime);
79002 +#endif
79003 +
79004 void shm_init_ns(struct ipc_namespace *ns)
79005 {
79006 ns->shm_ctlmax = SHMMAX;
79007 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
79008 shp->shm_lprid = 0;
79009 shp->shm_atim = shp->shm_dtim = 0;
79010 shp->shm_ctim = get_seconds();
79011 +#ifdef CONFIG_GRKERNSEC
79012 + {
79013 + struct timespec timeval;
79014 + do_posix_clock_monotonic_gettime(&timeval);
79015 +
79016 + shp->shm_createtime = timeval.tv_sec;
79017 + }
79018 +#endif
79019 shp->shm_segsz = size;
79020 shp->shm_nattch = 0;
79021 shp->shm_file = file;
79022 @@ -585,18 +601,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
79023 return 0;
79024 }
79025
79026 +static struct ipc_ops shm_ops = {
79027 + .getnew = newseg,
79028 + .associate = shm_security,
79029 + .more_checks = shm_more_checks
79030 +};
79031 +
79032 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
79033 {
79034 struct ipc_namespace *ns;
79035 - struct ipc_ops shm_ops;
79036 struct ipc_params shm_params;
79037
79038 ns = current->nsproxy->ipc_ns;
79039
79040 - shm_ops.getnew = newseg;
79041 - shm_ops.associate = shm_security;
79042 - shm_ops.more_checks = shm_more_checks;
79043 -
79044 shm_params.key = key;
79045 shm_params.flg = shmflg;
79046 shm_params.u.size = size;
79047 @@ -1028,6 +1045,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79048 f_mode = FMODE_READ | FMODE_WRITE;
79049 }
79050 if (shmflg & SHM_EXEC) {
79051 +
79052 +#ifdef CONFIG_PAX_MPROTECT
79053 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
79054 + goto out;
79055 +#endif
79056 +
79057 prot |= PROT_EXEC;
79058 acc_mode |= S_IXUGO;
79059 }
79060 @@ -1051,9 +1074,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79061 if (err)
79062 goto out_unlock;
79063
79064 +#ifdef CONFIG_GRKERNSEC
79065 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
79066 + shp->shm_perm.cuid, shmid) ||
79067 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
79068 + err = -EACCES;
79069 + goto out_unlock;
79070 + }
79071 +#endif
79072 +
79073 path = shp->shm_file->f_path;
79074 path_get(&path);
79075 shp->shm_nattch++;
79076 +#ifdef CONFIG_GRKERNSEC
79077 + shp->shm_lapid = current->pid;
79078 +#endif
79079 size = i_size_read(path.dentry->d_inode);
79080 shm_unlock(shp);
79081
79082 diff --git a/kernel/acct.c b/kernel/acct.c
79083 index 8d6e145..33e0b1e 100644
79084 --- a/kernel/acct.c
79085 +++ b/kernel/acct.c
79086 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
79087 */
79088 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
79089 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
79090 - file->f_op->write(file, (char *)&ac,
79091 + file->f_op->write(file, (char __force_user *)&ac,
79092 sizeof(acct_t), &file->f_pos);
79093 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
79094 set_fs(fs);
79095 diff --git a/kernel/audit.c b/kernel/audit.c
79096 index 7b0e23a..861041e 100644
79097 --- a/kernel/audit.c
79098 +++ b/kernel/audit.c
79099 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
79100 3) suppressed due to audit_rate_limit
79101 4) suppressed due to audit_backlog_limit
79102 */
79103 -static atomic_t audit_lost = ATOMIC_INIT(0);
79104 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
79105
79106 /* The netlink socket. */
79107 static struct sock *audit_sock;
79108 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
79109 unsigned long now;
79110 int print;
79111
79112 - atomic_inc(&audit_lost);
79113 + atomic_inc_unchecked(&audit_lost);
79114
79115 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
79116
79117 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
79118 printk(KERN_WARNING
79119 "audit: audit_lost=%d audit_rate_limit=%d "
79120 "audit_backlog_limit=%d\n",
79121 - atomic_read(&audit_lost),
79122 + atomic_read_unchecked(&audit_lost),
79123 audit_rate_limit,
79124 audit_backlog_limit);
79125 audit_panic(message);
79126 @@ -664,7 +664,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79127 status_set.pid = audit_pid;
79128 status_set.rate_limit = audit_rate_limit;
79129 status_set.backlog_limit = audit_backlog_limit;
79130 - status_set.lost = atomic_read(&audit_lost);
79131 + status_set.lost = atomic_read_unchecked(&audit_lost);
79132 status_set.backlog = skb_queue_len(&audit_skb_queue);
79133 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
79134 &status_set, sizeof(status_set));
79135 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
79136 index 9845cb3..3ec9369 100644
79137 --- a/kernel/auditsc.c
79138 +++ b/kernel/auditsc.c
79139 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
79140 }
79141
79142 /* global counter which is incremented every time something logs in */
79143 -static atomic_t session_id = ATOMIC_INIT(0);
79144 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
79145
79146 /**
79147 * audit_set_loginuid - set current task's audit_context loginuid
79148 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
79149 return -EPERM;
79150 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
79151
79152 - sessionid = atomic_inc_return(&session_id);
79153 + sessionid = atomic_inc_return_unchecked(&session_id);
79154 if (context && context->in_syscall) {
79155 struct audit_buffer *ab;
79156
79157 diff --git a/kernel/capability.c b/kernel/capability.c
79158 index f6c2ce5..982c0f9 100644
79159 --- a/kernel/capability.c
79160 +++ b/kernel/capability.c
79161 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
79162 * before modification is attempted and the application
79163 * fails.
79164 */
79165 + if (tocopy > ARRAY_SIZE(kdata))
79166 + return -EFAULT;
79167 +
79168 if (copy_to_user(dataptr, kdata, tocopy
79169 * sizeof(struct __user_cap_data_struct))) {
79170 return -EFAULT;
79171 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
79172 int ret;
79173
79174 rcu_read_lock();
79175 - ret = security_capable(__task_cred(t), ns, cap);
79176 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
79177 + gr_task_is_capable(t, __task_cred(t), cap);
79178 rcu_read_unlock();
79179
79180 - return (ret == 0);
79181 + return ret;
79182 }
79183
79184 /**
79185 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
79186 int ret;
79187
79188 rcu_read_lock();
79189 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
79190 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
79191 rcu_read_unlock();
79192
79193 - return (ret == 0);
79194 + return ret;
79195 }
79196
79197 /**
79198 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
79199 BUG();
79200 }
79201
79202 - if (security_capable(current_cred(), ns, cap) == 0) {
79203 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
79204 current->flags |= PF_SUPERPRIV;
79205 return true;
79206 }
79207 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
79208 }
79209 EXPORT_SYMBOL(ns_capable);
79210
79211 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
79212 +{
79213 + if (unlikely(!cap_valid(cap))) {
79214 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
79215 + BUG();
79216 + }
79217 +
79218 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
79219 + current->flags |= PF_SUPERPRIV;
79220 + return true;
79221 + }
79222 + return false;
79223 +}
79224 +EXPORT_SYMBOL(ns_capable_nolog);
79225 +
79226 /**
79227 * file_ns_capable - Determine if the file's opener had a capability in effect
79228 * @file: The file we want to check
79229 @@ -432,6 +451,12 @@ bool capable(int cap)
79230 }
79231 EXPORT_SYMBOL(capable);
79232
79233 +bool capable_nolog(int cap)
79234 +{
79235 + return ns_capable_nolog(&init_user_ns, cap);
79236 +}
79237 +EXPORT_SYMBOL(capable_nolog);
79238 +
79239 /**
79240 * nsown_capable - Check superior capability to one's own user_ns
79241 * @cap: The capability in question
79242 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
79243
79244 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79245 }
79246 +
79247 +bool inode_capable_nolog(const struct inode *inode, int cap)
79248 +{
79249 + struct user_namespace *ns = current_user_ns();
79250 +
79251 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79252 +}
79253 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
79254 index e919633..f46b08f 100644
79255 --- a/kernel/cgroup.c
79256 +++ b/kernel/cgroup.c
79257 @@ -5623,7 +5623,7 @@ static int cgroup_css_links_read(struct cgroup *cgrp,
79258 struct css_set *cset = link->cset;
79259 struct task_struct *task;
79260 int count = 0;
79261 - seq_printf(seq, "css_set %p\n", cset);
79262 + seq_printf(seq, "css_set %pK\n", cset);
79263 list_for_each_entry(task, &cset->tasks, cg_list) {
79264 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
79265 seq_puts(seq, " ...\n");
79266 diff --git a/kernel/compat.c b/kernel/compat.c
79267 index 0a09e48..f44f3f0 100644
79268 --- a/kernel/compat.c
79269 +++ b/kernel/compat.c
79270 @@ -13,6 +13,7 @@
79271
79272 #include <linux/linkage.h>
79273 #include <linux/compat.h>
79274 +#include <linux/module.h>
79275 #include <linux/errno.h>
79276 #include <linux/time.h>
79277 #include <linux/signal.h>
79278 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
79279 mm_segment_t oldfs;
79280 long ret;
79281
79282 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
79283 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
79284 oldfs = get_fs();
79285 set_fs(KERNEL_DS);
79286 ret = hrtimer_nanosleep_restart(restart);
79287 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
79288 oldfs = get_fs();
79289 set_fs(KERNEL_DS);
79290 ret = hrtimer_nanosleep(&tu,
79291 - rmtp ? (struct timespec __user *)&rmt : NULL,
79292 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
79293 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
79294 set_fs(oldfs);
79295
79296 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
79297 mm_segment_t old_fs = get_fs();
79298
79299 set_fs(KERNEL_DS);
79300 - ret = sys_sigpending((old_sigset_t __user *) &s);
79301 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
79302 set_fs(old_fs);
79303 if (ret == 0)
79304 ret = put_user(s, set);
79305 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
79306 mm_segment_t old_fs = get_fs();
79307
79308 set_fs(KERNEL_DS);
79309 - ret = sys_old_getrlimit(resource, &r);
79310 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
79311 set_fs(old_fs);
79312
79313 if (!ret) {
79314 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
79315 set_fs (KERNEL_DS);
79316 ret = sys_wait4(pid,
79317 (stat_addr ?
79318 - (unsigned int __user *) &status : NULL),
79319 - options, (struct rusage __user *) &r);
79320 + (unsigned int __force_user *) &status : NULL),
79321 + options, (struct rusage __force_user *) &r);
79322 set_fs (old_fs);
79323
79324 if (ret > 0) {
79325 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
79326 memset(&info, 0, sizeof(info));
79327
79328 set_fs(KERNEL_DS);
79329 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
79330 - uru ? (struct rusage __user *)&ru : NULL);
79331 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
79332 + uru ? (struct rusage __force_user *)&ru : NULL);
79333 set_fs(old_fs);
79334
79335 if ((ret < 0) || (info.si_signo == 0))
79336 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
79337 oldfs = get_fs();
79338 set_fs(KERNEL_DS);
79339 err = sys_timer_settime(timer_id, flags,
79340 - (struct itimerspec __user *) &newts,
79341 - (struct itimerspec __user *) &oldts);
79342 + (struct itimerspec __force_user *) &newts,
79343 + (struct itimerspec __force_user *) &oldts);
79344 set_fs(oldfs);
79345 if (!err && old && put_compat_itimerspec(old, &oldts))
79346 return -EFAULT;
79347 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
79348 oldfs = get_fs();
79349 set_fs(KERNEL_DS);
79350 err = sys_timer_gettime(timer_id,
79351 - (struct itimerspec __user *) &ts);
79352 + (struct itimerspec __force_user *) &ts);
79353 set_fs(oldfs);
79354 if (!err && put_compat_itimerspec(setting, &ts))
79355 return -EFAULT;
79356 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
79357 oldfs = get_fs();
79358 set_fs(KERNEL_DS);
79359 err = sys_clock_settime(which_clock,
79360 - (struct timespec __user *) &ts);
79361 + (struct timespec __force_user *) &ts);
79362 set_fs(oldfs);
79363 return err;
79364 }
79365 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
79366 oldfs = get_fs();
79367 set_fs(KERNEL_DS);
79368 err = sys_clock_gettime(which_clock,
79369 - (struct timespec __user *) &ts);
79370 + (struct timespec __force_user *) &ts);
79371 set_fs(oldfs);
79372 if (!err && put_compat_timespec(&ts, tp))
79373 return -EFAULT;
79374 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
79375
79376 oldfs = get_fs();
79377 set_fs(KERNEL_DS);
79378 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
79379 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
79380 set_fs(oldfs);
79381
79382 err = compat_put_timex(utp, &txc);
79383 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
79384 oldfs = get_fs();
79385 set_fs(KERNEL_DS);
79386 err = sys_clock_getres(which_clock,
79387 - (struct timespec __user *) &ts);
79388 + (struct timespec __force_user *) &ts);
79389 set_fs(oldfs);
79390 if (!err && tp && put_compat_timespec(&ts, tp))
79391 return -EFAULT;
79392 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
79393 long err;
79394 mm_segment_t oldfs;
79395 struct timespec tu;
79396 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
79397 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
79398
79399 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
79400 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
79401 oldfs = get_fs();
79402 set_fs(KERNEL_DS);
79403 err = clock_nanosleep_restart(restart);
79404 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
79405 oldfs = get_fs();
79406 set_fs(KERNEL_DS);
79407 err = sys_clock_nanosleep(which_clock, flags,
79408 - (struct timespec __user *) &in,
79409 - (struct timespec __user *) &out);
79410 + (struct timespec __force_user *) &in,
79411 + (struct timespec __force_user *) &out);
79412 set_fs(oldfs);
79413
79414 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
79415 diff --git a/kernel/configs.c b/kernel/configs.c
79416 index c18b1f1..b9a0132 100644
79417 --- a/kernel/configs.c
79418 +++ b/kernel/configs.c
79419 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
79420 struct proc_dir_entry *entry;
79421
79422 /* create the current config file */
79423 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
79424 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
79425 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
79426 + &ikconfig_file_ops);
79427 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
79428 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
79429 + &ikconfig_file_ops);
79430 +#endif
79431 +#else
79432 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
79433 &ikconfig_file_ops);
79434 +#endif
79435 +
79436 if (!entry)
79437 return -ENOMEM;
79438
79439 diff --git a/kernel/cred.c b/kernel/cred.c
79440 index e0573a4..3874e41 100644
79441 --- a/kernel/cred.c
79442 +++ b/kernel/cred.c
79443 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
79444 validate_creds(cred);
79445 alter_cred_subscribers(cred, -1);
79446 put_cred(cred);
79447 +
79448 +#ifdef CONFIG_GRKERNSEC_SETXID
79449 + cred = (struct cred *) tsk->delayed_cred;
79450 + if (cred != NULL) {
79451 + tsk->delayed_cred = NULL;
79452 + validate_creds(cred);
79453 + alter_cred_subscribers(cred, -1);
79454 + put_cred(cred);
79455 + }
79456 +#endif
79457 }
79458
79459 /**
79460 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
79461 * Always returns 0 thus allowing this function to be tail-called at the end
79462 * of, say, sys_setgid().
79463 */
79464 -int commit_creds(struct cred *new)
79465 +static int __commit_creds(struct cred *new)
79466 {
79467 struct task_struct *task = current;
79468 const struct cred *old = task->real_cred;
79469 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
79470
79471 get_cred(new); /* we will require a ref for the subj creds too */
79472
79473 + gr_set_role_label(task, new->uid, new->gid);
79474 +
79475 /* dumpability changes */
79476 if (!uid_eq(old->euid, new->euid) ||
79477 !gid_eq(old->egid, new->egid) ||
79478 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
79479 put_cred(old);
79480 return 0;
79481 }
79482 +#ifdef CONFIG_GRKERNSEC_SETXID
79483 +extern int set_user(struct cred *new);
79484 +
79485 +void gr_delayed_cred_worker(void)
79486 +{
79487 + const struct cred *new = current->delayed_cred;
79488 + struct cred *ncred;
79489 +
79490 + current->delayed_cred = NULL;
79491 +
79492 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
79493 + // from doing get_cred on it when queueing this
79494 + put_cred(new);
79495 + return;
79496 + } else if (new == NULL)
79497 + return;
79498 +
79499 + ncred = prepare_creds();
79500 + if (!ncred)
79501 + goto die;
79502 + // uids
79503 + ncred->uid = new->uid;
79504 + ncred->euid = new->euid;
79505 + ncred->suid = new->suid;
79506 + ncred->fsuid = new->fsuid;
79507 + // gids
79508 + ncred->gid = new->gid;
79509 + ncred->egid = new->egid;
79510 + ncred->sgid = new->sgid;
79511 + ncred->fsgid = new->fsgid;
79512 + // groups
79513 + if (set_groups(ncred, new->group_info) < 0) {
79514 + abort_creds(ncred);
79515 + goto die;
79516 + }
79517 + // caps
79518 + ncred->securebits = new->securebits;
79519 + ncred->cap_inheritable = new->cap_inheritable;
79520 + ncred->cap_permitted = new->cap_permitted;
79521 + ncred->cap_effective = new->cap_effective;
79522 + ncred->cap_bset = new->cap_bset;
79523 +
79524 + if (set_user(ncred)) {
79525 + abort_creds(ncred);
79526 + goto die;
79527 + }
79528 +
79529 + // from doing get_cred on it when queueing this
79530 + put_cred(new);
79531 +
79532 + __commit_creds(ncred);
79533 + return;
79534 +die:
79535 + // from doing get_cred on it when queueing this
79536 + put_cred(new);
79537 + do_group_exit(SIGKILL);
79538 +}
79539 +#endif
79540 +
79541 +int commit_creds(struct cred *new)
79542 +{
79543 +#ifdef CONFIG_GRKERNSEC_SETXID
79544 + int ret;
79545 + int schedule_it = 0;
79546 + struct task_struct *t;
79547 +
79548 + /* we won't get called with tasklist_lock held for writing
79549 + and interrupts disabled as the cred struct in that case is
79550 + init_cred
79551 + */
79552 + if (grsec_enable_setxid && !current_is_single_threaded() &&
79553 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
79554 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
79555 + schedule_it = 1;
79556 + }
79557 + ret = __commit_creds(new);
79558 + if (schedule_it) {
79559 + rcu_read_lock();
79560 + read_lock(&tasklist_lock);
79561 + for (t = next_thread(current); t != current;
79562 + t = next_thread(t)) {
79563 + if (t->delayed_cred == NULL) {
79564 + t->delayed_cred = get_cred(new);
79565 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
79566 + set_tsk_need_resched(t);
79567 + }
79568 + }
79569 + read_unlock(&tasklist_lock);
79570 + rcu_read_unlock();
79571 + }
79572 + return ret;
79573 +#else
79574 + return __commit_creds(new);
79575 +#endif
79576 +}
79577 +
79578 EXPORT_SYMBOL(commit_creds);
79579
79580 /**
79581 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
79582 index 0506d44..2c20034 100644
79583 --- a/kernel/debug/debug_core.c
79584 +++ b/kernel/debug/debug_core.c
79585 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
79586 */
79587 static atomic_t masters_in_kgdb;
79588 static atomic_t slaves_in_kgdb;
79589 -static atomic_t kgdb_break_tasklet_var;
79590 +static atomic_unchecked_t kgdb_break_tasklet_var;
79591 atomic_t kgdb_setting_breakpoint;
79592
79593 struct task_struct *kgdb_usethread;
79594 @@ -133,7 +133,7 @@ int kgdb_single_step;
79595 static pid_t kgdb_sstep_pid;
79596
79597 /* to keep track of the CPU which is doing the single stepping*/
79598 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
79599 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
79600
79601 /*
79602 * If you are debugging a problem where roundup (the collection of
79603 @@ -541,7 +541,7 @@ return_normal:
79604 * kernel will only try for the value of sstep_tries before
79605 * giving up and continuing on.
79606 */
79607 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
79608 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
79609 (kgdb_info[cpu].task &&
79610 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
79611 atomic_set(&kgdb_active, -1);
79612 @@ -635,8 +635,8 @@ cpu_master_loop:
79613 }
79614
79615 kgdb_restore:
79616 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
79617 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
79618 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
79619 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
79620 if (kgdb_info[sstep_cpu].task)
79621 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
79622 else
79623 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
79624 static void kgdb_tasklet_bpt(unsigned long ing)
79625 {
79626 kgdb_breakpoint();
79627 - atomic_set(&kgdb_break_tasklet_var, 0);
79628 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
79629 }
79630
79631 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
79632
79633 void kgdb_schedule_breakpoint(void)
79634 {
79635 - if (atomic_read(&kgdb_break_tasklet_var) ||
79636 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
79637 atomic_read(&kgdb_active) != -1 ||
79638 atomic_read(&kgdb_setting_breakpoint))
79639 return;
79640 - atomic_inc(&kgdb_break_tasklet_var);
79641 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
79642 tasklet_schedule(&kgdb_tasklet_breakpoint);
79643 }
79644 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
79645 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
79646 index 00eb8f7..d7e3244 100644
79647 --- a/kernel/debug/kdb/kdb_main.c
79648 +++ b/kernel/debug/kdb/kdb_main.c
79649 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
79650 continue;
79651
79652 kdb_printf("%-20s%8u 0x%p ", mod->name,
79653 - mod->core_size, (void *)mod);
79654 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
79655 #ifdef CONFIG_MODULE_UNLOAD
79656 kdb_printf("%4ld ", module_refcount(mod));
79657 #endif
79658 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
79659 kdb_printf(" (Loading)");
79660 else
79661 kdb_printf(" (Live)");
79662 - kdb_printf(" 0x%p", mod->module_core);
79663 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
79664
79665 #ifdef CONFIG_MODULE_UNLOAD
79666 {
79667 diff --git a/kernel/events/core.c b/kernel/events/core.c
79668 index f86599e..b18b180 100644
79669 --- a/kernel/events/core.c
79670 +++ b/kernel/events/core.c
79671 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
79672 * 0 - disallow raw tracepoint access for unpriv
79673 * 1 - disallow cpu events for unpriv
79674 * 2 - disallow kernel profiling for unpriv
79675 + * 3 - disallow all unpriv perf event use
79676 */
79677 -int sysctl_perf_event_paranoid __read_mostly = 1;
79678 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
79679 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
79680 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
79681 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
79682 +#else
79683 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
79684 +#endif
79685
79686 /* Minimum for 512 kiB + 1 user control page */
79687 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
79688 @@ -270,7 +277,7 @@ void perf_sample_event_took(u64 sample_len_ns)
79689 update_perf_cpu_limits();
79690 }
79691
79692 -static atomic64_t perf_event_id;
79693 +static atomic64_unchecked_t perf_event_id;
79694
79695 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
79696 enum event_type_t event_type);
79697 @@ -2936,7 +2943,7 @@ static void __perf_event_read(void *info)
79698
79699 static inline u64 perf_event_count(struct perf_event *event)
79700 {
79701 - return local64_read(&event->count) + atomic64_read(&event->child_count);
79702 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
79703 }
79704
79705 static u64 perf_event_read(struct perf_event *event)
79706 @@ -3282,9 +3289,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
79707 mutex_lock(&event->child_mutex);
79708 total += perf_event_read(event);
79709 *enabled += event->total_time_enabled +
79710 - atomic64_read(&event->child_total_time_enabled);
79711 + atomic64_read_unchecked(&event->child_total_time_enabled);
79712 *running += event->total_time_running +
79713 - atomic64_read(&event->child_total_time_running);
79714 + atomic64_read_unchecked(&event->child_total_time_running);
79715
79716 list_for_each_entry(child, &event->child_list, child_list) {
79717 total += perf_event_read(child);
79718 @@ -3670,10 +3677,10 @@ void perf_event_update_userpage(struct perf_event *event)
79719 userpg->offset -= local64_read(&event->hw.prev_count);
79720
79721 userpg->time_enabled = enabled +
79722 - atomic64_read(&event->child_total_time_enabled);
79723 + atomic64_read_unchecked(&event->child_total_time_enabled);
79724
79725 userpg->time_running = running +
79726 - atomic64_read(&event->child_total_time_running);
79727 + atomic64_read_unchecked(&event->child_total_time_running);
79728
79729 arch_perf_update_userpage(userpg, now);
79730
79731 @@ -4223,7 +4230,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
79732
79733 /* Data. */
79734 sp = perf_user_stack_pointer(regs);
79735 - rem = __output_copy_user(handle, (void *) sp, dump_size);
79736 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
79737 dyn_size = dump_size - rem;
79738
79739 perf_output_skip(handle, rem);
79740 @@ -4311,11 +4318,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
79741 values[n++] = perf_event_count(event);
79742 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
79743 values[n++] = enabled +
79744 - atomic64_read(&event->child_total_time_enabled);
79745 + atomic64_read_unchecked(&event->child_total_time_enabled);
79746 }
79747 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
79748 values[n++] = running +
79749 - atomic64_read(&event->child_total_time_running);
79750 + atomic64_read_unchecked(&event->child_total_time_running);
79751 }
79752 if (read_format & PERF_FORMAT_ID)
79753 values[n++] = primary_event_id(event);
79754 @@ -5024,12 +5031,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
79755 * need to add enough zero bytes after the string to handle
79756 * the 64bit alignment we do later.
79757 */
79758 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
79759 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
79760 if (!buf) {
79761 name = strncpy(tmp, "//enomem", sizeof(tmp));
79762 goto got_name;
79763 }
79764 - name = d_path(&file->f_path, buf, PATH_MAX);
79765 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
79766 if (IS_ERR(name)) {
79767 name = strncpy(tmp, "//toolong", sizeof(tmp));
79768 goto got_name;
79769 @@ -6498,7 +6505,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
79770 event->parent = parent_event;
79771
79772 event->ns = get_pid_ns(task_active_pid_ns(current));
79773 - event->id = atomic64_inc_return(&perf_event_id);
79774 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
79775
79776 event->state = PERF_EVENT_STATE_INACTIVE;
79777
79778 @@ -6807,6 +6814,11 @@ SYSCALL_DEFINE5(perf_event_open,
79779 if (flags & ~PERF_FLAG_ALL)
79780 return -EINVAL;
79781
79782 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
79783 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
79784 + return -EACCES;
79785 +#endif
79786 +
79787 err = perf_copy_attr(attr_uptr, &attr);
79788 if (err)
79789 return err;
79790 @@ -7139,10 +7151,10 @@ static void sync_child_event(struct perf_event *child_event,
79791 /*
79792 * Add back the child's count to the parent's count:
79793 */
79794 - atomic64_add(child_val, &parent_event->child_count);
79795 - atomic64_add(child_event->total_time_enabled,
79796 + atomic64_add_unchecked(child_val, &parent_event->child_count);
79797 + atomic64_add_unchecked(child_event->total_time_enabled,
79798 &parent_event->child_total_time_enabled);
79799 - atomic64_add(child_event->total_time_running,
79800 + atomic64_add_unchecked(child_event->total_time_running,
79801 &parent_event->child_total_time_running);
79802
79803 /*
79804 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
79805 index ca65997..60df03d 100644
79806 --- a/kernel/events/internal.h
79807 +++ b/kernel/events/internal.h
79808 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
79809 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
79810 }
79811
79812 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
79813 -static inline unsigned int \
79814 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
79815 +static inline unsigned long \
79816 func_name(struct perf_output_handle *handle, \
79817 - const void *buf, unsigned int len) \
79818 + const void user *buf, unsigned long len) \
79819 { \
79820 unsigned long size, written; \
79821 \
79822 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
79823 return n;
79824 }
79825
79826 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
79827 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
79828
79829 #define MEMCPY_SKIP(dst, src, n) (n)
79830
79831 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
79832 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
79833
79834 #ifndef arch_perf_out_copy_user
79835 #define arch_perf_out_copy_user __copy_from_user_inatomic
79836 #endif
79837
79838 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
79839 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
79840
79841 /* Callchain handling */
79842 extern struct perf_callchain_entry *
79843 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
79844 index ad8e1bd..fed7ba9 100644
79845 --- a/kernel/events/uprobes.c
79846 +++ b/kernel/events/uprobes.c
79847 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
79848 {
79849 struct page *page;
79850 uprobe_opcode_t opcode;
79851 - int result;
79852 + long result;
79853
79854 pagefault_disable();
79855 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
79856 diff --git a/kernel/exit.c b/kernel/exit.c
79857 index a949819..a5f127d 100644
79858 --- a/kernel/exit.c
79859 +++ b/kernel/exit.c
79860 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
79861 struct task_struct *leader;
79862 int zap_leader;
79863 repeat:
79864 +#ifdef CONFIG_NET
79865 + gr_del_task_from_ip_table(p);
79866 +#endif
79867 +
79868 /* don't need to get the RCU readlock here - the process is dead and
79869 * can't be modifying its own credentials. But shut RCU-lockdep up */
79870 rcu_read_lock();
79871 @@ -329,7 +333,7 @@ int allow_signal(int sig)
79872 * know it'll be handled, so that they don't get converted to
79873 * SIGKILL or just silently dropped.
79874 */
79875 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
79876 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
79877 recalc_sigpending();
79878 spin_unlock_irq(&current->sighand->siglock);
79879 return 0;
79880 @@ -698,6 +702,8 @@ void do_exit(long code)
79881 struct task_struct *tsk = current;
79882 int group_dead;
79883
79884 + set_fs(USER_DS);
79885 +
79886 profile_task_exit(tsk);
79887
79888 WARN_ON(blk_needs_flush_plug(tsk));
79889 @@ -714,7 +720,6 @@ void do_exit(long code)
79890 * mm_release()->clear_child_tid() from writing to a user-controlled
79891 * kernel address.
79892 */
79893 - set_fs(USER_DS);
79894
79895 ptrace_event(PTRACE_EVENT_EXIT, code);
79896
79897 @@ -773,6 +778,9 @@ void do_exit(long code)
79898 tsk->exit_code = code;
79899 taskstats_exit(tsk, group_dead);
79900
79901 + gr_acl_handle_psacct(tsk, code);
79902 + gr_acl_handle_exit();
79903 +
79904 exit_mm(tsk);
79905
79906 if (group_dead)
79907 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
79908 * Take down every thread in the group. This is called by fatal signals
79909 * as well as by sys_exit_group (below).
79910 */
79911 -void
79912 +__noreturn void
79913 do_group_exit(int exit_code)
79914 {
79915 struct signal_struct *sig = current->signal;
79916 diff --git a/kernel/fork.c b/kernel/fork.c
79917 index 200a7a2..43e52da 100644
79918 --- a/kernel/fork.c
79919 +++ b/kernel/fork.c
79920 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
79921 *stackend = STACK_END_MAGIC; /* for overflow detection */
79922
79923 #ifdef CONFIG_CC_STACKPROTECTOR
79924 - tsk->stack_canary = get_random_int();
79925 + tsk->stack_canary = pax_get_random_long();
79926 #endif
79927
79928 /*
79929 @@ -345,13 +345,81 @@ free_tsk:
79930 }
79931
79932 #ifdef CONFIG_MMU
79933 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
79934 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
79935 {
79936 - struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
79937 - struct rb_node **rb_link, *rb_parent;
79938 - int retval;
79939 + struct vm_area_struct *tmp;
79940 unsigned long charge;
79941 struct mempolicy *pol;
79942 + struct file *file;
79943 +
79944 + charge = 0;
79945 + if (mpnt->vm_flags & VM_ACCOUNT) {
79946 + unsigned long len = vma_pages(mpnt);
79947 +
79948 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
79949 + goto fail_nomem;
79950 + charge = len;
79951 + }
79952 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
79953 + if (!tmp)
79954 + goto fail_nomem;
79955 + *tmp = *mpnt;
79956 + tmp->vm_mm = mm;
79957 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
79958 + pol = mpol_dup(vma_policy(mpnt));
79959 + if (IS_ERR(pol))
79960 + goto fail_nomem_policy;
79961 + vma_set_policy(tmp, pol);
79962 + if (anon_vma_fork(tmp, mpnt))
79963 + goto fail_nomem_anon_vma_fork;
79964 + tmp->vm_flags &= ~VM_LOCKED;
79965 + tmp->vm_next = tmp->vm_prev = NULL;
79966 + tmp->vm_mirror = NULL;
79967 + file = tmp->vm_file;
79968 + if (file) {
79969 + struct inode *inode = file_inode(file);
79970 + struct address_space *mapping = file->f_mapping;
79971 +
79972 + get_file(file);
79973 + if (tmp->vm_flags & VM_DENYWRITE)
79974 + atomic_dec(&inode->i_writecount);
79975 + mutex_lock(&mapping->i_mmap_mutex);
79976 + if (tmp->vm_flags & VM_SHARED)
79977 + mapping->i_mmap_writable++;
79978 + flush_dcache_mmap_lock(mapping);
79979 + /* insert tmp into the share list, just after mpnt */
79980 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
79981 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
79982 + else
79983 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
79984 + flush_dcache_mmap_unlock(mapping);
79985 + mutex_unlock(&mapping->i_mmap_mutex);
79986 + }
79987 +
79988 + /*
79989 + * Clear hugetlb-related page reserves for children. This only
79990 + * affects MAP_PRIVATE mappings. Faults generated by the child
79991 + * are not guaranteed to succeed, even if read-only
79992 + */
79993 + if (is_vm_hugetlb_page(tmp))
79994 + reset_vma_resv_huge_pages(tmp);
79995 +
79996 + return tmp;
79997 +
79998 +fail_nomem_anon_vma_fork:
79999 + mpol_put(pol);
80000 +fail_nomem_policy:
80001 + kmem_cache_free(vm_area_cachep, tmp);
80002 +fail_nomem:
80003 + vm_unacct_memory(charge);
80004 + return NULL;
80005 +}
80006 +
80007 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80008 +{
80009 + struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80010 + struct rb_node **rb_link, *rb_parent;
80011 + int retval;
80012
80013 uprobe_start_dup_mmap();
80014 down_write(&oldmm->mmap_sem);
80015 @@ -380,57 +448,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80016
80017 prev = NULL;
80018 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
80019 - struct file *file;
80020 -
80021 if (mpnt->vm_flags & VM_DONTCOPY) {
80022 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
80023 -vma_pages(mpnt));
80024 continue;
80025 }
80026 - charge = 0;
80027 - if (mpnt->vm_flags & VM_ACCOUNT) {
80028 - unsigned long len = vma_pages(mpnt);
80029 -
80030 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80031 - goto fail_nomem;
80032 - charge = len;
80033 - }
80034 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80035 - if (!tmp)
80036 - goto fail_nomem;
80037 - *tmp = *mpnt;
80038 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
80039 - pol = mpol_dup(vma_policy(mpnt));
80040 - retval = PTR_ERR(pol);
80041 - if (IS_ERR(pol))
80042 - goto fail_nomem_policy;
80043 - vma_set_policy(tmp, pol);
80044 - tmp->vm_mm = mm;
80045 - if (anon_vma_fork(tmp, mpnt))
80046 - goto fail_nomem_anon_vma_fork;
80047 - tmp->vm_flags &= ~VM_LOCKED;
80048 - tmp->vm_next = tmp->vm_prev = NULL;
80049 - file = tmp->vm_file;
80050 - if (file) {
80051 - struct inode *inode = file_inode(file);
80052 - struct address_space *mapping = file->f_mapping;
80053 -
80054 - get_file(file);
80055 - if (tmp->vm_flags & VM_DENYWRITE)
80056 - atomic_dec(&inode->i_writecount);
80057 - mutex_lock(&mapping->i_mmap_mutex);
80058 - if (tmp->vm_flags & VM_SHARED)
80059 - mapping->i_mmap_writable++;
80060 - flush_dcache_mmap_lock(mapping);
80061 - /* insert tmp into the share list, just after mpnt */
80062 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80063 - vma_nonlinear_insert(tmp,
80064 - &mapping->i_mmap_nonlinear);
80065 - else
80066 - vma_interval_tree_insert_after(tmp, mpnt,
80067 - &mapping->i_mmap);
80068 - flush_dcache_mmap_unlock(mapping);
80069 - mutex_unlock(&mapping->i_mmap_mutex);
80070 + tmp = dup_vma(mm, oldmm, mpnt);
80071 + if (!tmp) {
80072 + retval = -ENOMEM;
80073 + goto out;
80074 }
80075
80076 /*
80077 @@ -462,6 +488,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80078 if (retval)
80079 goto out;
80080 }
80081 +
80082 +#ifdef CONFIG_PAX_SEGMEXEC
80083 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
80084 + struct vm_area_struct *mpnt_m;
80085 +
80086 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
80087 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
80088 +
80089 + if (!mpnt->vm_mirror)
80090 + continue;
80091 +
80092 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
80093 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
80094 + mpnt->vm_mirror = mpnt_m;
80095 + } else {
80096 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
80097 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
80098 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
80099 + mpnt->vm_mirror->vm_mirror = mpnt;
80100 + }
80101 + }
80102 + BUG_ON(mpnt_m);
80103 + }
80104 +#endif
80105 +
80106 /* a new mm has just been created */
80107 arch_dup_mmap(oldmm, mm);
80108 retval = 0;
80109 @@ -471,14 +522,6 @@ out:
80110 up_write(&oldmm->mmap_sem);
80111 uprobe_end_dup_mmap();
80112 return retval;
80113 -fail_nomem_anon_vma_fork:
80114 - mpol_put(pol);
80115 -fail_nomem_policy:
80116 - kmem_cache_free(vm_area_cachep, tmp);
80117 -fail_nomem:
80118 - retval = -ENOMEM;
80119 - vm_unacct_memory(charge);
80120 - goto out;
80121 }
80122
80123 static inline int mm_alloc_pgd(struct mm_struct *mm)
80124 @@ -691,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
80125 return ERR_PTR(err);
80126
80127 mm = get_task_mm(task);
80128 - if (mm && mm != current->mm &&
80129 - !ptrace_may_access(task, mode)) {
80130 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
80131 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
80132 mmput(mm);
80133 mm = ERR_PTR(-EACCES);
80134 }
80135 @@ -914,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
80136 spin_unlock(&fs->lock);
80137 return -EAGAIN;
80138 }
80139 - fs->users++;
80140 + atomic_inc(&fs->users);
80141 spin_unlock(&fs->lock);
80142 return 0;
80143 }
80144 tsk->fs = copy_fs_struct(fs);
80145 if (!tsk->fs)
80146 return -ENOMEM;
80147 + /* Carry through gr_chroot_dentry and is_chrooted instead
80148 + of recomputing it here. Already copied when the task struct
80149 + is duplicated. This allows pivot_root to not be treated as
80150 + a chroot
80151 + */
80152 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
80153 +
80154 return 0;
80155 }
80156
80157 @@ -1131,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
80158 * parts of the process environment (as per the clone
80159 * flags). The actual kick-off is left to the caller.
80160 */
80161 -static struct task_struct *copy_process(unsigned long clone_flags,
80162 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
80163 unsigned long stack_start,
80164 unsigned long stack_size,
80165 int __user *child_tidptr,
80166 @@ -1201,6 +1251,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80167 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
80168 #endif
80169 retval = -EAGAIN;
80170 +
80171 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
80172 +
80173 if (atomic_read(&p->real_cred->user->processes) >=
80174 task_rlimit(p, RLIMIT_NPROC)) {
80175 if (p->real_cred->user != INIT_USER &&
80176 @@ -1450,6 +1503,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80177 goto bad_fork_free_pid;
80178 }
80179
80180 + /* synchronizes with gr_set_acls()
80181 + we need to call this past the point of no return for fork()
80182 + */
80183 + gr_copy_label(p);
80184 +
80185 if (likely(p->pid)) {
80186 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
80187
80188 @@ -1535,6 +1593,8 @@ bad_fork_cleanup_count:
80189 bad_fork_free:
80190 free_task(p);
80191 fork_out:
80192 + gr_log_forkfail(retval);
80193 +
80194 return ERR_PTR(retval);
80195 }
80196
80197 @@ -1605,6 +1665,7 @@ long do_fork(unsigned long clone_flags,
80198
80199 p = copy_process(clone_flags, stack_start, stack_size,
80200 child_tidptr, NULL, trace);
80201 + add_latent_entropy();
80202 /*
80203 * Do this prior waking up the new thread - the thread pointer
80204 * might get invalid after that point, if the thread exits quickly.
80205 @@ -1619,6 +1680,8 @@ long do_fork(unsigned long clone_flags,
80206 if (clone_flags & CLONE_PARENT_SETTID)
80207 put_user(nr, parent_tidptr);
80208
80209 + gr_handle_brute_check();
80210 +
80211 if (clone_flags & CLONE_VFORK) {
80212 p->vfork_done = &vfork;
80213 init_completion(&vfork);
80214 @@ -1735,7 +1798,7 @@ void __init proc_caches_init(void)
80215 mm_cachep = kmem_cache_create("mm_struct",
80216 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
80217 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
80218 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
80219 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
80220 mmap_init();
80221 nsproxy_cache_init();
80222 }
80223 @@ -1775,7 +1838,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
80224 return 0;
80225
80226 /* don't need lock here; in the worst case we'll do useless copy */
80227 - if (fs->users == 1)
80228 + if (atomic_read(&fs->users) == 1)
80229 return 0;
80230
80231 *new_fsp = copy_fs_struct(fs);
80232 @@ -1887,7 +1950,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
80233 fs = current->fs;
80234 spin_lock(&fs->lock);
80235 current->fs = new_fs;
80236 - if (--fs->users)
80237 + gr_set_chroot_entries(current, &current->fs->root);
80238 + if (atomic_dec_return(&fs->users))
80239 new_fs = NULL;
80240 else
80241 new_fs = fs;
80242 diff --git a/kernel/futex.c b/kernel/futex.c
80243 index c3a1a55..e32b4a98 100644
80244 --- a/kernel/futex.c
80245 +++ b/kernel/futex.c
80246 @@ -54,6 +54,7 @@
80247 #include <linux/mount.h>
80248 #include <linux/pagemap.h>
80249 #include <linux/syscalls.h>
80250 +#include <linux/ptrace.h>
80251 #include <linux/signal.h>
80252 #include <linux/export.h>
80253 #include <linux/magic.h>
80254 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
80255 struct page *page, *page_head;
80256 int err, ro = 0;
80257
80258 +#ifdef CONFIG_PAX_SEGMEXEC
80259 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
80260 + return -EFAULT;
80261 +#endif
80262 +
80263 /*
80264 * The futex address must be "naturally" aligned.
80265 */
80266 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
80267
80268 static int get_futex_value_locked(u32 *dest, u32 __user *from)
80269 {
80270 - int ret;
80271 + unsigned long ret;
80272
80273 pagefault_disable();
80274 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
80275 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
80276 {
80277 u32 curval;
80278 int i;
80279 + mm_segment_t oldfs;
80280
80281 /*
80282 * This will fail and we want it. Some arch implementations do
80283 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
80284 * implementation, the non-functional ones will return
80285 * -ENOSYS.
80286 */
80287 + oldfs = get_fs();
80288 + set_fs(USER_DS);
80289 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
80290 futex_cmpxchg_enabled = 1;
80291 + set_fs(oldfs);
80292
80293 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
80294 plist_head_init(&futex_queues[i].chain);
80295 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
80296 index f9f44fd..29885e4 100644
80297 --- a/kernel/futex_compat.c
80298 +++ b/kernel/futex_compat.c
80299 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
80300 return 0;
80301 }
80302
80303 -static void __user *futex_uaddr(struct robust_list __user *entry,
80304 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
80305 compat_long_t futex_offset)
80306 {
80307 compat_uptr_t base = ptr_to_compat(entry);
80308 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
80309 index 9b22d03..6295b62 100644
80310 --- a/kernel/gcov/base.c
80311 +++ b/kernel/gcov/base.c
80312 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
80313 }
80314
80315 #ifdef CONFIG_MODULES
80316 -static inline int within(void *addr, void *start, unsigned long size)
80317 -{
80318 - return ((addr >= start) && (addr < start + size));
80319 -}
80320 -
80321 /* Update list and generate events when modules are unloaded. */
80322 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80323 void *data)
80324 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80325 prev = NULL;
80326 /* Remove entries located in module from linked list. */
80327 for (info = gcov_info_head; info; info = info->next) {
80328 - if (within(info, mod->module_core, mod->core_size)) {
80329 + if (within_module_core_rw((unsigned long)info, mod)) {
80330 if (prev)
80331 prev->next = info->next;
80332 else
80333 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
80334 index 383319b..56ebb13 100644
80335 --- a/kernel/hrtimer.c
80336 +++ b/kernel/hrtimer.c
80337 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
80338 local_irq_restore(flags);
80339 }
80340
80341 -static void run_hrtimer_softirq(struct softirq_action *h)
80342 +static __latent_entropy void run_hrtimer_softirq(void)
80343 {
80344 hrtimer_peek_ahead_timers();
80345 }
80346 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
80347 index 55fcce6..0e4cf34 100644
80348 --- a/kernel/irq_work.c
80349 +++ b/kernel/irq_work.c
80350 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
80351 return NOTIFY_OK;
80352 }
80353
80354 -static struct notifier_block cpu_notify;
80355 +static struct notifier_block cpu_notify = {
80356 + .notifier_call = irq_work_cpu_notify,
80357 + .priority = 0,
80358 +};
80359
80360 static __init int irq_work_init_cpu_notifier(void)
80361 {
80362 - cpu_notify.notifier_call = irq_work_cpu_notify;
80363 - cpu_notify.priority = 0;
80364 register_cpu_notifier(&cpu_notify);
80365 return 0;
80366 }
80367 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
80368 index 60f48fa..7f3a770 100644
80369 --- a/kernel/jump_label.c
80370 +++ b/kernel/jump_label.c
80371 @@ -13,6 +13,7 @@
80372 #include <linux/sort.h>
80373 #include <linux/err.h>
80374 #include <linux/static_key.h>
80375 +#include <linux/mm.h>
80376
80377 #ifdef HAVE_JUMP_LABEL
80378
80379 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
80380
80381 size = (((unsigned long)stop - (unsigned long)start)
80382 / sizeof(struct jump_entry));
80383 + pax_open_kernel();
80384 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
80385 + pax_close_kernel();
80386 }
80387
80388 static void jump_label_update(struct static_key *key, int enable);
80389 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
80390 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
80391 struct jump_entry *iter;
80392
80393 + pax_open_kernel();
80394 for (iter = iter_start; iter < iter_stop; iter++) {
80395 if (within_module_init(iter->code, mod))
80396 iter->code = 0;
80397 }
80398 + pax_close_kernel();
80399 }
80400
80401 static int
80402 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
80403 index 3127ad5..159d880 100644
80404 --- a/kernel/kallsyms.c
80405 +++ b/kernel/kallsyms.c
80406 @@ -11,6 +11,9 @@
80407 * Changed the compression method from stem compression to "table lookup"
80408 * compression (see scripts/kallsyms.c for a more complete description)
80409 */
80410 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80411 +#define __INCLUDED_BY_HIDESYM 1
80412 +#endif
80413 #include <linux/kallsyms.h>
80414 #include <linux/module.h>
80415 #include <linux/init.h>
80416 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
80417
80418 static inline int is_kernel_inittext(unsigned long addr)
80419 {
80420 + if (system_state != SYSTEM_BOOTING)
80421 + return 0;
80422 +
80423 if (addr >= (unsigned long)_sinittext
80424 && addr <= (unsigned long)_einittext)
80425 return 1;
80426 return 0;
80427 }
80428
80429 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80430 +#ifdef CONFIG_MODULES
80431 +static inline int is_module_text(unsigned long addr)
80432 +{
80433 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
80434 + return 1;
80435 +
80436 + addr = ktla_ktva(addr);
80437 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
80438 +}
80439 +#else
80440 +static inline int is_module_text(unsigned long addr)
80441 +{
80442 + return 0;
80443 +}
80444 +#endif
80445 +#endif
80446 +
80447 static inline int is_kernel_text(unsigned long addr)
80448 {
80449 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
80450 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
80451
80452 static inline int is_kernel(unsigned long addr)
80453 {
80454 +
80455 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80456 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
80457 + return 1;
80458 +
80459 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
80460 +#else
80461 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
80462 +#endif
80463 +
80464 return 1;
80465 return in_gate_area_no_mm(addr);
80466 }
80467
80468 static int is_ksym_addr(unsigned long addr)
80469 {
80470 +
80471 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
80472 + if (is_module_text(addr))
80473 + return 0;
80474 +#endif
80475 +
80476 if (all_var)
80477 return is_kernel(addr);
80478
80479 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
80480
80481 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
80482 {
80483 - iter->name[0] = '\0';
80484 iter->nameoff = get_symbol_offset(new_pos);
80485 iter->pos = new_pos;
80486 }
80487 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
80488 {
80489 struct kallsym_iter *iter = m->private;
80490
80491 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80492 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
80493 + return 0;
80494 +#endif
80495 +
80496 /* Some debugging symbols have no name. Ignore them. */
80497 if (!iter->name[0])
80498 return 0;
80499 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
80500 */
80501 type = iter->exported ? toupper(iter->type) :
80502 tolower(iter->type);
80503 +
80504 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
80505 type, iter->name, iter->module_name);
80506 } else
80507 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
80508 struct kallsym_iter *iter;
80509 int ret;
80510
80511 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
80512 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
80513 if (!iter)
80514 return -ENOMEM;
80515 reset_iter(iter, 0);
80516 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
80517 index e30ac0f..3528cac 100644
80518 --- a/kernel/kcmp.c
80519 +++ b/kernel/kcmp.c
80520 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
80521 struct task_struct *task1, *task2;
80522 int ret;
80523
80524 +#ifdef CONFIG_GRKERNSEC
80525 + return -ENOSYS;
80526 +#endif
80527 +
80528 rcu_read_lock();
80529
80530 /*
80531 diff --git a/kernel/kexec.c b/kernel/kexec.c
80532 index 59f7b55..4022f65 100644
80533 --- a/kernel/kexec.c
80534 +++ b/kernel/kexec.c
80535 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
80536 unsigned long flags)
80537 {
80538 struct compat_kexec_segment in;
80539 - struct kexec_segment out, __user *ksegments;
80540 + struct kexec_segment out;
80541 + struct kexec_segment __user *ksegments;
80542 unsigned long i, result;
80543
80544 /* Don't allow clients that don't understand the native
80545 diff --git a/kernel/kmod.c b/kernel/kmod.c
80546 index fb32636..2fe8775 100644
80547 --- a/kernel/kmod.c
80548 +++ b/kernel/kmod.c
80549 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
80550 kfree(info->argv);
80551 }
80552
80553 -static int call_modprobe(char *module_name, int wait)
80554 +static int call_modprobe(char *module_name, char *module_param, int wait)
80555 {
80556 struct subprocess_info *info;
80557 static char *envp[] = {
80558 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
80559 NULL
80560 };
80561
80562 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
80563 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
80564 if (!argv)
80565 goto out;
80566
80567 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
80568 argv[1] = "-q";
80569 argv[2] = "--";
80570 argv[3] = module_name; /* check free_modprobe_argv() */
80571 - argv[4] = NULL;
80572 + argv[4] = module_param;
80573 + argv[5] = NULL;
80574
80575 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
80576 NULL, free_modprobe_argv, NULL);
80577 @@ -129,9 +130,8 @@ out:
80578 * If module auto-loading support is disabled then this function
80579 * becomes a no-operation.
80580 */
80581 -int __request_module(bool wait, const char *fmt, ...)
80582 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
80583 {
80584 - va_list args;
80585 char module_name[MODULE_NAME_LEN];
80586 unsigned int max_modprobes;
80587 int ret;
80588 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
80589 if (!modprobe_path[0])
80590 return 0;
80591
80592 - va_start(args, fmt);
80593 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
80594 - va_end(args);
80595 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
80596 if (ret >= MODULE_NAME_LEN)
80597 return -ENAMETOOLONG;
80598
80599 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
80600 if (ret)
80601 return ret;
80602
80603 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
80604 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
80605 + /* hack to workaround consolekit/udisks stupidity */
80606 + read_lock(&tasklist_lock);
80607 + if (!strcmp(current->comm, "mount") &&
80608 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
80609 + read_unlock(&tasklist_lock);
80610 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
80611 + return -EPERM;
80612 + }
80613 + read_unlock(&tasklist_lock);
80614 + }
80615 +#endif
80616 +
80617 /* If modprobe needs a service that is in a module, we get a recursive
80618 * loop. Limit the number of running kmod threads to max_threads/2 or
80619 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
80620 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
80621
80622 trace_module_request(module_name, wait, _RET_IP_);
80623
80624 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
80625 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
80626
80627 atomic_dec(&kmod_concurrent);
80628 return ret;
80629 }
80630 +
80631 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
80632 +{
80633 + va_list args;
80634 + int ret;
80635 +
80636 + va_start(args, fmt);
80637 + ret = ____request_module(wait, module_param, fmt, args);
80638 + va_end(args);
80639 +
80640 + return ret;
80641 +}
80642 +
80643 +int __request_module(bool wait, const char *fmt, ...)
80644 +{
80645 + va_list args;
80646 + int ret;
80647 +
80648 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
80649 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
80650 + char module_param[MODULE_NAME_LEN];
80651 +
80652 + memset(module_param, 0, sizeof(module_param));
80653 +
80654 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
80655 +
80656 + va_start(args, fmt);
80657 + ret = ____request_module(wait, module_param, fmt, args);
80658 + va_end(args);
80659 +
80660 + return ret;
80661 + }
80662 +#endif
80663 +
80664 + va_start(args, fmt);
80665 + ret = ____request_module(wait, NULL, fmt, args);
80666 + va_end(args);
80667 +
80668 + return ret;
80669 +}
80670 +
80671 EXPORT_SYMBOL(__request_module);
80672 #endif /* CONFIG_MODULES */
80673
80674 @@ -303,7 +356,7 @@ static int wait_for_helper(void *data)
80675 *
80676 * Thus the __user pointer cast is valid here.
80677 */
80678 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
80679 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
80680
80681 /*
80682 * If ret is 0, either ____call_usermodehelper failed and the
80683 @@ -646,7 +699,7 @@ EXPORT_SYMBOL(call_usermodehelper);
80684 static int proc_cap_handler(struct ctl_table *table, int write,
80685 void __user *buffer, size_t *lenp, loff_t *ppos)
80686 {
80687 - struct ctl_table t;
80688 + ctl_table_no_const t;
80689 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
80690 kernel_cap_t new_cap;
80691 int err, i;
80692 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
80693 index 6e33498..3133bd3 100644
80694 --- a/kernel/kprobes.c
80695 +++ b/kernel/kprobes.c
80696 @@ -31,6 +31,9 @@
80697 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
80698 * <prasanna@in.ibm.com> added function-return probes.
80699 */
80700 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80701 +#define __INCLUDED_BY_HIDESYM 1
80702 +#endif
80703 #include <linux/kprobes.h>
80704 #include <linux/hash.h>
80705 #include <linux/init.h>
80706 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
80707 * kernel image and loaded module images reside. This is required
80708 * so x86_64 can correctly handle the %rip-relative fixups.
80709 */
80710 - kip->insns = module_alloc(PAGE_SIZE);
80711 + kip->insns = module_alloc_exec(PAGE_SIZE);
80712 if (!kip->insns) {
80713 kfree(kip);
80714 return NULL;
80715 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
80716 */
80717 if (!list_is_singular(&kip->list)) {
80718 list_del(&kip->list);
80719 - module_free(NULL, kip->insns);
80720 + module_free_exec(NULL, kip->insns);
80721 kfree(kip);
80722 }
80723 return 1;
80724 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
80725 {
80726 int i, err = 0;
80727 unsigned long offset = 0, size = 0;
80728 - char *modname, namebuf[128];
80729 + char *modname, namebuf[KSYM_NAME_LEN];
80730 const char *symbol_name;
80731 void *addr;
80732 struct kprobe_blackpoint *kb;
80733 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
80734 kprobe_type = "k";
80735
80736 if (sym)
80737 - seq_printf(pi, "%p %s %s+0x%x %s ",
80738 + seq_printf(pi, "%pK %s %s+0x%x %s ",
80739 p->addr, kprobe_type, sym, offset,
80740 (modname ? modname : " "));
80741 else
80742 - seq_printf(pi, "%p %s %p ",
80743 + seq_printf(pi, "%pK %s %pK ",
80744 p->addr, kprobe_type, p->addr);
80745
80746 if (!pp)
80747 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
80748 const char *sym = NULL;
80749 unsigned int i = *(loff_t *) v;
80750 unsigned long offset = 0;
80751 - char *modname, namebuf[128];
80752 + char *modname, namebuf[KSYM_NAME_LEN];
80753
80754 head = &kprobe_table[i];
80755 preempt_disable();
80756 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
80757 index 6ada93c..dce7d5d 100644
80758 --- a/kernel/ksysfs.c
80759 +++ b/kernel/ksysfs.c
80760 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
80761 {
80762 if (count+1 > UEVENT_HELPER_PATH_LEN)
80763 return -ENOENT;
80764 + if (!capable(CAP_SYS_ADMIN))
80765 + return -EPERM;
80766 memcpy(uevent_helper, buf, count);
80767 uevent_helper[count] = '\0';
80768 if (count && uevent_helper[count-1] == '\n')
80769 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
80770 return count;
80771 }
80772
80773 -static struct bin_attribute notes_attr = {
80774 +static bin_attribute_no_const notes_attr __read_only = {
80775 .attr = {
80776 .name = "notes",
80777 .mode = S_IRUGO,
80778 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
80779 index e16c45b..6f49c48 100644
80780 --- a/kernel/lockdep.c
80781 +++ b/kernel/lockdep.c
80782 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
80783 end = (unsigned long) &_end,
80784 addr = (unsigned long) obj;
80785
80786 +#ifdef CONFIG_PAX_KERNEXEC
80787 + start = ktla_ktva(start);
80788 +#endif
80789 +
80790 /*
80791 * static variable?
80792 */
80793 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
80794 if (!static_obj(lock->key)) {
80795 debug_locks_off();
80796 printk("INFO: trying to register non-static key.\n");
80797 + printk("lock:%pS key:%pS.\n", lock, lock->key);
80798 printk("the code is fine but needs lockdep annotation.\n");
80799 printk("turning off the locking correctness validator.\n");
80800 dump_stack();
80801 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
80802 if (!class)
80803 return 0;
80804 }
80805 - atomic_inc((atomic_t *)&class->ops);
80806 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
80807 if (very_verbose(class)) {
80808 printk("\nacquire class [%p] %s", class->key, class->name);
80809 if (class->name_version > 1)
80810 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
80811 index b2c71c5..7b88d63 100644
80812 --- a/kernel/lockdep_proc.c
80813 +++ b/kernel/lockdep_proc.c
80814 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
80815 return 0;
80816 }
80817
80818 - seq_printf(m, "%p", class->key);
80819 + seq_printf(m, "%pK", class->key);
80820 #ifdef CONFIG_DEBUG_LOCKDEP
80821 seq_printf(m, " OPS:%8ld", class->ops);
80822 #endif
80823 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
80824
80825 list_for_each_entry(entry, &class->locks_after, entry) {
80826 if (entry->distance == 1) {
80827 - seq_printf(m, " -> [%p] ", entry->class->key);
80828 + seq_printf(m, " -> [%pK] ", entry->class->key);
80829 print_name(m, entry->class);
80830 seq_puts(m, "\n");
80831 }
80832 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
80833 if (!class->key)
80834 continue;
80835
80836 - seq_printf(m, "[%p] ", class->key);
80837 + seq_printf(m, "[%pK] ", class->key);
80838 print_name(m, class);
80839 seq_puts(m, "\n");
80840 }
80841 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
80842 if (!i)
80843 seq_line(m, '-', 40-namelen, namelen);
80844
80845 - snprintf(ip, sizeof(ip), "[<%p>]",
80846 + snprintf(ip, sizeof(ip), "[<%pK>]",
80847 (void *)class->contention_point[i]);
80848 seq_printf(m, "%40s %14lu %29s %pS\n",
80849 name, stats->contention_point[i],
80850 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
80851 if (!i)
80852 seq_line(m, '-', 40-namelen, namelen);
80853
80854 - snprintf(ip, sizeof(ip), "[<%p>]",
80855 + snprintf(ip, sizeof(ip), "[<%pK>]",
80856 (void *)class->contending_point[i]);
80857 seq_printf(m, "%40s %14lu %29s %pS\n",
80858 name, stats->contending_point[i],
80859 diff --git a/kernel/module.c b/kernel/module.c
80860 index 2069158..71101bb 100644
80861 --- a/kernel/module.c
80862 +++ b/kernel/module.c
80863 @@ -61,6 +61,7 @@
80864 #include <linux/pfn.h>
80865 #include <linux/bsearch.h>
80866 #include <linux/fips.h>
80867 +#include <linux/grsecurity.h>
80868 #include <uapi/linux/module.h>
80869 #include "module-internal.h"
80870
80871 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
80872
80873 /* Bounds of module allocation, for speeding __module_address.
80874 * Protected by module_mutex. */
80875 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
80876 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
80877 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
80878
80879 int register_module_notifier(struct notifier_block * nb)
80880 {
80881 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
80882 return true;
80883
80884 list_for_each_entry_rcu(mod, &modules, list) {
80885 - struct symsearch arr[] = {
80886 + struct symsearch modarr[] = {
80887 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
80888 NOT_GPL_ONLY, false },
80889 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
80890 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
80891 if (mod->state == MODULE_STATE_UNFORMED)
80892 continue;
80893
80894 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
80895 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
80896 return true;
80897 }
80898 return false;
80899 @@ -490,7 +492,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
80900 if (!pcpusec->sh_size)
80901 return 0;
80902
80903 - if (align > PAGE_SIZE) {
80904 + if (align-1 >= PAGE_SIZE) {
80905 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
80906 mod->name, align, PAGE_SIZE);
80907 align = PAGE_SIZE;
80908 @@ -1096,7 +1098,7 @@ struct module_attribute module_uevent =
80909 static ssize_t show_coresize(struct module_attribute *mattr,
80910 struct module_kobject *mk, char *buffer)
80911 {
80912 - return sprintf(buffer, "%u\n", mk->mod->core_size);
80913 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
80914 }
80915
80916 static struct module_attribute modinfo_coresize =
80917 @@ -1105,7 +1107,7 @@ static struct module_attribute modinfo_coresize =
80918 static ssize_t show_initsize(struct module_attribute *mattr,
80919 struct module_kobject *mk, char *buffer)
80920 {
80921 - return sprintf(buffer, "%u\n", mk->mod->init_size);
80922 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
80923 }
80924
80925 static struct module_attribute modinfo_initsize =
80926 @@ -1320,7 +1322,7 @@ resolve_symbol_wait(struct module *mod,
80927 */
80928 #ifdef CONFIG_SYSFS
80929
80930 -#ifdef CONFIG_KALLSYMS
80931 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
80932 static inline bool sect_empty(const Elf_Shdr *sect)
80933 {
80934 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
80935 @@ -1460,7 +1462,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
80936 {
80937 unsigned int notes, loaded, i;
80938 struct module_notes_attrs *notes_attrs;
80939 - struct bin_attribute *nattr;
80940 + bin_attribute_no_const *nattr;
80941
80942 /* failed to create section attributes, so can't create notes */
80943 if (!mod->sect_attrs)
80944 @@ -1572,7 +1574,7 @@ static void del_usage_links(struct module *mod)
80945 static int module_add_modinfo_attrs(struct module *mod)
80946 {
80947 struct module_attribute *attr;
80948 - struct module_attribute *temp_attr;
80949 + module_attribute_no_const *temp_attr;
80950 int error = 0;
80951 int i;
80952
80953 @@ -1786,21 +1788,21 @@ static void set_section_ro_nx(void *base,
80954
80955 static void unset_module_core_ro_nx(struct module *mod)
80956 {
80957 - set_page_attributes(mod->module_core + mod->core_text_size,
80958 - mod->module_core + mod->core_size,
80959 + set_page_attributes(mod->module_core_rw,
80960 + mod->module_core_rw + mod->core_size_rw,
80961 set_memory_x);
80962 - set_page_attributes(mod->module_core,
80963 - mod->module_core + mod->core_ro_size,
80964 + set_page_attributes(mod->module_core_rx,
80965 + mod->module_core_rx + mod->core_size_rx,
80966 set_memory_rw);
80967 }
80968
80969 static void unset_module_init_ro_nx(struct module *mod)
80970 {
80971 - set_page_attributes(mod->module_init + mod->init_text_size,
80972 - mod->module_init + mod->init_size,
80973 + set_page_attributes(mod->module_init_rw,
80974 + mod->module_init_rw + mod->init_size_rw,
80975 set_memory_x);
80976 - set_page_attributes(mod->module_init,
80977 - mod->module_init + mod->init_ro_size,
80978 + set_page_attributes(mod->module_init_rx,
80979 + mod->module_init_rx + mod->init_size_rx,
80980 set_memory_rw);
80981 }
80982
80983 @@ -1813,14 +1815,14 @@ void set_all_modules_text_rw(void)
80984 list_for_each_entry_rcu(mod, &modules, list) {
80985 if (mod->state == MODULE_STATE_UNFORMED)
80986 continue;
80987 - if ((mod->module_core) && (mod->core_text_size)) {
80988 - set_page_attributes(mod->module_core,
80989 - mod->module_core + mod->core_text_size,
80990 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
80991 + set_page_attributes(mod->module_core_rx,
80992 + mod->module_core_rx + mod->core_size_rx,
80993 set_memory_rw);
80994 }
80995 - if ((mod->module_init) && (mod->init_text_size)) {
80996 - set_page_attributes(mod->module_init,
80997 - mod->module_init + mod->init_text_size,
80998 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
80999 + set_page_attributes(mod->module_init_rx,
81000 + mod->module_init_rx + mod->init_size_rx,
81001 set_memory_rw);
81002 }
81003 }
81004 @@ -1836,14 +1838,14 @@ void set_all_modules_text_ro(void)
81005 list_for_each_entry_rcu(mod, &modules, list) {
81006 if (mod->state == MODULE_STATE_UNFORMED)
81007 continue;
81008 - if ((mod->module_core) && (mod->core_text_size)) {
81009 - set_page_attributes(mod->module_core,
81010 - mod->module_core + mod->core_text_size,
81011 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81012 + set_page_attributes(mod->module_core_rx,
81013 + mod->module_core_rx + mod->core_size_rx,
81014 set_memory_ro);
81015 }
81016 - if ((mod->module_init) && (mod->init_text_size)) {
81017 - set_page_attributes(mod->module_init,
81018 - mod->module_init + mod->init_text_size,
81019 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81020 + set_page_attributes(mod->module_init_rx,
81021 + mod->module_init_rx + mod->init_size_rx,
81022 set_memory_ro);
81023 }
81024 }
81025 @@ -1894,16 +1896,19 @@ static void free_module(struct module *mod)
81026
81027 /* This may be NULL, but that's OK */
81028 unset_module_init_ro_nx(mod);
81029 - module_free(mod, mod->module_init);
81030 + module_free(mod, mod->module_init_rw);
81031 + module_free_exec(mod, mod->module_init_rx);
81032 kfree(mod->args);
81033 percpu_modfree(mod);
81034
81035 /* Free lock-classes: */
81036 - lockdep_free_key_range(mod->module_core, mod->core_size);
81037 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
81038 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
81039
81040 /* Finally, free the core (containing the module structure) */
81041 unset_module_core_ro_nx(mod);
81042 - module_free(mod, mod->module_core);
81043 + module_free_exec(mod, mod->module_core_rx);
81044 + module_free(mod, mod->module_core_rw);
81045
81046 #ifdef CONFIG_MPU
81047 update_protections(current->mm);
81048 @@ -1973,9 +1978,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81049 int ret = 0;
81050 const struct kernel_symbol *ksym;
81051
81052 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81053 + int is_fs_load = 0;
81054 + int register_filesystem_found = 0;
81055 + char *p;
81056 +
81057 + p = strstr(mod->args, "grsec_modharden_fs");
81058 + if (p) {
81059 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
81060 + /* copy \0 as well */
81061 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
81062 + is_fs_load = 1;
81063 + }
81064 +#endif
81065 +
81066 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
81067 const char *name = info->strtab + sym[i].st_name;
81068
81069 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81070 + /* it's a real shame this will never get ripped and copied
81071 + upstream! ;(
81072 + */
81073 + if (is_fs_load && !strcmp(name, "register_filesystem"))
81074 + register_filesystem_found = 1;
81075 +#endif
81076 +
81077 switch (sym[i].st_shndx) {
81078 case SHN_COMMON:
81079 /* We compiled with -fno-common. These are not
81080 @@ -1996,7 +2023,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81081 ksym = resolve_symbol_wait(mod, info, name);
81082 /* Ok if resolved. */
81083 if (ksym && !IS_ERR(ksym)) {
81084 + pax_open_kernel();
81085 sym[i].st_value = ksym->value;
81086 + pax_close_kernel();
81087 break;
81088 }
81089
81090 @@ -2015,11 +2044,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81091 secbase = (unsigned long)mod_percpu(mod);
81092 else
81093 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
81094 + pax_open_kernel();
81095 sym[i].st_value += secbase;
81096 + pax_close_kernel();
81097 break;
81098 }
81099 }
81100
81101 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81102 + if (is_fs_load && !register_filesystem_found) {
81103 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
81104 + ret = -EPERM;
81105 + }
81106 +#endif
81107 +
81108 return ret;
81109 }
81110
81111 @@ -2103,22 +2141,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
81112 || s->sh_entsize != ~0UL
81113 || strstarts(sname, ".init"))
81114 continue;
81115 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
81116 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81117 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
81118 + else
81119 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
81120 pr_debug("\t%s\n", sname);
81121 }
81122 - switch (m) {
81123 - case 0: /* executable */
81124 - mod->core_size = debug_align(mod->core_size);
81125 - mod->core_text_size = mod->core_size;
81126 - break;
81127 - case 1: /* RO: text and ro-data */
81128 - mod->core_size = debug_align(mod->core_size);
81129 - mod->core_ro_size = mod->core_size;
81130 - break;
81131 - case 3: /* whole core */
81132 - mod->core_size = debug_align(mod->core_size);
81133 - break;
81134 - }
81135 }
81136
81137 pr_debug("Init section allocation order:\n");
81138 @@ -2132,23 +2160,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
81139 || s->sh_entsize != ~0UL
81140 || !strstarts(sname, ".init"))
81141 continue;
81142 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
81143 - | INIT_OFFSET_MASK);
81144 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81145 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
81146 + else
81147 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
81148 + s->sh_entsize |= INIT_OFFSET_MASK;
81149 pr_debug("\t%s\n", sname);
81150 }
81151 - switch (m) {
81152 - case 0: /* executable */
81153 - mod->init_size = debug_align(mod->init_size);
81154 - mod->init_text_size = mod->init_size;
81155 - break;
81156 - case 1: /* RO: text and ro-data */
81157 - mod->init_size = debug_align(mod->init_size);
81158 - mod->init_ro_size = mod->init_size;
81159 - break;
81160 - case 3: /* whole init */
81161 - mod->init_size = debug_align(mod->init_size);
81162 - break;
81163 - }
81164 }
81165 }
81166
81167 @@ -2321,7 +2339,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81168
81169 /* Put symbol section at end of init part of module. */
81170 symsect->sh_flags |= SHF_ALLOC;
81171 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
81172 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
81173 info->index.sym) | INIT_OFFSET_MASK;
81174 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
81175
81176 @@ -2338,13 +2356,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81177 }
81178
81179 /* Append room for core symbols at end of core part. */
81180 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
81181 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
81182 - mod->core_size += strtab_size;
81183 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
81184 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
81185 + mod->core_size_rx += strtab_size;
81186
81187 /* Put string table section at end of init part of module. */
81188 strsect->sh_flags |= SHF_ALLOC;
81189 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
81190 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
81191 info->index.str) | INIT_OFFSET_MASK;
81192 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
81193 }
81194 @@ -2362,12 +2380,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81195 /* Make sure we get permanent strtab: don't use info->strtab. */
81196 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
81197
81198 + pax_open_kernel();
81199 +
81200 /* Set types up while we still have access to sections. */
81201 for (i = 0; i < mod->num_symtab; i++)
81202 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
81203
81204 - mod->core_symtab = dst = mod->module_core + info->symoffs;
81205 - mod->core_strtab = s = mod->module_core + info->stroffs;
81206 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
81207 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
81208 src = mod->symtab;
81209 for (ndst = i = 0; i < mod->num_symtab; i++) {
81210 if (i == 0 ||
81211 @@ -2379,6 +2399,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81212 }
81213 }
81214 mod->core_num_syms = ndst;
81215 +
81216 + pax_close_kernel();
81217 }
81218 #else
81219 static inline void layout_symtab(struct module *mod, struct load_info *info)
81220 @@ -2412,17 +2434,33 @@ void * __weak module_alloc(unsigned long size)
81221 return vmalloc_exec(size);
81222 }
81223
81224 -static void *module_alloc_update_bounds(unsigned long size)
81225 +static void *module_alloc_update_bounds_rw(unsigned long size)
81226 {
81227 void *ret = module_alloc(size);
81228
81229 if (ret) {
81230 mutex_lock(&module_mutex);
81231 /* Update module bounds. */
81232 - if ((unsigned long)ret < module_addr_min)
81233 - module_addr_min = (unsigned long)ret;
81234 - if ((unsigned long)ret + size > module_addr_max)
81235 - module_addr_max = (unsigned long)ret + size;
81236 + if ((unsigned long)ret < module_addr_min_rw)
81237 + module_addr_min_rw = (unsigned long)ret;
81238 + if ((unsigned long)ret + size > module_addr_max_rw)
81239 + module_addr_max_rw = (unsigned long)ret + size;
81240 + mutex_unlock(&module_mutex);
81241 + }
81242 + return ret;
81243 +}
81244 +
81245 +static void *module_alloc_update_bounds_rx(unsigned long size)
81246 +{
81247 + void *ret = module_alloc_exec(size);
81248 +
81249 + if (ret) {
81250 + mutex_lock(&module_mutex);
81251 + /* Update module bounds. */
81252 + if ((unsigned long)ret < module_addr_min_rx)
81253 + module_addr_min_rx = (unsigned long)ret;
81254 + if ((unsigned long)ret + size > module_addr_max_rx)
81255 + module_addr_max_rx = (unsigned long)ret + size;
81256 mutex_unlock(&module_mutex);
81257 }
81258 return ret;
81259 @@ -2698,8 +2736,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
81260 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81261 {
81262 const char *modmagic = get_modinfo(info, "vermagic");
81263 + const char *license = get_modinfo(info, "license");
81264 int err;
81265
81266 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
81267 + if (!license || !license_is_gpl_compatible(license))
81268 + return -ENOEXEC;
81269 +#endif
81270 +
81271 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
81272 modmagic = NULL;
81273
81274 @@ -2725,7 +2769,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81275 }
81276
81277 /* Set up license info based on the info section */
81278 - set_license(mod, get_modinfo(info, "license"));
81279 + set_license(mod, license);
81280
81281 return 0;
81282 }
81283 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
81284 void *ptr;
81285
81286 /* Do the allocs. */
81287 - ptr = module_alloc_update_bounds(mod->core_size);
81288 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
81289 /*
81290 * The pointer to this block is stored in the module structure
81291 * which is inside the block. Just mark it as not being a
81292 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
81293 if (!ptr)
81294 return -ENOMEM;
81295
81296 - memset(ptr, 0, mod->core_size);
81297 - mod->module_core = ptr;
81298 + memset(ptr, 0, mod->core_size_rw);
81299 + mod->module_core_rw = ptr;
81300
81301 - if (mod->init_size) {
81302 - ptr = module_alloc_update_bounds(mod->init_size);
81303 + if (mod->init_size_rw) {
81304 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
81305 /*
81306 * The pointer to this block is stored in the module structure
81307 * which is inside the block. This block doesn't need to be
81308 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
81309 */
81310 kmemleak_ignore(ptr);
81311 if (!ptr) {
81312 - module_free(mod, mod->module_core);
81313 + module_free(mod, mod->module_core_rw);
81314 return -ENOMEM;
81315 }
81316 - memset(ptr, 0, mod->init_size);
81317 - mod->module_init = ptr;
81318 + memset(ptr, 0, mod->init_size_rw);
81319 + mod->module_init_rw = ptr;
81320 } else
81321 - mod->module_init = NULL;
81322 + mod->module_init_rw = NULL;
81323 +
81324 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
81325 + kmemleak_not_leak(ptr);
81326 + if (!ptr) {
81327 + if (mod->module_init_rw)
81328 + module_free(mod, mod->module_init_rw);
81329 + module_free(mod, mod->module_core_rw);
81330 + return -ENOMEM;
81331 + }
81332 +
81333 + pax_open_kernel();
81334 + memset(ptr, 0, mod->core_size_rx);
81335 + pax_close_kernel();
81336 + mod->module_core_rx = ptr;
81337 +
81338 + if (mod->init_size_rx) {
81339 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
81340 + kmemleak_ignore(ptr);
81341 + if (!ptr && mod->init_size_rx) {
81342 + module_free_exec(mod, mod->module_core_rx);
81343 + if (mod->module_init_rw)
81344 + module_free(mod, mod->module_init_rw);
81345 + module_free(mod, mod->module_core_rw);
81346 + return -ENOMEM;
81347 + }
81348 +
81349 + pax_open_kernel();
81350 + memset(ptr, 0, mod->init_size_rx);
81351 + pax_close_kernel();
81352 + mod->module_init_rx = ptr;
81353 + } else
81354 + mod->module_init_rx = NULL;
81355
81356 /* Transfer each section which specifies SHF_ALLOC */
81357 pr_debug("final section addresses:\n");
81358 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
81359 if (!(shdr->sh_flags & SHF_ALLOC))
81360 continue;
81361
81362 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
81363 - dest = mod->module_init
81364 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81365 - else
81366 - dest = mod->module_core + shdr->sh_entsize;
81367 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
81368 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81369 + dest = mod->module_init_rw
81370 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81371 + else
81372 + dest = mod->module_init_rx
81373 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81374 + } else {
81375 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81376 + dest = mod->module_core_rw + shdr->sh_entsize;
81377 + else
81378 + dest = mod->module_core_rx + shdr->sh_entsize;
81379 + }
81380 +
81381 + if (shdr->sh_type != SHT_NOBITS) {
81382 +
81383 +#ifdef CONFIG_PAX_KERNEXEC
81384 +#ifdef CONFIG_X86_64
81385 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
81386 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
81387 +#endif
81388 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
81389 + pax_open_kernel();
81390 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81391 + pax_close_kernel();
81392 + } else
81393 +#endif
81394
81395 - if (shdr->sh_type != SHT_NOBITS)
81396 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81397 + }
81398 /* Update sh_addr to point to copy in image. */
81399 - shdr->sh_addr = (unsigned long)dest;
81400 +
81401 +#ifdef CONFIG_PAX_KERNEXEC
81402 + if (shdr->sh_flags & SHF_EXECINSTR)
81403 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
81404 + else
81405 +#endif
81406 +
81407 + shdr->sh_addr = (unsigned long)dest;
81408 pr_debug("\t0x%lx %s\n",
81409 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
81410 }
81411 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
81412 * Do it before processing of module parameters, so the module
81413 * can provide parameter accessor functions of its own.
81414 */
81415 - if (mod->module_init)
81416 - flush_icache_range((unsigned long)mod->module_init,
81417 - (unsigned long)mod->module_init
81418 - + mod->init_size);
81419 - flush_icache_range((unsigned long)mod->module_core,
81420 - (unsigned long)mod->module_core + mod->core_size);
81421 + if (mod->module_init_rx)
81422 + flush_icache_range((unsigned long)mod->module_init_rx,
81423 + (unsigned long)mod->module_init_rx
81424 + + mod->init_size_rx);
81425 + flush_icache_range((unsigned long)mod->module_core_rx,
81426 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
81427
81428 set_fs(old_fs);
81429 }
81430 @@ -2974,8 +3079,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
81431 static void module_deallocate(struct module *mod, struct load_info *info)
81432 {
81433 percpu_modfree(mod);
81434 - module_free(mod, mod->module_init);
81435 - module_free(mod, mod->module_core);
81436 + module_free_exec(mod, mod->module_init_rx);
81437 + module_free_exec(mod, mod->module_core_rx);
81438 + module_free(mod, mod->module_init_rw);
81439 + module_free(mod, mod->module_core_rw);
81440 }
81441
81442 int __weak module_finalize(const Elf_Ehdr *hdr,
81443 @@ -2988,7 +3095,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
81444 static int post_relocation(struct module *mod, const struct load_info *info)
81445 {
81446 /* Sort exception table now relocations are done. */
81447 + pax_open_kernel();
81448 sort_extable(mod->extable, mod->extable + mod->num_exentries);
81449 + pax_close_kernel();
81450
81451 /* Copy relocated percpu area over. */
81452 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
81453 @@ -3042,16 +3151,16 @@ static int do_init_module(struct module *mod)
81454 MODULE_STATE_COMING, mod);
81455
81456 /* Set RO and NX regions for core */
81457 - set_section_ro_nx(mod->module_core,
81458 - mod->core_text_size,
81459 - mod->core_ro_size,
81460 - mod->core_size);
81461 + set_section_ro_nx(mod->module_core_rx,
81462 + mod->core_size_rx,
81463 + mod->core_size_rx,
81464 + mod->core_size_rx);
81465
81466 /* Set RO and NX regions for init */
81467 - set_section_ro_nx(mod->module_init,
81468 - mod->init_text_size,
81469 - mod->init_ro_size,
81470 - mod->init_size);
81471 + set_section_ro_nx(mod->module_init_rx,
81472 + mod->init_size_rx,
81473 + mod->init_size_rx,
81474 + mod->init_size_rx);
81475
81476 do_mod_ctors(mod);
81477 /* Start the module */
81478 @@ -3113,11 +3222,12 @@ static int do_init_module(struct module *mod)
81479 mod->strtab = mod->core_strtab;
81480 #endif
81481 unset_module_init_ro_nx(mod);
81482 - module_free(mod, mod->module_init);
81483 - mod->module_init = NULL;
81484 - mod->init_size = 0;
81485 - mod->init_ro_size = 0;
81486 - mod->init_text_size = 0;
81487 + module_free(mod, mod->module_init_rw);
81488 + module_free_exec(mod, mod->module_init_rx);
81489 + mod->module_init_rw = NULL;
81490 + mod->module_init_rx = NULL;
81491 + mod->init_size_rw = 0;
81492 + mod->init_size_rx = 0;
81493 mutex_unlock(&module_mutex);
81494 wake_up_all(&module_wq);
81495
81496 @@ -3261,9 +3371,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
81497 if (err)
81498 goto free_unload;
81499
81500 + /* Now copy in args */
81501 + mod->args = strndup_user(uargs, ~0UL >> 1);
81502 + if (IS_ERR(mod->args)) {
81503 + err = PTR_ERR(mod->args);
81504 + goto free_unload;
81505 + }
81506 +
81507 /* Set up MODINFO_ATTR fields */
81508 setup_modinfo(mod, info);
81509
81510 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81511 + {
81512 + char *p, *p2;
81513 +
81514 + if (strstr(mod->args, "grsec_modharden_netdev")) {
81515 + 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);
81516 + err = -EPERM;
81517 + goto free_modinfo;
81518 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
81519 + p += sizeof("grsec_modharden_normal") - 1;
81520 + p2 = strstr(p, "_");
81521 + if (p2) {
81522 + *p2 = '\0';
81523 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
81524 + *p2 = '_';
81525 + }
81526 + err = -EPERM;
81527 + goto free_modinfo;
81528 + }
81529 + }
81530 +#endif
81531 +
81532 /* Fix up syms, so that st_value is a pointer to location. */
81533 err = simplify_symbols(mod, info);
81534 if (err < 0)
81535 @@ -3279,13 +3418,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
81536
81537 flush_module_icache(mod);
81538
81539 - /* Now copy in args */
81540 - mod->args = strndup_user(uargs, ~0UL >> 1);
81541 - if (IS_ERR(mod->args)) {
81542 - err = PTR_ERR(mod->args);
81543 - goto free_arch_cleanup;
81544 - }
81545 -
81546 dynamic_debug_setup(info->debug, info->num_debug);
81547
81548 /* Finally it's fully formed, ready to start executing. */
81549 @@ -3320,11 +3452,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
81550 ddebug_cleanup:
81551 dynamic_debug_remove(info->debug);
81552 synchronize_sched();
81553 - kfree(mod->args);
81554 - free_arch_cleanup:
81555 module_arch_cleanup(mod);
81556 free_modinfo:
81557 free_modinfo(mod);
81558 + kfree(mod->args);
81559 free_unload:
81560 module_unload_free(mod);
81561 unlink_mod:
81562 @@ -3407,10 +3538,16 @@ static const char *get_ksymbol(struct module *mod,
81563 unsigned long nextval;
81564
81565 /* At worse, next value is at end of module */
81566 - if (within_module_init(addr, mod))
81567 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
81568 + if (within_module_init_rx(addr, mod))
81569 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
81570 + else if (within_module_init_rw(addr, mod))
81571 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
81572 + else if (within_module_core_rx(addr, mod))
81573 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
81574 + else if (within_module_core_rw(addr, mod))
81575 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
81576 else
81577 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
81578 + return NULL;
81579
81580 /* Scan for closest preceding symbol, and next symbol. (ELF
81581 starts real symbols at 1). */
81582 @@ -3661,7 +3798,7 @@ static int m_show(struct seq_file *m, void *p)
81583 return 0;
81584
81585 seq_printf(m, "%s %u",
81586 - mod->name, mod->init_size + mod->core_size);
81587 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
81588 print_unload_info(m, mod);
81589
81590 /* Informative for users. */
81591 @@ -3670,7 +3807,7 @@ static int m_show(struct seq_file *m, void *p)
81592 mod->state == MODULE_STATE_COMING ? "Loading":
81593 "Live");
81594 /* Used by oprofile and other similar tools. */
81595 - seq_printf(m, " 0x%pK", mod->module_core);
81596 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
81597
81598 /* Taints info */
81599 if (mod->taints)
81600 @@ -3706,7 +3843,17 @@ static const struct file_operations proc_modules_operations = {
81601
81602 static int __init proc_modules_init(void)
81603 {
81604 +#ifndef CONFIG_GRKERNSEC_HIDESYM
81605 +#ifdef CONFIG_GRKERNSEC_PROC_USER
81606 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
81607 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81608 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
81609 +#else
81610 proc_create("modules", 0, NULL, &proc_modules_operations);
81611 +#endif
81612 +#else
81613 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
81614 +#endif
81615 return 0;
81616 }
81617 module_init(proc_modules_init);
81618 @@ -3767,14 +3914,14 @@ struct module *__module_address(unsigned long addr)
81619 {
81620 struct module *mod;
81621
81622 - if (addr < module_addr_min || addr > module_addr_max)
81623 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
81624 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
81625 return NULL;
81626
81627 list_for_each_entry_rcu(mod, &modules, list) {
81628 if (mod->state == MODULE_STATE_UNFORMED)
81629 continue;
81630 - if (within_module_core(addr, mod)
81631 - || within_module_init(addr, mod))
81632 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
81633 return mod;
81634 }
81635 return NULL;
81636 @@ -3809,11 +3956,20 @@ bool is_module_text_address(unsigned long addr)
81637 */
81638 struct module *__module_text_address(unsigned long addr)
81639 {
81640 - struct module *mod = __module_address(addr);
81641 + struct module *mod;
81642 +
81643 +#ifdef CONFIG_X86_32
81644 + addr = ktla_ktva(addr);
81645 +#endif
81646 +
81647 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
81648 + return NULL;
81649 +
81650 + mod = __module_address(addr);
81651 +
81652 if (mod) {
81653 /* Make sure it's within the text section. */
81654 - if (!within(addr, mod->module_init, mod->init_text_size)
81655 - && !within(addr, mod->module_core, mod->core_text_size))
81656 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
81657 mod = NULL;
81658 }
81659 return mod;
81660 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
81661 index 7e3443f..b2a1e6b 100644
81662 --- a/kernel/mutex-debug.c
81663 +++ b/kernel/mutex-debug.c
81664 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
81665 }
81666
81667 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
81668 - struct thread_info *ti)
81669 + struct task_struct *task)
81670 {
81671 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
81672
81673 /* Mark the current thread as blocked on the lock: */
81674 - ti->task->blocked_on = waiter;
81675 + task->blocked_on = waiter;
81676 }
81677
81678 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
81679 - struct thread_info *ti)
81680 + struct task_struct *task)
81681 {
81682 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
81683 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
81684 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
81685 - ti->task->blocked_on = NULL;
81686 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
81687 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
81688 + task->blocked_on = NULL;
81689
81690 list_del_init(&waiter->list);
81691 waiter->task = NULL;
81692 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
81693 index 0799fd3..d06ae3b 100644
81694 --- a/kernel/mutex-debug.h
81695 +++ b/kernel/mutex-debug.h
81696 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
81697 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
81698 extern void debug_mutex_add_waiter(struct mutex *lock,
81699 struct mutex_waiter *waiter,
81700 - struct thread_info *ti);
81701 + struct task_struct *task);
81702 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
81703 - struct thread_info *ti);
81704 + struct task_struct *task);
81705 extern void debug_mutex_unlock(struct mutex *lock);
81706 extern void debug_mutex_init(struct mutex *lock, const char *name,
81707 struct lock_class_key *key);
81708 diff --git a/kernel/mutex.c b/kernel/mutex.c
81709 index a52ee7bb..f361f16 100644
81710 --- a/kernel/mutex.c
81711 +++ b/kernel/mutex.c
81712 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
81713 node->locked = 1;
81714 return;
81715 }
81716 - ACCESS_ONCE(prev->next) = node;
81717 + ACCESS_ONCE_RW(prev->next) = node;
81718 smp_wmb();
81719 /* Wait until the lock holder passes the lock down */
81720 while (!ACCESS_ONCE(node->locked))
81721 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
81722 while (!(next = ACCESS_ONCE(node->next)))
81723 arch_mutex_cpu_relax();
81724 }
81725 - ACCESS_ONCE(next->locked) = 1;
81726 + ACCESS_ONCE_RW(next->locked) = 1;
81727 smp_wmb();
81728 }
81729
81730 @@ -514,7 +514,7 @@ slowpath:
81731 spin_lock_mutex(&lock->wait_lock, flags);
81732
81733 debug_mutex_lock_common(lock, &waiter);
81734 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
81735 + debug_mutex_add_waiter(lock, &waiter, task);
81736
81737 /* add waiting tasks to the end of the waitqueue (FIFO): */
81738 list_add_tail(&waiter.list, &lock->wait_list);
81739 @@ -565,7 +565,7 @@ slowpath:
81740 done:
81741 lock_acquired(&lock->dep_map, ip);
81742 /* got the lock - rejoice! */
81743 - mutex_remove_waiter(lock, &waiter, current_thread_info());
81744 + mutex_remove_waiter(lock, &waiter, task);
81745 mutex_set_owner(lock);
81746
81747 if (!__builtin_constant_p(ww_ctx == NULL)) {
81748 @@ -604,7 +604,7 @@ done:
81749 return 0;
81750
81751 err:
81752 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
81753 + mutex_remove_waiter(lock, &waiter, task);
81754 spin_unlock_mutex(&lock->wait_lock, flags);
81755 debug_mutex_free_waiter(&waiter);
81756 mutex_release(&lock->dep_map, 1, ip);
81757 diff --git a/kernel/notifier.c b/kernel/notifier.c
81758 index 2d5cc4c..d9ea600 100644
81759 --- a/kernel/notifier.c
81760 +++ b/kernel/notifier.c
81761 @@ -5,6 +5,7 @@
81762 #include <linux/rcupdate.h>
81763 #include <linux/vmalloc.h>
81764 #include <linux/reboot.h>
81765 +#include <linux/mm.h>
81766
81767 /*
81768 * Notifier list for kernel code which wants to be called
81769 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
81770 while ((*nl) != NULL) {
81771 if (n->priority > (*nl)->priority)
81772 break;
81773 - nl = &((*nl)->next);
81774 + nl = (struct notifier_block **)&((*nl)->next);
81775 }
81776 - n->next = *nl;
81777 + pax_open_kernel();
81778 + *(const void **)&n->next = *nl;
81779 rcu_assign_pointer(*nl, n);
81780 + pax_close_kernel();
81781 return 0;
81782 }
81783
81784 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
81785 return 0;
81786 if (n->priority > (*nl)->priority)
81787 break;
81788 - nl = &((*nl)->next);
81789 + nl = (struct notifier_block **)&((*nl)->next);
81790 }
81791 - n->next = *nl;
81792 + pax_open_kernel();
81793 + *(const void **)&n->next = *nl;
81794 rcu_assign_pointer(*nl, n);
81795 + pax_close_kernel();
81796 return 0;
81797 }
81798
81799 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
81800 {
81801 while ((*nl) != NULL) {
81802 if ((*nl) == n) {
81803 + pax_open_kernel();
81804 rcu_assign_pointer(*nl, n->next);
81805 + pax_close_kernel();
81806 return 0;
81807 }
81808 - nl = &((*nl)->next);
81809 + nl = (struct notifier_block **)&((*nl)->next);
81810 }
81811 return -ENOENT;
81812 }
81813 diff --git a/kernel/panic.c b/kernel/panic.c
81814 index 8018646..b6a5b4f 100644
81815 --- a/kernel/panic.c
81816 +++ b/kernel/panic.c
81817 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
81818 disable_trace_on_warning();
81819
81820 pr_warn("------------[ cut here ]------------\n");
81821 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
81822 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
81823 raw_smp_processor_id(), current->pid, file, line, caller);
81824
81825 if (args)
81826 @@ -457,7 +457,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
81827 */
81828 void __stack_chk_fail(void)
81829 {
81830 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
81831 + dump_stack();
81832 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
81833 __builtin_return_address(0));
81834 }
81835 EXPORT_SYMBOL(__stack_chk_fail);
81836 diff --git a/kernel/pid.c b/kernel/pid.c
81837 index ebe5e80..5d6d634 100644
81838 --- a/kernel/pid.c
81839 +++ b/kernel/pid.c
81840 @@ -33,6 +33,7 @@
81841 #include <linux/rculist.h>
81842 #include <linux/bootmem.h>
81843 #include <linux/hash.h>
81844 +#include <linux/security.h>
81845 #include <linux/pid_namespace.h>
81846 #include <linux/init_task.h>
81847 #include <linux/syscalls.h>
81848 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
81849
81850 int pid_max = PID_MAX_DEFAULT;
81851
81852 -#define RESERVED_PIDS 300
81853 +#define RESERVED_PIDS 500
81854
81855 int pid_max_min = RESERVED_PIDS + 1;
81856 int pid_max_max = PID_MAX_LIMIT;
81857 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
81858 */
81859 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
81860 {
81861 + struct task_struct *task;
81862 +
81863 rcu_lockdep_assert(rcu_read_lock_held(),
81864 "find_task_by_pid_ns() needs rcu_read_lock()"
81865 " protection");
81866 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
81867 +
81868 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
81869 +
81870 + if (gr_pid_is_chrooted(task))
81871 + return NULL;
81872 +
81873 + return task;
81874 }
81875
81876 struct task_struct *find_task_by_vpid(pid_t vnr)
81877 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
81878 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
81879 }
81880
81881 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
81882 +{
81883 + rcu_lockdep_assert(rcu_read_lock_held(),
81884 + "find_task_by_pid_ns() needs rcu_read_lock()"
81885 + " protection");
81886 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
81887 +}
81888 +
81889 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
81890 {
81891 struct pid *pid;
81892 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
81893 index 601bb36..f7e6f34 100644
81894 --- a/kernel/pid_namespace.c
81895 +++ b/kernel/pid_namespace.c
81896 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
81897 void __user *buffer, size_t *lenp, loff_t *ppos)
81898 {
81899 struct pid_namespace *pid_ns = task_active_pid_ns(current);
81900 - struct ctl_table tmp = *table;
81901 + ctl_table_no_const tmp = *table;
81902
81903 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
81904 return -EPERM;
81905 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
81906 index c7f31aa..2b44977 100644
81907 --- a/kernel/posix-cpu-timers.c
81908 +++ b/kernel/posix-cpu-timers.c
81909 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
81910
81911 static __init int init_posix_cpu_timers(void)
81912 {
81913 - struct k_clock process = {
81914 + static struct k_clock process = {
81915 .clock_getres = process_cpu_clock_getres,
81916 .clock_get = process_cpu_clock_get,
81917 .timer_create = process_cpu_timer_create,
81918 .nsleep = process_cpu_nsleep,
81919 .nsleep_restart = process_cpu_nsleep_restart,
81920 };
81921 - struct k_clock thread = {
81922 + static struct k_clock thread = {
81923 .clock_getres = thread_cpu_clock_getres,
81924 .clock_get = thread_cpu_clock_get,
81925 .timer_create = thread_cpu_timer_create,
81926 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
81927 index 424c2d4..679242f 100644
81928 --- a/kernel/posix-timers.c
81929 +++ b/kernel/posix-timers.c
81930 @@ -43,6 +43,7 @@
81931 #include <linux/hash.h>
81932 #include <linux/posix-clock.h>
81933 #include <linux/posix-timers.h>
81934 +#include <linux/grsecurity.h>
81935 #include <linux/syscalls.h>
81936 #include <linux/wait.h>
81937 #include <linux/workqueue.h>
81938 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
81939 * which we beg off on and pass to do_sys_settimeofday().
81940 */
81941
81942 -static struct k_clock posix_clocks[MAX_CLOCKS];
81943 +static struct k_clock *posix_clocks[MAX_CLOCKS];
81944
81945 /*
81946 * These ones are defined below.
81947 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
81948 */
81949 static __init int init_posix_timers(void)
81950 {
81951 - struct k_clock clock_realtime = {
81952 + static struct k_clock clock_realtime = {
81953 .clock_getres = hrtimer_get_res,
81954 .clock_get = posix_clock_realtime_get,
81955 .clock_set = posix_clock_realtime_set,
81956 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
81957 .timer_get = common_timer_get,
81958 .timer_del = common_timer_del,
81959 };
81960 - struct k_clock clock_monotonic = {
81961 + static struct k_clock clock_monotonic = {
81962 .clock_getres = hrtimer_get_res,
81963 .clock_get = posix_ktime_get_ts,
81964 .nsleep = common_nsleep,
81965 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
81966 .timer_get = common_timer_get,
81967 .timer_del = common_timer_del,
81968 };
81969 - struct k_clock clock_monotonic_raw = {
81970 + static struct k_clock clock_monotonic_raw = {
81971 .clock_getres = hrtimer_get_res,
81972 .clock_get = posix_get_monotonic_raw,
81973 };
81974 - struct k_clock clock_realtime_coarse = {
81975 + static struct k_clock clock_realtime_coarse = {
81976 .clock_getres = posix_get_coarse_res,
81977 .clock_get = posix_get_realtime_coarse,
81978 };
81979 - struct k_clock clock_monotonic_coarse = {
81980 + static struct k_clock clock_monotonic_coarse = {
81981 .clock_getres = posix_get_coarse_res,
81982 .clock_get = posix_get_monotonic_coarse,
81983 };
81984 - struct k_clock clock_tai = {
81985 + static struct k_clock clock_tai = {
81986 .clock_getres = hrtimer_get_res,
81987 .clock_get = posix_get_tai,
81988 .nsleep = common_nsleep,
81989 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
81990 .timer_get = common_timer_get,
81991 .timer_del = common_timer_del,
81992 };
81993 - struct k_clock clock_boottime = {
81994 + static struct k_clock clock_boottime = {
81995 .clock_getres = hrtimer_get_res,
81996 .clock_get = posix_get_boottime,
81997 .nsleep = common_nsleep,
81998 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
81999 return;
82000 }
82001
82002 - posix_clocks[clock_id] = *new_clock;
82003 + posix_clocks[clock_id] = new_clock;
82004 }
82005 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
82006
82007 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
82008 return (id & CLOCKFD_MASK) == CLOCKFD ?
82009 &clock_posix_dynamic : &clock_posix_cpu;
82010
82011 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
82012 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
82013 return NULL;
82014 - return &posix_clocks[id];
82015 + return posix_clocks[id];
82016 }
82017
82018 static int common_timer_create(struct k_itimer *new_timer)
82019 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
82020 struct k_clock *kc = clockid_to_kclock(which_clock);
82021 struct k_itimer *new_timer;
82022 int error, new_timer_id;
82023 - sigevent_t event;
82024 + sigevent_t event = { };
82025 int it_id_set = IT_ID_NOT_SET;
82026
82027 if (!kc)
82028 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
82029 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
82030 return -EFAULT;
82031
82032 + /* only the CLOCK_REALTIME clock can be set, all other clocks
82033 + have their clock_set fptr set to a nosettime dummy function
82034 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
82035 + call common_clock_set, which calls do_sys_settimeofday, which
82036 + we hook
82037 + */
82038 +
82039 return kc->clock_set(which_clock, &new_tp);
82040 }
82041
82042 diff --git a/kernel/power/process.c b/kernel/power/process.c
82043 index 06ec886..9dba35e 100644
82044 --- a/kernel/power/process.c
82045 +++ b/kernel/power/process.c
82046 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
82047 unsigned int elapsed_msecs;
82048 bool wakeup = false;
82049 int sleep_usecs = USEC_PER_MSEC;
82050 + bool timedout = false;
82051
82052 do_gettimeofday(&start);
82053
82054 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
82055
82056 while (true) {
82057 todo = 0;
82058 + if (time_after(jiffies, end_time))
82059 + timedout = true;
82060 read_lock(&tasklist_lock);
82061 do_each_thread(g, p) {
82062 if (p == current || !freeze_task(p))
82063 continue;
82064
82065 - if (!freezer_should_skip(p))
82066 + if (!freezer_should_skip(p)) {
82067 todo++;
82068 + if (timedout) {
82069 + printk(KERN_ERR "Task refusing to freeze:\n");
82070 + sched_show_task(p);
82071 + }
82072 + }
82073 } while_each_thread(g, p);
82074 read_unlock(&tasklist_lock);
82075
82076 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
82077 todo += wq_busy;
82078 }
82079
82080 - if (!todo || time_after(jiffies, end_time))
82081 + if (!todo || timedout)
82082 break;
82083
82084 if (pm_wakeup_pending()) {
82085 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
82086 index 5b5a708..ec7637e 100644
82087 --- a/kernel/printk/printk.c
82088 +++ b/kernel/printk/printk.c
82089 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
82090 if (from_file && type != SYSLOG_ACTION_OPEN)
82091 return 0;
82092
82093 +#ifdef CONFIG_GRKERNSEC_DMESG
82094 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
82095 + return -EPERM;
82096 +#endif
82097 +
82098 if (syslog_action_restricted(type)) {
82099 if (capable(CAP_SYSLOG))
82100 return 0;
82101 diff --git a/kernel/profile.c b/kernel/profile.c
82102 index 6631e1e..310c266 100644
82103 --- a/kernel/profile.c
82104 +++ b/kernel/profile.c
82105 @@ -37,7 +37,7 @@ struct profile_hit {
82106 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
82107 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
82108
82109 -static atomic_t *prof_buffer;
82110 +static atomic_unchecked_t *prof_buffer;
82111 static unsigned long prof_len, prof_shift;
82112
82113 int prof_on __read_mostly;
82114 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
82115 hits[i].pc = 0;
82116 continue;
82117 }
82118 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82119 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82120 hits[i].hits = hits[i].pc = 0;
82121 }
82122 }
82123 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82124 * Add the current hit(s) and flush the write-queue out
82125 * to the global buffer:
82126 */
82127 - atomic_add(nr_hits, &prof_buffer[pc]);
82128 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
82129 for (i = 0; i < NR_PROFILE_HIT; ++i) {
82130 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82131 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82132 hits[i].pc = hits[i].hits = 0;
82133 }
82134 out:
82135 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82136 {
82137 unsigned long pc;
82138 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
82139 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82140 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82141 }
82142 #endif /* !CONFIG_SMP */
82143
82144 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
82145 return -EFAULT;
82146 buf++; p++; count--; read++;
82147 }
82148 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
82149 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
82150 if (copy_to_user(buf, (void *)pnt, count))
82151 return -EFAULT;
82152 read += count;
82153 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
82154 }
82155 #endif
82156 profile_discard_flip_buffers();
82157 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
82158 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
82159 return count;
82160 }
82161
82162 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
82163 index a146ee3..ffed4c3 100644
82164 --- a/kernel/ptrace.c
82165 +++ b/kernel/ptrace.c
82166 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
82167 if (seize)
82168 flags |= PT_SEIZED;
82169 rcu_read_lock();
82170 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82171 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82172 flags |= PT_PTRACE_CAP;
82173 rcu_read_unlock();
82174 task->ptrace = flags;
82175 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
82176 break;
82177 return -EIO;
82178 }
82179 - if (copy_to_user(dst, buf, retval))
82180 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
82181 return -EFAULT;
82182 copied += retval;
82183 src += retval;
82184 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
82185 bool seized = child->ptrace & PT_SEIZED;
82186 int ret = -EIO;
82187 siginfo_t siginfo, *si;
82188 - void __user *datavp = (void __user *) data;
82189 + void __user *datavp = (__force void __user *) data;
82190 unsigned long __user *datalp = datavp;
82191 unsigned long flags;
82192
82193 @@ -1051,14 +1051,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
82194 goto out;
82195 }
82196
82197 + if (gr_handle_ptrace(child, request)) {
82198 + ret = -EPERM;
82199 + goto out_put_task_struct;
82200 + }
82201 +
82202 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82203 ret = ptrace_attach(child, request, addr, data);
82204 /*
82205 * Some architectures need to do book-keeping after
82206 * a ptrace attach.
82207 */
82208 - if (!ret)
82209 + if (!ret) {
82210 arch_ptrace_attach(child);
82211 + gr_audit_ptrace(child);
82212 + }
82213 goto out_put_task_struct;
82214 }
82215
82216 @@ -1086,7 +1093,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
82217 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
82218 if (copied != sizeof(tmp))
82219 return -EIO;
82220 - return put_user(tmp, (unsigned long __user *)data);
82221 + return put_user(tmp, (__force unsigned long __user *)data);
82222 }
82223
82224 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
82225 @@ -1180,7 +1187,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
82226 }
82227
82228 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82229 - compat_long_t addr, compat_long_t data)
82230 + compat_ulong_t addr, compat_ulong_t data)
82231 {
82232 struct task_struct *child;
82233 long ret;
82234 @@ -1196,14 +1203,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82235 goto out;
82236 }
82237
82238 + if (gr_handle_ptrace(child, request)) {
82239 + ret = -EPERM;
82240 + goto out_put_task_struct;
82241 + }
82242 +
82243 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82244 ret = ptrace_attach(child, request, addr, data);
82245 /*
82246 * Some architectures need to do book-keeping after
82247 * a ptrace attach.
82248 */
82249 - if (!ret)
82250 + if (!ret) {
82251 arch_ptrace_attach(child);
82252 + gr_audit_ptrace(child);
82253 + }
82254 goto out_put_task_struct;
82255 }
82256
82257 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
82258 index cce6ba8..7c758b1f 100644
82259 --- a/kernel/rcupdate.c
82260 +++ b/kernel/rcupdate.c
82261 @@ -412,10 +412,10 @@ int rcu_jiffies_till_stall_check(void)
82262 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
82263 */
82264 if (till_stall_check < 3) {
82265 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
82266 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
82267 till_stall_check = 3;
82268 } else if (till_stall_check > 300) {
82269 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
82270 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
82271 till_stall_check = 300;
82272 }
82273 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
82274 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
82275 index aa34411..4832cd4 100644
82276 --- a/kernel/rcutiny.c
82277 +++ b/kernel/rcutiny.c
82278 @@ -45,7 +45,7 @@
82279 /* Forward declarations for rcutiny_plugin.h. */
82280 struct rcu_ctrlblk;
82281 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
82282 -static void rcu_process_callbacks(struct softirq_action *unused);
82283 +static void rcu_process_callbacks(void);
82284 static void __call_rcu(struct rcu_head *head,
82285 void (*func)(struct rcu_head *rcu),
82286 struct rcu_ctrlblk *rcp);
82287 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
82288 false));
82289 }
82290
82291 -static void rcu_process_callbacks(struct softirq_action *unused)
82292 +static __latent_entropy void rcu_process_callbacks(void)
82293 {
82294 __rcu_process_callbacks(&rcu_sched_ctrlblk);
82295 __rcu_process_callbacks(&rcu_bh_ctrlblk);
82296 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
82297 index f4871e5..8ef5741 100644
82298 --- a/kernel/rcutorture.c
82299 +++ b/kernel/rcutorture.c
82300 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
82301 { 0 };
82302 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
82303 { 0 };
82304 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82305 -static atomic_t n_rcu_torture_alloc;
82306 -static atomic_t n_rcu_torture_alloc_fail;
82307 -static atomic_t n_rcu_torture_free;
82308 -static atomic_t n_rcu_torture_mberror;
82309 -static atomic_t n_rcu_torture_error;
82310 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82311 +static atomic_unchecked_t n_rcu_torture_alloc;
82312 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
82313 +static atomic_unchecked_t n_rcu_torture_free;
82314 +static atomic_unchecked_t n_rcu_torture_mberror;
82315 +static atomic_unchecked_t n_rcu_torture_error;
82316 static long n_rcu_torture_barrier_error;
82317 static long n_rcu_torture_boost_ktrerror;
82318 static long n_rcu_torture_boost_rterror;
82319 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
82320
82321 spin_lock_bh(&rcu_torture_lock);
82322 if (list_empty(&rcu_torture_freelist)) {
82323 - atomic_inc(&n_rcu_torture_alloc_fail);
82324 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
82325 spin_unlock_bh(&rcu_torture_lock);
82326 return NULL;
82327 }
82328 - atomic_inc(&n_rcu_torture_alloc);
82329 + atomic_inc_unchecked(&n_rcu_torture_alloc);
82330 p = rcu_torture_freelist.next;
82331 list_del_init(p);
82332 spin_unlock_bh(&rcu_torture_lock);
82333 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
82334 static void
82335 rcu_torture_free(struct rcu_torture *p)
82336 {
82337 - atomic_inc(&n_rcu_torture_free);
82338 + atomic_inc_unchecked(&n_rcu_torture_free);
82339 spin_lock_bh(&rcu_torture_lock);
82340 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
82341 spin_unlock_bh(&rcu_torture_lock);
82342 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
82343 i = rp->rtort_pipe_count;
82344 if (i > RCU_TORTURE_PIPE_LEN)
82345 i = RCU_TORTURE_PIPE_LEN;
82346 - atomic_inc(&rcu_torture_wcount[i]);
82347 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82348 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82349 rp->rtort_mbtest = 0;
82350 rcu_torture_free(rp);
82351 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
82352 i = rp->rtort_pipe_count;
82353 if (i > RCU_TORTURE_PIPE_LEN)
82354 i = RCU_TORTURE_PIPE_LEN;
82355 - atomic_inc(&rcu_torture_wcount[i]);
82356 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82357 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82358 rp->rtort_mbtest = 0;
82359 list_del(&rp->rtort_free);
82360 @@ -952,7 +952,7 @@ rcu_torture_writer(void *arg)
82361 i = old_rp->rtort_pipe_count;
82362 if (i > RCU_TORTURE_PIPE_LEN)
82363 i = RCU_TORTURE_PIPE_LEN;
82364 - atomic_inc(&rcu_torture_wcount[i]);
82365 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82366 old_rp->rtort_pipe_count++;
82367 cur_ops->deferred_free(old_rp);
82368 }
82369 @@ -1038,7 +1038,7 @@ static void rcu_torture_timer(unsigned long unused)
82370 return;
82371 }
82372 if (p->rtort_mbtest == 0)
82373 - atomic_inc(&n_rcu_torture_mberror);
82374 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82375 spin_lock(&rand_lock);
82376 cur_ops->read_delay(&rand);
82377 n_rcu_torture_timers++;
82378 @@ -1108,7 +1108,7 @@ rcu_torture_reader(void *arg)
82379 continue;
82380 }
82381 if (p->rtort_mbtest == 0)
82382 - atomic_inc(&n_rcu_torture_mberror);
82383 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82384 cur_ops->read_delay(&rand);
82385 preempt_disable();
82386 pipe_count = p->rtort_pipe_count;
82387 @@ -1171,11 +1171,11 @@ rcu_torture_printk(char *page)
82388 rcu_torture_current,
82389 rcu_torture_current_version,
82390 list_empty(&rcu_torture_freelist),
82391 - atomic_read(&n_rcu_torture_alloc),
82392 - atomic_read(&n_rcu_torture_alloc_fail),
82393 - atomic_read(&n_rcu_torture_free));
82394 + atomic_read_unchecked(&n_rcu_torture_alloc),
82395 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
82396 + atomic_read_unchecked(&n_rcu_torture_free));
82397 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
82398 - atomic_read(&n_rcu_torture_mberror),
82399 + atomic_read_unchecked(&n_rcu_torture_mberror),
82400 n_rcu_torture_boost_ktrerror,
82401 n_rcu_torture_boost_rterror);
82402 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
82403 @@ -1194,14 +1194,14 @@ rcu_torture_printk(char *page)
82404 n_barrier_attempts,
82405 n_rcu_torture_barrier_error);
82406 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
82407 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
82408 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
82409 n_rcu_torture_barrier_error != 0 ||
82410 n_rcu_torture_boost_ktrerror != 0 ||
82411 n_rcu_torture_boost_rterror != 0 ||
82412 n_rcu_torture_boost_failure != 0 ||
82413 i > 1) {
82414 cnt += sprintf(&page[cnt], "!!! ");
82415 - atomic_inc(&n_rcu_torture_error);
82416 + atomic_inc_unchecked(&n_rcu_torture_error);
82417 WARN_ON_ONCE(1);
82418 }
82419 cnt += sprintf(&page[cnt], "Reader Pipe: ");
82420 @@ -1215,7 +1215,7 @@ rcu_torture_printk(char *page)
82421 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
82422 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82423 cnt += sprintf(&page[cnt], " %d",
82424 - atomic_read(&rcu_torture_wcount[i]));
82425 + atomic_read_unchecked(&rcu_torture_wcount[i]));
82426 }
82427 cnt += sprintf(&page[cnt], "\n");
82428 if (cur_ops->stats)
82429 @@ -1924,7 +1924,7 @@ rcu_torture_cleanup(void)
82430
82431 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
82432
82433 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82434 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
82435 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
82436 else if (n_online_successes != n_online_attempts ||
82437 n_offline_successes != n_offline_attempts)
82438 @@ -1992,18 +1992,18 @@ rcu_torture_init(void)
82439
82440 rcu_torture_current = NULL;
82441 rcu_torture_current_version = 0;
82442 - atomic_set(&n_rcu_torture_alloc, 0);
82443 - atomic_set(&n_rcu_torture_alloc_fail, 0);
82444 - atomic_set(&n_rcu_torture_free, 0);
82445 - atomic_set(&n_rcu_torture_mberror, 0);
82446 - atomic_set(&n_rcu_torture_error, 0);
82447 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
82448 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
82449 + atomic_set_unchecked(&n_rcu_torture_free, 0);
82450 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
82451 + atomic_set_unchecked(&n_rcu_torture_error, 0);
82452 n_rcu_torture_barrier_error = 0;
82453 n_rcu_torture_boost_ktrerror = 0;
82454 n_rcu_torture_boost_rterror = 0;
82455 n_rcu_torture_boost_failure = 0;
82456 n_rcu_torture_boosts = 0;
82457 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
82458 - atomic_set(&rcu_torture_wcount[i], 0);
82459 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
82460 for_each_possible_cpu(cpu) {
82461 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82462 per_cpu(rcu_torture_count, cpu)[i] = 0;
82463 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
82464 index 068de3a..5e7db2f 100644
82465 --- a/kernel/rcutree.c
82466 +++ b/kernel/rcutree.c
82467 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
82468 rcu_prepare_for_idle(smp_processor_id());
82469 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82470 smp_mb__before_atomic_inc(); /* See above. */
82471 - atomic_inc(&rdtp->dynticks);
82472 + atomic_inc_unchecked(&rdtp->dynticks);
82473 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
82474 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82475 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82476
82477 /*
82478 * It is illegal to enter an extended quiescent state while
82479 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
82480 int user)
82481 {
82482 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
82483 - atomic_inc(&rdtp->dynticks);
82484 + atomic_inc_unchecked(&rdtp->dynticks);
82485 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82486 smp_mb__after_atomic_inc(); /* See above. */
82487 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82488 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82489 rcu_cleanup_after_idle(smp_processor_id());
82490 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
82491 if (!user && !is_idle_task(current)) {
82492 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
82493 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
82494
82495 if (rdtp->dynticks_nmi_nesting == 0 &&
82496 - (atomic_read(&rdtp->dynticks) & 0x1))
82497 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
82498 return;
82499 rdtp->dynticks_nmi_nesting++;
82500 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
82501 - atomic_inc(&rdtp->dynticks);
82502 + atomic_inc_unchecked(&rdtp->dynticks);
82503 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
82504 smp_mb__after_atomic_inc(); /* See above. */
82505 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
82506 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
82507 }
82508
82509 /**
82510 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
82511 return;
82512 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
82513 smp_mb__before_atomic_inc(); /* See above. */
82514 - atomic_inc(&rdtp->dynticks);
82515 + atomic_inc_unchecked(&rdtp->dynticks);
82516 smp_mb__after_atomic_inc(); /* Force delay to next write. */
82517 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
82518 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
82519 }
82520
82521 /**
82522 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
82523 int ret;
82524
82525 preempt_disable();
82526 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
82527 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
82528 preempt_enable();
82529 return ret;
82530 }
82531 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
82532 */
82533 static int dyntick_save_progress_counter(struct rcu_data *rdp)
82534 {
82535 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
82536 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
82537 return (rdp->dynticks_snap & 0x1) == 0;
82538 }
82539
82540 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
82541 unsigned int curr;
82542 unsigned int snap;
82543
82544 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
82545 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
82546 snap = (unsigned int)rdp->dynticks_snap;
82547
82548 /*
82549 @@ -1351,9 +1351,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
82550 rdp = this_cpu_ptr(rsp->rda);
82551 rcu_preempt_check_blocked_tasks(rnp);
82552 rnp->qsmask = rnp->qsmaskinit;
82553 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
82554 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
82555 WARN_ON_ONCE(rnp->completed != rsp->completed);
82556 - ACCESS_ONCE(rnp->completed) = rsp->completed;
82557 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
82558 if (rnp == rdp->mynode)
82559 __note_gp_changes(rsp, rnp, rdp);
82560 rcu_preempt_boost_start_gp(rnp);
82561 @@ -1435,7 +1435,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
82562 */
82563 rcu_for_each_node_breadth_first(rsp, rnp) {
82564 raw_spin_lock_irq(&rnp->lock);
82565 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
82566 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
82567 rdp = this_cpu_ptr(rsp->rda);
82568 if (rnp == rdp->mynode)
82569 __note_gp_changes(rsp, rnp, rdp);
82570 @@ -1765,7 +1765,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
82571 rsp->qlen += rdp->qlen;
82572 rdp->n_cbs_orphaned += rdp->qlen;
82573 rdp->qlen_lazy = 0;
82574 - ACCESS_ONCE(rdp->qlen) = 0;
82575 + ACCESS_ONCE_RW(rdp->qlen) = 0;
82576 }
82577
82578 /*
82579 @@ -2011,7 +2011,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
82580 }
82581 smp_mb(); /* List handling before counting for rcu_barrier(). */
82582 rdp->qlen_lazy -= count_lazy;
82583 - ACCESS_ONCE(rdp->qlen) -= count;
82584 + ACCESS_ONCE_RW(rdp->qlen) -= count;
82585 rdp->n_cbs_invoked += count;
82586
82587 /* Reinstate batch limit if we have worked down the excess. */
82588 @@ -2202,7 +2202,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
82589 /*
82590 * Do RCU core processing for the current CPU.
82591 */
82592 -static void rcu_process_callbacks(struct softirq_action *unused)
82593 +static __latent_entropy void rcu_process_callbacks(void)
82594 {
82595 struct rcu_state *rsp;
82596
82597 @@ -2325,7 +2325,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
82598 local_irq_restore(flags);
82599 return;
82600 }
82601 - ACCESS_ONCE(rdp->qlen)++;
82602 + ACCESS_ONCE_RW(rdp->qlen)++;
82603 if (lazy)
82604 rdp->qlen_lazy++;
82605 else
82606 @@ -2534,11 +2534,11 @@ void synchronize_sched_expedited(void)
82607 * counter wrap on a 32-bit system. Quite a few more CPUs would of
82608 * course be required on a 64-bit system.
82609 */
82610 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
82611 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
82612 (ulong)atomic_long_read(&rsp->expedited_done) +
82613 ULONG_MAX / 8)) {
82614 synchronize_sched();
82615 - atomic_long_inc(&rsp->expedited_wrap);
82616 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
82617 return;
82618 }
82619
82620 @@ -2546,7 +2546,7 @@ void synchronize_sched_expedited(void)
82621 * Take a ticket. Note that atomic_inc_return() implies a
82622 * full memory barrier.
82623 */
82624 - snap = atomic_long_inc_return(&rsp->expedited_start);
82625 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
82626 firstsnap = snap;
82627 get_online_cpus();
82628 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
82629 @@ -2559,14 +2559,14 @@ void synchronize_sched_expedited(void)
82630 synchronize_sched_expedited_cpu_stop,
82631 NULL) == -EAGAIN) {
82632 put_online_cpus();
82633 - atomic_long_inc(&rsp->expedited_tryfail);
82634 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
82635
82636 /* Check to see if someone else did our work for us. */
82637 s = atomic_long_read(&rsp->expedited_done);
82638 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
82639 /* ensure test happens before caller kfree */
82640 smp_mb__before_atomic_inc(); /* ^^^ */
82641 - atomic_long_inc(&rsp->expedited_workdone1);
82642 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
82643 return;
82644 }
82645
82646 @@ -2575,7 +2575,7 @@ void synchronize_sched_expedited(void)
82647 udelay(trycount * num_online_cpus());
82648 } else {
82649 wait_rcu_gp(call_rcu_sched);
82650 - atomic_long_inc(&rsp->expedited_normal);
82651 + atomic_long_inc_unchecked(&rsp->expedited_normal);
82652 return;
82653 }
82654
82655 @@ -2584,7 +2584,7 @@ void synchronize_sched_expedited(void)
82656 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
82657 /* ensure test happens before caller kfree */
82658 smp_mb__before_atomic_inc(); /* ^^^ */
82659 - atomic_long_inc(&rsp->expedited_workdone2);
82660 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
82661 return;
82662 }
82663
82664 @@ -2596,10 +2596,10 @@ void synchronize_sched_expedited(void)
82665 * period works for us.
82666 */
82667 get_online_cpus();
82668 - snap = atomic_long_read(&rsp->expedited_start);
82669 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
82670 smp_mb(); /* ensure read is before try_stop_cpus(). */
82671 }
82672 - atomic_long_inc(&rsp->expedited_stoppedcpus);
82673 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
82674
82675 /*
82676 * Everyone up to our most recent fetch is covered by our grace
82677 @@ -2608,16 +2608,16 @@ void synchronize_sched_expedited(void)
82678 * than we did already did their update.
82679 */
82680 do {
82681 - atomic_long_inc(&rsp->expedited_done_tries);
82682 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
82683 s = atomic_long_read(&rsp->expedited_done);
82684 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
82685 /* ensure test happens before caller kfree */
82686 smp_mb__before_atomic_inc(); /* ^^^ */
82687 - atomic_long_inc(&rsp->expedited_done_lost);
82688 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
82689 break;
82690 }
82691 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
82692 - atomic_long_inc(&rsp->expedited_done_exit);
82693 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
82694
82695 put_online_cpus();
82696 }
82697 @@ -2799,7 +2799,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
82698 * ACCESS_ONCE() to prevent the compiler from speculating
82699 * the increment to precede the early-exit check.
82700 */
82701 - ACCESS_ONCE(rsp->n_barrier_done)++;
82702 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
82703 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
82704 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
82705 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
82706 @@ -2849,7 +2849,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
82707
82708 /* Increment ->n_barrier_done to prevent duplicate work. */
82709 smp_mb(); /* Keep increment after above mechanism. */
82710 - ACCESS_ONCE(rsp->n_barrier_done)++;
82711 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
82712 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
82713 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
82714 smp_mb(); /* Keep increment before caller's subsequent code. */
82715 @@ -2894,10 +2894,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
82716 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
82717 init_callback_list(rdp);
82718 rdp->qlen_lazy = 0;
82719 - ACCESS_ONCE(rdp->qlen) = 0;
82720 + ACCESS_ONCE_RW(rdp->qlen) = 0;
82721 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
82722 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
82723 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
82724 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
82725 rdp->cpu = cpu;
82726 rdp->rsp = rsp;
82727 rcu_boot_init_nocb_percpu_data(rdp);
82728 @@ -2930,8 +2930,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
82729 rdp->blimit = blimit;
82730 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
82731 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
82732 - atomic_set(&rdp->dynticks->dynticks,
82733 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
82734 + atomic_set_unchecked(&rdp->dynticks->dynticks,
82735 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
82736 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
82737
82738 /* Add CPU to rcu_node bitmasks. */
82739 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
82740 index b383258..2440c1e 100644
82741 --- a/kernel/rcutree.h
82742 +++ b/kernel/rcutree.h
82743 @@ -87,7 +87,7 @@ struct rcu_dynticks {
82744 long long dynticks_nesting; /* Track irq/process nesting level. */
82745 /* Process level is worth LLONG_MAX/2. */
82746 int dynticks_nmi_nesting; /* Track NMI nesting level. */
82747 - atomic_t dynticks; /* Even value for idle, else odd. */
82748 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
82749 #ifdef CONFIG_RCU_FAST_NO_HZ
82750 bool all_lazy; /* Are all CPU's CBs lazy? */
82751 unsigned long nonlazy_posted;
82752 @@ -419,17 +419,17 @@ struct rcu_state {
82753 /* _rcu_barrier(). */
82754 /* End of fields guarded by barrier_mutex. */
82755
82756 - atomic_long_t expedited_start; /* Starting ticket. */
82757 - atomic_long_t expedited_done; /* Done ticket. */
82758 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
82759 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
82760 - atomic_long_t expedited_workdone1; /* # done by others #1. */
82761 - atomic_long_t expedited_workdone2; /* # done by others #2. */
82762 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
82763 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
82764 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
82765 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
82766 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
82767 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
82768 + atomic_long_t expedited_done; /* Done ticket. */
82769 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
82770 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
82771 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
82772 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
82773 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
82774 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
82775 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
82776 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
82777 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
82778
82779 unsigned long jiffies_force_qs; /* Time at which to invoke */
82780 /* force_quiescent_state(). */
82781 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
82782 index 769e12e..7b2139b 100644
82783 --- a/kernel/rcutree_plugin.h
82784 +++ b/kernel/rcutree_plugin.h
82785 @@ -902,7 +902,7 @@ void synchronize_rcu_expedited(void)
82786
82787 /* Clean up and exit. */
82788 smp_mb(); /* ensure expedited GP seen before counter increment. */
82789 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
82790 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
82791 unlock_mb_ret:
82792 mutex_unlock(&sync_rcu_preempt_exp_mutex);
82793 mb_ret:
82794 @@ -1476,7 +1476,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
82795 free_cpumask_var(cm);
82796 }
82797
82798 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
82799 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
82800 .store = &rcu_cpu_kthread_task,
82801 .thread_should_run = rcu_cpu_kthread_should_run,
82802 .thread_fn = rcu_cpu_kthread,
82803 @@ -1941,7 +1941,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
82804 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
82805 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
82806 cpu, ticks_value, ticks_title,
82807 - atomic_read(&rdtp->dynticks) & 0xfff,
82808 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
82809 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
82810 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
82811 fast_no_hz);
82812 @@ -2104,7 +2104,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
82813
82814 /* Enqueue the callback on the nocb list and update counts. */
82815 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
82816 - ACCESS_ONCE(*old_rhpp) = rhp;
82817 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
82818 atomic_long_add(rhcount, &rdp->nocb_q_count);
82819 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
82820
82821 @@ -2244,12 +2244,12 @@ static int rcu_nocb_kthread(void *arg)
82822 * Extract queued callbacks, update counts, and wait
82823 * for a grace period to elapse.
82824 */
82825 - ACCESS_ONCE(rdp->nocb_head) = NULL;
82826 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
82827 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
82828 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
82829 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
82830 - ACCESS_ONCE(rdp->nocb_p_count) += c;
82831 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
82832 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
82833 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
82834 rcu_nocb_wait_gp(rdp);
82835
82836 /* Each pass through the following loop invokes a callback. */
82837 @@ -2271,8 +2271,8 @@ static int rcu_nocb_kthread(void *arg)
82838 list = next;
82839 }
82840 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
82841 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
82842 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
82843 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
82844 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
82845 rdp->n_nocbs_invoked += c;
82846 }
82847 return 0;
82848 @@ -2299,7 +2299,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
82849 t = kthread_run(rcu_nocb_kthread, rdp,
82850 "rcuo%c/%d", rsp->abbr, cpu);
82851 BUG_ON(IS_ERR(t));
82852 - ACCESS_ONCE(rdp->nocb_kthread) = t;
82853 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
82854 }
82855 }
82856
82857 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
82858 index cf6c174..a8f4b50 100644
82859 --- a/kernel/rcutree_trace.c
82860 +++ b/kernel/rcutree_trace.c
82861 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
82862 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
82863 rdp->passed_quiesce, rdp->qs_pending);
82864 seq_printf(m, " dt=%d/%llx/%d df=%lu",
82865 - atomic_read(&rdp->dynticks->dynticks),
82866 + atomic_read_unchecked(&rdp->dynticks->dynticks),
82867 rdp->dynticks->dynticks_nesting,
82868 rdp->dynticks->dynticks_nmi_nesting,
82869 rdp->dynticks_fqs);
82870 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
82871 struct rcu_state *rsp = (struct rcu_state *)m->private;
82872
82873 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",
82874 - atomic_long_read(&rsp->expedited_start),
82875 + atomic_long_read_unchecked(&rsp->expedited_start),
82876 atomic_long_read(&rsp->expedited_done),
82877 - atomic_long_read(&rsp->expedited_wrap),
82878 - atomic_long_read(&rsp->expedited_tryfail),
82879 - atomic_long_read(&rsp->expedited_workdone1),
82880 - atomic_long_read(&rsp->expedited_workdone2),
82881 - atomic_long_read(&rsp->expedited_normal),
82882 - atomic_long_read(&rsp->expedited_stoppedcpus),
82883 - atomic_long_read(&rsp->expedited_done_tries),
82884 - atomic_long_read(&rsp->expedited_done_lost),
82885 - atomic_long_read(&rsp->expedited_done_exit));
82886 + atomic_long_read_unchecked(&rsp->expedited_wrap),
82887 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
82888 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
82889 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
82890 + atomic_long_read_unchecked(&rsp->expedited_normal),
82891 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
82892 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
82893 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
82894 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
82895 return 0;
82896 }
82897
82898 diff --git a/kernel/resource.c b/kernel/resource.c
82899 index 3f285dc..5755f62 100644
82900 --- a/kernel/resource.c
82901 +++ b/kernel/resource.c
82902 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
82903
82904 static int __init ioresources_init(void)
82905 {
82906 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
82907 +#ifdef CONFIG_GRKERNSEC_PROC_USER
82908 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
82909 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
82910 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82911 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
82912 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
82913 +#endif
82914 +#else
82915 proc_create("ioports", 0, NULL, &proc_ioports_operations);
82916 proc_create("iomem", 0, NULL, &proc_iomem_operations);
82917 +#endif
82918 return 0;
82919 }
82920 __initcall(ioresources_init);
82921 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
82922 index 1d96dd0..994ff19 100644
82923 --- a/kernel/rtmutex-tester.c
82924 +++ b/kernel/rtmutex-tester.c
82925 @@ -22,7 +22,7 @@
82926 #define MAX_RT_TEST_MUTEXES 8
82927
82928 static spinlock_t rttest_lock;
82929 -static atomic_t rttest_event;
82930 +static atomic_unchecked_t rttest_event;
82931
82932 struct test_thread_data {
82933 int opcode;
82934 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
82935
82936 case RTTEST_LOCKCONT:
82937 td->mutexes[td->opdata] = 1;
82938 - td->event = atomic_add_return(1, &rttest_event);
82939 + td->event = atomic_add_return_unchecked(1, &rttest_event);
82940 return 0;
82941
82942 case RTTEST_RESET:
82943 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
82944 return 0;
82945
82946 case RTTEST_RESETEVENT:
82947 - atomic_set(&rttest_event, 0);
82948 + atomic_set_unchecked(&rttest_event, 0);
82949 return 0;
82950
82951 default:
82952 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
82953 return ret;
82954
82955 td->mutexes[id] = 1;
82956 - td->event = atomic_add_return(1, &rttest_event);
82957 + td->event = atomic_add_return_unchecked(1, &rttest_event);
82958 rt_mutex_lock(&mutexes[id]);
82959 - td->event = atomic_add_return(1, &rttest_event);
82960 + td->event = atomic_add_return_unchecked(1, &rttest_event);
82961 td->mutexes[id] = 4;
82962 return 0;
82963
82964 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
82965 return ret;
82966
82967 td->mutexes[id] = 1;
82968 - td->event = atomic_add_return(1, &rttest_event);
82969 + td->event = atomic_add_return_unchecked(1, &rttest_event);
82970 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
82971 - td->event = atomic_add_return(1, &rttest_event);
82972 + td->event = atomic_add_return_unchecked(1, &rttest_event);
82973 td->mutexes[id] = ret ? 0 : 4;
82974 return ret ? -EINTR : 0;
82975
82976 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
82977 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
82978 return ret;
82979
82980 - td->event = atomic_add_return(1, &rttest_event);
82981 + td->event = atomic_add_return_unchecked(1, &rttest_event);
82982 rt_mutex_unlock(&mutexes[id]);
82983 - td->event = atomic_add_return(1, &rttest_event);
82984 + td->event = atomic_add_return_unchecked(1, &rttest_event);
82985 td->mutexes[id] = 0;
82986 return 0;
82987
82988 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
82989 break;
82990
82991 td->mutexes[dat] = 2;
82992 - td->event = atomic_add_return(1, &rttest_event);
82993 + td->event = atomic_add_return_unchecked(1, &rttest_event);
82994 break;
82995
82996 default:
82997 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
82998 return;
82999
83000 td->mutexes[dat] = 3;
83001 - td->event = atomic_add_return(1, &rttest_event);
83002 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83003 break;
83004
83005 case RTTEST_LOCKNOWAIT:
83006 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83007 return;
83008
83009 td->mutexes[dat] = 1;
83010 - td->event = atomic_add_return(1, &rttest_event);
83011 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83012 return;
83013
83014 default:
83015 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
83016 index 4a07353..66b5291 100644
83017 --- a/kernel/sched/auto_group.c
83018 +++ b/kernel/sched/auto_group.c
83019 @@ -11,7 +11,7 @@
83020
83021 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
83022 static struct autogroup autogroup_default;
83023 -static atomic_t autogroup_seq_nr;
83024 +static atomic_unchecked_t autogroup_seq_nr;
83025
83026 void __init autogroup_init(struct task_struct *init_task)
83027 {
83028 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
83029
83030 kref_init(&ag->kref);
83031 init_rwsem(&ag->lock);
83032 - ag->id = atomic_inc_return(&autogroup_seq_nr);
83033 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
83034 ag->tg = tg;
83035 #ifdef CONFIG_RT_GROUP_SCHED
83036 /*
83037 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
83038 index 05c39f0..442e6fe 100644
83039 --- a/kernel/sched/core.c
83040 +++ b/kernel/sched/core.c
83041 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
83042 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83043 * or number of jiffies left till timeout) if completed.
83044 */
83045 -long __sched
83046 +long __sched __intentional_overflow(-1)
83047 wait_for_completion_interruptible_timeout(struct completion *x,
83048 unsigned long timeout)
83049 {
83050 @@ -2902,7 +2902,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
83051 *
83052 * Return: -ERESTARTSYS if interrupted, 0 if completed.
83053 */
83054 -int __sched wait_for_completion_killable(struct completion *x)
83055 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
83056 {
83057 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
83058 if (t == -ERESTARTSYS)
83059 @@ -2923,7 +2923,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
83060 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83061 * or number of jiffies left till timeout) if completed.
83062 */
83063 -long __sched
83064 +long __sched __intentional_overflow(-1)
83065 wait_for_completion_killable_timeout(struct completion *x,
83066 unsigned long timeout)
83067 {
83068 @@ -3149,6 +3149,8 @@ int can_nice(const struct task_struct *p, const int nice)
83069 /* convert nice value [19,-20] to rlimit style value [1,40] */
83070 int nice_rlim = 20 - nice;
83071
83072 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
83073 +
83074 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
83075 capable(CAP_SYS_NICE));
83076 }
83077 @@ -3182,7 +3184,8 @@ SYSCALL_DEFINE1(nice, int, increment)
83078 if (nice > 19)
83079 nice = 19;
83080
83081 - if (increment < 0 && !can_nice(current, nice))
83082 + if (increment < 0 && (!can_nice(current, nice) ||
83083 + gr_handle_chroot_nice()))
83084 return -EPERM;
83085
83086 retval = security_task_setnice(current, nice);
83087 @@ -3344,6 +3347,7 @@ recheck:
83088 unsigned long rlim_rtprio =
83089 task_rlimit(p, RLIMIT_RTPRIO);
83090
83091 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
83092 /* can't set/change the rt policy */
83093 if (policy != p->policy && !rlim_rtprio)
83094 return -EPERM;
83095 @@ -4473,7 +4477,7 @@ static void migrate_tasks(unsigned int dead_cpu)
83096
83097 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
83098
83099 -static struct ctl_table sd_ctl_dir[] = {
83100 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
83101 {
83102 .procname = "sched_domain",
83103 .mode = 0555,
83104 @@ -4490,17 +4494,17 @@ static struct ctl_table sd_ctl_root[] = {
83105 {}
83106 };
83107
83108 -static struct ctl_table *sd_alloc_ctl_entry(int n)
83109 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
83110 {
83111 - struct ctl_table *entry =
83112 + ctl_table_no_const *entry =
83113 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
83114
83115 return entry;
83116 }
83117
83118 -static void sd_free_ctl_entry(struct ctl_table **tablep)
83119 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
83120 {
83121 - struct ctl_table *entry;
83122 + ctl_table_no_const *entry;
83123
83124 /*
83125 * In the intermediate directories, both the child directory and
83126 @@ -4508,22 +4512,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
83127 * will always be set. In the lowest directory the names are
83128 * static strings and all have proc handlers.
83129 */
83130 - for (entry = *tablep; entry->mode; entry++) {
83131 - if (entry->child)
83132 - sd_free_ctl_entry(&entry->child);
83133 + for (entry = tablep; entry->mode; entry++) {
83134 + if (entry->child) {
83135 + sd_free_ctl_entry(entry->child);
83136 + pax_open_kernel();
83137 + entry->child = NULL;
83138 + pax_close_kernel();
83139 + }
83140 if (entry->proc_handler == NULL)
83141 kfree(entry->procname);
83142 }
83143
83144 - kfree(*tablep);
83145 - *tablep = NULL;
83146 + kfree(tablep);
83147 }
83148
83149 static int min_load_idx = 0;
83150 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
83151
83152 static void
83153 -set_table_entry(struct ctl_table *entry,
83154 +set_table_entry(ctl_table_no_const *entry,
83155 const char *procname, void *data, int maxlen,
83156 umode_t mode, proc_handler *proc_handler,
83157 bool load_idx)
83158 @@ -4543,7 +4550,7 @@ set_table_entry(struct ctl_table *entry,
83159 static struct ctl_table *
83160 sd_alloc_ctl_domain_table(struct sched_domain *sd)
83161 {
83162 - struct ctl_table *table = sd_alloc_ctl_entry(13);
83163 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
83164
83165 if (table == NULL)
83166 return NULL;
83167 @@ -4578,9 +4585,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
83168 return table;
83169 }
83170
83171 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
83172 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
83173 {
83174 - struct ctl_table *entry, *table;
83175 + ctl_table_no_const *entry, *table;
83176 struct sched_domain *sd;
83177 int domain_num = 0, i;
83178 char buf[32];
83179 @@ -4607,11 +4614,13 @@ static struct ctl_table_header *sd_sysctl_header;
83180 static void register_sched_domain_sysctl(void)
83181 {
83182 int i, cpu_num = num_possible_cpus();
83183 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
83184 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
83185 char buf[32];
83186
83187 WARN_ON(sd_ctl_dir[0].child);
83188 + pax_open_kernel();
83189 sd_ctl_dir[0].child = entry;
83190 + pax_close_kernel();
83191
83192 if (entry == NULL)
83193 return;
83194 @@ -4634,8 +4643,12 @@ static void unregister_sched_domain_sysctl(void)
83195 if (sd_sysctl_header)
83196 unregister_sysctl_table(sd_sysctl_header);
83197 sd_sysctl_header = NULL;
83198 - if (sd_ctl_dir[0].child)
83199 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
83200 + if (sd_ctl_dir[0].child) {
83201 + sd_free_ctl_entry(sd_ctl_dir[0].child);
83202 + pax_open_kernel();
83203 + sd_ctl_dir[0].child = NULL;
83204 + pax_close_kernel();
83205 + }
83206 }
83207 #else
83208 static void register_sched_domain_sysctl(void)
83209 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
83210 index 31cbc15..ba68c15 100644
83211 --- a/kernel/sched/fair.c
83212 +++ b/kernel/sched/fair.c
83213 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
83214
83215 static void reset_ptenuma_scan(struct task_struct *p)
83216 {
83217 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
83218 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
83219 p->mm->numa_scan_offset = 0;
83220 }
83221
83222 @@ -5727,7 +5727,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
83223 * run_rebalance_domains is triggered when needed from the scheduler tick.
83224 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
83225 */
83226 -static void run_rebalance_domains(struct softirq_action *h)
83227 +static __latent_entropy void run_rebalance_domains(void)
83228 {
83229 int this_cpu = smp_processor_id();
83230 struct rq *this_rq = cpu_rq(this_cpu);
83231 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
83232 index ef0a7b2..1b728c1 100644
83233 --- a/kernel/sched/sched.h
83234 +++ b/kernel/sched/sched.h
83235 @@ -1004,7 +1004,7 @@ struct sched_class {
83236 #ifdef CONFIG_FAIR_GROUP_SCHED
83237 void (*task_move_group) (struct task_struct *p, int on_rq);
83238 #endif
83239 -};
83240 +} __do_const;
83241
83242 #define sched_class_highest (&stop_sched_class)
83243 #define for_each_class(class) \
83244 diff --git a/kernel/signal.c b/kernel/signal.c
83245 index 50e4107..9409983 100644
83246 --- a/kernel/signal.c
83247 +++ b/kernel/signal.c
83248 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
83249
83250 int print_fatal_signals __read_mostly;
83251
83252 -static void __user *sig_handler(struct task_struct *t, int sig)
83253 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
83254 {
83255 return t->sighand->action[sig - 1].sa.sa_handler;
83256 }
83257
83258 -static int sig_handler_ignored(void __user *handler, int sig)
83259 +static int sig_handler_ignored(__sighandler_t handler, int sig)
83260 {
83261 /* Is it explicitly or implicitly ignored? */
83262 return handler == SIG_IGN ||
83263 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
83264
83265 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
83266 {
83267 - void __user *handler;
83268 + __sighandler_t handler;
83269
83270 handler = sig_handler(t, sig);
83271
83272 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
83273 atomic_inc(&user->sigpending);
83274 rcu_read_unlock();
83275
83276 + if (!override_rlimit)
83277 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
83278 +
83279 if (override_rlimit ||
83280 atomic_read(&user->sigpending) <=
83281 task_rlimit(t, RLIMIT_SIGPENDING)) {
83282 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
83283
83284 int unhandled_signal(struct task_struct *tsk, int sig)
83285 {
83286 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
83287 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
83288 if (is_global_init(tsk))
83289 return 1;
83290 if (handler != SIG_IGN && handler != SIG_DFL)
83291 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
83292 }
83293 }
83294
83295 + /* allow glibc communication via tgkill to other threads in our
83296 + thread group */
83297 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
83298 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
83299 + && gr_handle_signal(t, sig))
83300 + return -EPERM;
83301 +
83302 return security_task_kill(t, info, sig, 0);
83303 }
83304
83305 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83306 return send_signal(sig, info, p, 1);
83307 }
83308
83309 -static int
83310 +int
83311 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83312 {
83313 return send_signal(sig, info, t, 0);
83314 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83315 unsigned long int flags;
83316 int ret, blocked, ignored;
83317 struct k_sigaction *action;
83318 + int is_unhandled = 0;
83319
83320 spin_lock_irqsave(&t->sighand->siglock, flags);
83321 action = &t->sighand->action[sig-1];
83322 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83323 }
83324 if (action->sa.sa_handler == SIG_DFL)
83325 t->signal->flags &= ~SIGNAL_UNKILLABLE;
83326 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
83327 + is_unhandled = 1;
83328 ret = specific_send_sig_info(sig, info, t);
83329 spin_unlock_irqrestore(&t->sighand->siglock, flags);
83330
83331 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
83332 + normal operation */
83333 + if (is_unhandled) {
83334 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
83335 + gr_handle_crash(t, sig);
83336 + }
83337 +
83338 return ret;
83339 }
83340
83341 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83342 ret = check_kill_permission(sig, info, p);
83343 rcu_read_unlock();
83344
83345 - if (!ret && sig)
83346 + if (!ret && sig) {
83347 ret = do_send_sig_info(sig, info, p, true);
83348 + if (!ret)
83349 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
83350 + }
83351
83352 return ret;
83353 }
83354 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
83355 int error = -ESRCH;
83356
83357 rcu_read_lock();
83358 - p = find_task_by_vpid(pid);
83359 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
83360 + /* allow glibc communication via tgkill to other threads in our
83361 + thread group */
83362 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
83363 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
83364 + p = find_task_by_vpid_unrestricted(pid);
83365 + else
83366 +#endif
83367 + p = find_task_by_vpid(pid);
83368 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
83369 error = check_kill_permission(sig, info, p);
83370 /*
83371 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
83372 }
83373 seg = get_fs();
83374 set_fs(KERNEL_DS);
83375 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
83376 - (stack_t __force __user *) &uoss,
83377 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
83378 + (stack_t __force_user *) &uoss,
83379 compat_user_stack_pointer());
83380 set_fs(seg);
83381 if (ret >= 0 && uoss_ptr) {
83382 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
83383 index eb89e18..a4e6792 100644
83384 --- a/kernel/smpboot.c
83385 +++ b/kernel/smpboot.c
83386 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
83387 }
83388 smpboot_unpark_thread(plug_thread, cpu);
83389 }
83390 - list_add(&plug_thread->list, &hotplug_threads);
83391 + pax_list_add(&plug_thread->list, &hotplug_threads);
83392 out:
83393 mutex_unlock(&smpboot_threads_lock);
83394 return ret;
83395 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
83396 {
83397 get_online_cpus();
83398 mutex_lock(&smpboot_threads_lock);
83399 - list_del(&plug_thread->list);
83400 + pax_list_del(&plug_thread->list);
83401 smpboot_destroy_threads(plug_thread);
83402 mutex_unlock(&smpboot_threads_lock);
83403 put_online_cpus();
83404 diff --git a/kernel/softirq.c b/kernel/softirq.c
83405 index be3d351..e57af82 100644
83406 --- a/kernel/softirq.c
83407 +++ b/kernel/softirq.c
83408 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
83409 EXPORT_SYMBOL(irq_stat);
83410 #endif
83411
83412 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
83413 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
83414
83415 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
83416
83417 -char *softirq_to_name[NR_SOFTIRQS] = {
83418 +const char * const softirq_to_name[NR_SOFTIRQS] = {
83419 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
83420 "TASKLET", "SCHED", "HRTIMER", "RCU"
83421 };
83422 @@ -248,7 +248,7 @@ restart:
83423 kstat_incr_softirqs_this_cpu(vec_nr);
83424
83425 trace_softirq_entry(vec_nr);
83426 - h->action(h);
83427 + h->action();
83428 trace_softirq_exit(vec_nr);
83429 if (unlikely(prev_count != preempt_count())) {
83430 printk(KERN_ERR "huh, entered softirq %u %s %p"
83431 @@ -403,7 +403,7 @@ void __raise_softirq_irqoff(unsigned int nr)
83432 or_softirq_pending(1UL << nr);
83433 }
83434
83435 -void open_softirq(int nr, void (*action)(struct softirq_action *))
83436 +void __init open_softirq(int nr, void (*action)(void))
83437 {
83438 softirq_vec[nr].action = action;
83439 }
83440 @@ -459,7 +459,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
83441
83442 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
83443
83444 -static void tasklet_action(struct softirq_action *a)
83445 +static __latent_entropy void tasklet_action(void)
83446 {
83447 struct tasklet_struct *list;
83448
83449 @@ -494,7 +494,7 @@ static void tasklet_action(struct softirq_action *a)
83450 }
83451 }
83452
83453 -static void tasklet_hi_action(struct softirq_action *a)
83454 +static __latent_entropy void tasklet_hi_action(void)
83455 {
83456 struct tasklet_struct *list;
83457
83458 @@ -849,7 +849,7 @@ static struct notifier_block cpu_nfb = {
83459 .notifier_call = cpu_callback
83460 };
83461
83462 -static struct smp_hotplug_thread softirq_threads = {
83463 +static struct smp_hotplug_thread softirq_threads __read_only = {
83464 .store = &ksoftirqd,
83465 .thread_should_run = ksoftirqd_should_run,
83466 .thread_fn = run_ksoftirqd,
83467 diff --git a/kernel/srcu.c b/kernel/srcu.c
83468 index 01d5ccb..cdcbee6 100644
83469 --- a/kernel/srcu.c
83470 +++ b/kernel/srcu.c
83471 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
83472
83473 idx = ACCESS_ONCE(sp->completed) & 0x1;
83474 preempt_disable();
83475 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83476 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
83477 smp_mb(); /* B */ /* Avoid leaking the critical section. */
83478 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83479 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
83480 preempt_enable();
83481 return idx;
83482 }
83483 diff --git a/kernel/sys.c b/kernel/sys.c
83484 index 771129b..dc0c7e3 100644
83485 --- a/kernel/sys.c
83486 +++ b/kernel/sys.c
83487 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
83488 error = -EACCES;
83489 goto out;
83490 }
83491 +
83492 + if (gr_handle_chroot_setpriority(p, niceval)) {
83493 + error = -EACCES;
83494 + goto out;
83495 + }
83496 +
83497 no_nice = security_task_setnice(p, niceval);
83498 if (no_nice) {
83499 error = no_nice;
83500 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
83501 goto error;
83502 }
83503
83504 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
83505 + goto error;
83506 +
83507 if (rgid != (gid_t) -1 ||
83508 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
83509 new->sgid = new->egid;
83510 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
83511 old = current_cred();
83512
83513 retval = -EPERM;
83514 +
83515 + if (gr_check_group_change(kgid, kgid, kgid))
83516 + goto error;
83517 +
83518 if (nsown_capable(CAP_SETGID))
83519 new->gid = new->egid = new->sgid = new->fsgid = kgid;
83520 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
83521 @@ -404,7 +417,7 @@ error:
83522 /*
83523 * change the user struct in a credentials set to match the new UID
83524 */
83525 -static int set_user(struct cred *new)
83526 +int set_user(struct cred *new)
83527 {
83528 struct user_struct *new_user;
83529
83530 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
83531 goto error;
83532 }
83533
83534 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
83535 + goto error;
83536 +
83537 if (!uid_eq(new->uid, old->uid)) {
83538 retval = set_user(new);
83539 if (retval < 0)
83540 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
83541 old = current_cred();
83542
83543 retval = -EPERM;
83544 +
83545 + if (gr_check_crash_uid(kuid))
83546 + goto error;
83547 + if (gr_check_user_change(kuid, kuid, kuid))
83548 + goto error;
83549 +
83550 if (nsown_capable(CAP_SETUID)) {
83551 new->suid = new->uid = kuid;
83552 if (!uid_eq(kuid, old->uid)) {
83553 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
83554 goto error;
83555 }
83556
83557 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
83558 + goto error;
83559 +
83560 if (ruid != (uid_t) -1) {
83561 new->uid = kruid;
83562 if (!uid_eq(kruid, old->uid)) {
83563 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
83564 goto error;
83565 }
83566
83567 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
83568 + goto error;
83569 +
83570 if (rgid != (gid_t) -1)
83571 new->gid = krgid;
83572 if (egid != (gid_t) -1)
83573 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
83574 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
83575 nsown_capable(CAP_SETUID)) {
83576 if (!uid_eq(kuid, old->fsuid)) {
83577 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
83578 + goto error;
83579 +
83580 new->fsuid = kuid;
83581 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
83582 goto change_okay;
83583 }
83584 }
83585
83586 +error:
83587 abort_creds(new);
83588 return old_fsuid;
83589
83590 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
83591 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
83592 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
83593 nsown_capable(CAP_SETGID)) {
83594 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
83595 + goto error;
83596 +
83597 if (!gid_eq(kgid, old->fsgid)) {
83598 new->fsgid = kgid;
83599 goto change_okay;
83600 }
83601 }
83602
83603 +error:
83604 abort_creds(new);
83605 return old_fsgid;
83606
83607 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
83608 return -EFAULT;
83609
83610 down_read(&uts_sem);
83611 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
83612 + error = __copy_to_user(name->sysname, &utsname()->sysname,
83613 __OLD_UTS_LEN);
83614 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
83615 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
83616 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
83617 __OLD_UTS_LEN);
83618 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
83619 - error |= __copy_to_user(&name->release, &utsname()->release,
83620 + error |= __copy_to_user(name->release, &utsname()->release,
83621 __OLD_UTS_LEN);
83622 error |= __put_user(0, name->release + __OLD_UTS_LEN);
83623 - error |= __copy_to_user(&name->version, &utsname()->version,
83624 + error |= __copy_to_user(name->version, &utsname()->version,
83625 __OLD_UTS_LEN);
83626 error |= __put_user(0, name->version + __OLD_UTS_LEN);
83627 - error |= __copy_to_user(&name->machine, &utsname()->machine,
83628 + error |= __copy_to_user(name->machine, &utsname()->machine,
83629 __OLD_UTS_LEN);
83630 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
83631 up_read(&uts_sem);
83632 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
83633 */
83634 new_rlim->rlim_cur = 1;
83635 }
83636 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
83637 + is changed to a lower value. Since tasks can be created by the same
83638 + user in between this limit change and an execve by this task, force
83639 + a recheck only for this task by setting PF_NPROC_EXCEEDED
83640 + */
83641 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
83642 + tsk->flags |= PF_NPROC_EXCEEDED;
83643 }
83644 if (!retval) {
83645 if (old_rlim)
83646 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
83647 index 07f6fc4..65fb3d4 100644
83648 --- a/kernel/sysctl.c
83649 +++ b/kernel/sysctl.c
83650 @@ -93,7 +93,6 @@
83651
83652
83653 #if defined(CONFIG_SYSCTL)
83654 -
83655 /* External variables not in a header file. */
83656 extern int sysctl_overcommit_memory;
83657 extern int sysctl_overcommit_ratio;
83658 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
83659
83660 /* Constants used for minimum and maximum */
83661 #ifdef CONFIG_LOCKUP_DETECTOR
83662 -static int sixty = 60;
83663 +static int sixty __read_only = 60;
83664 #endif
83665
83666 -static int zero;
83667 -static int __maybe_unused one = 1;
83668 -static int __maybe_unused two = 2;
83669 -static int __maybe_unused three = 3;
83670 -static unsigned long one_ul = 1;
83671 -static int one_hundred = 100;
83672 +static int neg_one __read_only = -1;
83673 +static int zero __read_only = 0;
83674 +static int __maybe_unused one __read_only = 1;
83675 +static int __maybe_unused two __read_only = 2;
83676 +static int __maybe_unused three __read_only = 3;
83677 +static unsigned long one_ul __read_only = 1;
83678 +static int one_hundred __read_only = 100;
83679 #ifdef CONFIG_PRINTK
83680 -static int ten_thousand = 10000;
83681 +static int ten_thousand __read_only = 10000;
83682 #endif
83683
83684 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
83685 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
83686 void __user *buffer, size_t *lenp, loff_t *ppos);
83687 #endif
83688
83689 -#ifdef CONFIG_PRINTK
83690 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
83691 void __user *buffer, size_t *lenp, loff_t *ppos);
83692 -#endif
83693
83694 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
83695 void __user *buffer, size_t *lenp, loff_t *ppos);
83696 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
83697
83698 #endif
83699
83700 +extern struct ctl_table grsecurity_table[];
83701 +
83702 static struct ctl_table kern_table[];
83703 static struct ctl_table vm_table[];
83704 static struct ctl_table fs_table[];
83705 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
83706 int sysctl_legacy_va_layout;
83707 #endif
83708
83709 +#ifdef CONFIG_PAX_SOFTMODE
83710 +static ctl_table pax_table[] = {
83711 + {
83712 + .procname = "softmode",
83713 + .data = &pax_softmode,
83714 + .maxlen = sizeof(unsigned int),
83715 + .mode = 0600,
83716 + .proc_handler = &proc_dointvec,
83717 + },
83718 +
83719 + { }
83720 +};
83721 +#endif
83722 +
83723 /* The default sysctl tables: */
83724
83725 static struct ctl_table sysctl_base_table[] = {
83726 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
83727 #endif
83728
83729 static struct ctl_table kern_table[] = {
83730 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
83731 + {
83732 + .procname = "grsecurity",
83733 + .mode = 0500,
83734 + .child = grsecurity_table,
83735 + },
83736 +#endif
83737 +
83738 +#ifdef CONFIG_PAX_SOFTMODE
83739 + {
83740 + .procname = "pax",
83741 + .mode = 0500,
83742 + .child = pax_table,
83743 + },
83744 +#endif
83745 +
83746 {
83747 .procname = "sched_child_runs_first",
83748 .data = &sysctl_sched_child_runs_first,
83749 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
83750 .data = &modprobe_path,
83751 .maxlen = KMOD_PATH_LEN,
83752 .mode = 0644,
83753 - .proc_handler = proc_dostring,
83754 + .proc_handler = proc_dostring_modpriv,
83755 },
83756 {
83757 .procname = "modules_disabled",
83758 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
83759 .extra1 = &zero,
83760 .extra2 = &one,
83761 },
83762 +#endif
83763 {
83764 .procname = "kptr_restrict",
83765 .data = &kptr_restrict,
83766 .maxlen = sizeof(int),
83767 .mode = 0644,
83768 .proc_handler = proc_dointvec_minmax_sysadmin,
83769 +#ifdef CONFIG_GRKERNSEC_HIDESYM
83770 + .extra1 = &two,
83771 +#else
83772 .extra1 = &zero,
83773 +#endif
83774 .extra2 = &two,
83775 },
83776 -#endif
83777 {
83778 .procname = "ngroups_max",
83779 .data = &ngroups_max,
83780 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
83781 */
83782 {
83783 .procname = "perf_event_paranoid",
83784 - .data = &sysctl_perf_event_paranoid,
83785 - .maxlen = sizeof(sysctl_perf_event_paranoid),
83786 + .data = &sysctl_perf_event_legitimately_concerned,
83787 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
83788 .mode = 0644,
83789 - .proc_handler = proc_dointvec,
83790 + /* go ahead, be a hero */
83791 + .proc_handler = proc_dointvec_minmax_sysadmin,
83792 + .extra1 = &neg_one,
83793 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
83794 + .extra2 = &three,
83795 +#else
83796 + .extra2 = &two,
83797 +#endif
83798 },
83799 {
83800 .procname = "perf_event_mlock_kb",
83801 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
83802 .proc_handler = proc_dointvec_minmax,
83803 .extra1 = &zero,
83804 },
83805 + {
83806 + .procname = "heap_stack_gap",
83807 + .data = &sysctl_heap_stack_gap,
83808 + .maxlen = sizeof(sysctl_heap_stack_gap),
83809 + .mode = 0644,
83810 + .proc_handler = proc_doulongvec_minmax,
83811 + },
83812 #else
83813 {
83814 .procname = "nr_trim_pages",
83815 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
83816 buffer, lenp, ppos);
83817 }
83818
83819 +int proc_dostring_modpriv(struct ctl_table *table, int write,
83820 + void __user *buffer, size_t *lenp, loff_t *ppos)
83821 +{
83822 + if (write && !capable(CAP_SYS_MODULE))
83823 + return -EPERM;
83824 +
83825 + return _proc_do_string(table->data, table->maxlen, write,
83826 + buffer, lenp, ppos);
83827 +}
83828 +
83829 static size_t proc_skip_spaces(char **buf)
83830 {
83831 size_t ret;
83832 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
83833 len = strlen(tmp);
83834 if (len > *size)
83835 len = *size;
83836 + if (len > sizeof(tmp))
83837 + len = sizeof(tmp);
83838 if (copy_to_user(*buf, tmp, len))
83839 return -EFAULT;
83840 *size -= len;
83841 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
83842 static int proc_taint(struct ctl_table *table, int write,
83843 void __user *buffer, size_t *lenp, loff_t *ppos)
83844 {
83845 - struct ctl_table t;
83846 + ctl_table_no_const t;
83847 unsigned long tmptaint = get_taint();
83848 int err;
83849
83850 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
83851 return err;
83852 }
83853
83854 -#ifdef CONFIG_PRINTK
83855 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
83856 void __user *buffer, size_t *lenp, loff_t *ppos)
83857 {
83858 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
83859
83860 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
83861 }
83862 -#endif
83863
83864 struct do_proc_dointvec_minmax_conv_param {
83865 int *min;
83866 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
83867 *i = val;
83868 } else {
83869 val = convdiv * (*i) / convmul;
83870 - if (!first)
83871 + if (!first) {
83872 err = proc_put_char(&buffer, &left, '\t');
83873 + if (err)
83874 + break;
83875 + }
83876 err = proc_put_long(&buffer, &left, val, false);
83877 if (err)
83878 break;
83879 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
83880 return -ENOSYS;
83881 }
83882
83883 +int proc_dostring_modpriv(struct ctl_table *table, int write,
83884 + void __user *buffer, size_t *lenp, loff_t *ppos)
83885 +{
83886 + return -ENOSYS;
83887 +}
83888 +
83889 int proc_dointvec(struct ctl_table *table, int write,
83890 void __user *buffer, size_t *lenp, loff_t *ppos)
83891 {
83892 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
83893 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
83894 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
83895 EXPORT_SYMBOL(proc_dostring);
83896 +EXPORT_SYMBOL(proc_dostring_modpriv);
83897 EXPORT_SYMBOL(proc_doulongvec_minmax);
83898 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
83899 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
83900 index 145bb4d..b2aa969 100644
83901 --- a/kernel/taskstats.c
83902 +++ b/kernel/taskstats.c
83903 @@ -28,9 +28,12 @@
83904 #include <linux/fs.h>
83905 #include <linux/file.h>
83906 #include <linux/pid_namespace.h>
83907 +#include <linux/grsecurity.h>
83908 #include <net/genetlink.h>
83909 #include <linux/atomic.h>
83910
83911 +extern int gr_is_taskstats_denied(int pid);
83912 +
83913 /*
83914 * Maximum length of a cpumask that can be specified in
83915 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
83916 @@ -570,6 +573,9 @@ err:
83917
83918 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
83919 {
83920 + if (gr_is_taskstats_denied(current->pid))
83921 + return -EACCES;
83922 +
83923 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
83924 return cmd_attr_register_cpumask(info);
83925 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
83926 diff --git a/kernel/time.c b/kernel/time.c
83927 index 7c7964c..784a599 100644
83928 --- a/kernel/time.c
83929 +++ b/kernel/time.c
83930 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
83931 return error;
83932
83933 if (tz) {
83934 + /* we log in do_settimeofday called below, so don't log twice
83935 + */
83936 + if (!tv)
83937 + gr_log_timechange();
83938 +
83939 sys_tz = *tz;
83940 update_vsyscall_tz();
83941 if (firsttime) {
83942 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
83943 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
83944 * value to a scaled second value.
83945 */
83946 -unsigned long
83947 +unsigned long __intentional_overflow(-1)
83948 timespec_to_jiffies(const struct timespec *value)
83949 {
83950 unsigned long sec = value->tv_sec;
83951 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
83952 index eec50fc..65e5df6 100644
83953 --- a/kernel/time/alarmtimer.c
83954 +++ b/kernel/time/alarmtimer.c
83955 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
83956 struct platform_device *pdev;
83957 int error = 0;
83958 int i;
83959 - struct k_clock alarm_clock = {
83960 + static struct k_clock alarm_clock = {
83961 .clock_getres = alarm_clock_getres,
83962 .clock_get = alarm_clock_get,
83963 .timer_create = alarm_timer_create,
83964 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
83965 index 947ba25..20cbade 100644
83966 --- a/kernel/time/timekeeping.c
83967 +++ b/kernel/time/timekeeping.c
83968 @@ -15,6 +15,7 @@
83969 #include <linux/init.h>
83970 #include <linux/mm.h>
83971 #include <linux/sched.h>
83972 +#include <linux/grsecurity.h>
83973 #include <linux/syscore_ops.h>
83974 #include <linux/clocksource.h>
83975 #include <linux/jiffies.h>
83976 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
83977 if (!timespec_valid_strict(tv))
83978 return -EINVAL;
83979
83980 + gr_log_timechange();
83981 +
83982 raw_spin_lock_irqsave(&timekeeper_lock, flags);
83983 write_seqcount_begin(&timekeeper_seq);
83984
83985 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
83986 index 61ed862..3b52c65 100644
83987 --- a/kernel/time/timer_list.c
83988 +++ b/kernel/time/timer_list.c
83989 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
83990
83991 static void print_name_offset(struct seq_file *m, void *sym)
83992 {
83993 +#ifdef CONFIG_GRKERNSEC_HIDESYM
83994 + SEQ_printf(m, "<%p>", NULL);
83995 +#else
83996 char symname[KSYM_NAME_LEN];
83997
83998 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
83999 SEQ_printf(m, "<%pK>", sym);
84000 else
84001 SEQ_printf(m, "%s", symname);
84002 +#endif
84003 }
84004
84005 static void
84006 @@ -119,7 +123,11 @@ next_one:
84007 static void
84008 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
84009 {
84010 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84011 + SEQ_printf(m, " .base: %p\n", NULL);
84012 +#else
84013 SEQ_printf(m, " .base: %pK\n", base);
84014 +#endif
84015 SEQ_printf(m, " .index: %d\n",
84016 base->index);
84017 SEQ_printf(m, " .resolution: %Lu nsecs\n",
84018 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
84019 {
84020 struct proc_dir_entry *pe;
84021
84022 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84023 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
84024 +#else
84025 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
84026 +#endif
84027 if (!pe)
84028 return -ENOMEM;
84029 return 0;
84030 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
84031 index 0b537f2..40d6c20 100644
84032 --- a/kernel/time/timer_stats.c
84033 +++ b/kernel/time/timer_stats.c
84034 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
84035 static unsigned long nr_entries;
84036 static struct entry entries[MAX_ENTRIES];
84037
84038 -static atomic_t overflow_count;
84039 +static atomic_unchecked_t overflow_count;
84040
84041 /*
84042 * The entries are in a hash-table, for fast lookup:
84043 @@ -140,7 +140,7 @@ static void reset_entries(void)
84044 nr_entries = 0;
84045 memset(entries, 0, sizeof(entries));
84046 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
84047 - atomic_set(&overflow_count, 0);
84048 + atomic_set_unchecked(&overflow_count, 0);
84049 }
84050
84051 static struct entry *alloc_entry(void)
84052 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84053 if (likely(entry))
84054 entry->count++;
84055 else
84056 - atomic_inc(&overflow_count);
84057 + atomic_inc_unchecked(&overflow_count);
84058
84059 out_unlock:
84060 raw_spin_unlock_irqrestore(lock, flags);
84061 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84062
84063 static void print_name_offset(struct seq_file *m, unsigned long addr)
84064 {
84065 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84066 + seq_printf(m, "<%p>", NULL);
84067 +#else
84068 char symname[KSYM_NAME_LEN];
84069
84070 if (lookup_symbol_name(addr, symname) < 0)
84071 - seq_printf(m, "<%p>", (void *)addr);
84072 + seq_printf(m, "<%pK>", (void *)addr);
84073 else
84074 seq_printf(m, "%s", symname);
84075 +#endif
84076 }
84077
84078 static int tstats_show(struct seq_file *m, void *v)
84079 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
84080
84081 seq_puts(m, "Timer Stats Version: v0.2\n");
84082 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
84083 - if (atomic_read(&overflow_count))
84084 + if (atomic_read_unchecked(&overflow_count))
84085 seq_printf(m, "Overflow: %d entries\n",
84086 - atomic_read(&overflow_count));
84087 + atomic_read_unchecked(&overflow_count));
84088
84089 for (i = 0; i < nr_entries; i++) {
84090 entry = entries + i;
84091 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
84092 {
84093 struct proc_dir_entry *pe;
84094
84095 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84096 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
84097 +#else
84098 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
84099 +#endif
84100 if (!pe)
84101 return -ENOMEM;
84102 return 0;
84103 diff --git a/kernel/timer.c b/kernel/timer.c
84104 index 4296d13..0164b04 100644
84105 --- a/kernel/timer.c
84106 +++ b/kernel/timer.c
84107 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
84108 /*
84109 * This function runs timers and the timer-tq in bottom half context.
84110 */
84111 -static void run_timer_softirq(struct softirq_action *h)
84112 +static __latent_entropy void run_timer_softirq(void)
84113 {
84114 struct tvec_base *base = __this_cpu_read(tvec_bases);
84115
84116 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
84117 *
84118 * In all cases the return value is guaranteed to be non-negative.
84119 */
84120 -signed long __sched schedule_timeout(signed long timeout)
84121 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
84122 {
84123 struct timer_list timer;
84124 unsigned long expire;
84125 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
84126 index b8b8560..75b1a09 100644
84127 --- a/kernel/trace/blktrace.c
84128 +++ b/kernel/trace/blktrace.c
84129 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
84130 struct blk_trace *bt = filp->private_data;
84131 char buf[16];
84132
84133 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
84134 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
84135
84136 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
84137 }
84138 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
84139 return 1;
84140
84141 bt = buf->chan->private_data;
84142 - atomic_inc(&bt->dropped);
84143 + atomic_inc_unchecked(&bt->dropped);
84144 return 0;
84145 }
84146
84147 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
84148
84149 bt->dir = dir;
84150 bt->dev = dev;
84151 - atomic_set(&bt->dropped, 0);
84152 + atomic_set_unchecked(&bt->dropped, 0);
84153
84154 ret = -EIO;
84155 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
84156 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
84157 index a6d098c..bb8cf65 100644
84158 --- a/kernel/trace/ftrace.c
84159 +++ b/kernel/trace/ftrace.c
84160 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
84161 if (unlikely(ftrace_disabled))
84162 return 0;
84163
84164 + ret = ftrace_arch_code_modify_prepare();
84165 + FTRACE_WARN_ON(ret);
84166 + if (ret)
84167 + return 0;
84168 +
84169 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
84170 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
84171 if (ret) {
84172 ftrace_bug(ret, ip);
84173 - return 0;
84174 }
84175 - return 1;
84176 + return ret ? 0 : 1;
84177 }
84178
84179 /*
84180 @@ -4028,8 +4033,10 @@ static int ftrace_process_locs(struct module *mod,
84181 if (!count)
84182 return 0;
84183
84184 + pax_open_kernel();
84185 sort(start, count, sizeof(*start),
84186 ftrace_cmp_ips, ftrace_swap_ips);
84187 + pax_close_kernel();
84188
84189 start_pg = ftrace_allocate_pages(count);
84190 if (!start_pg)
84191 @@ -4752,8 +4759,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
84192 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
84193
84194 static int ftrace_graph_active;
84195 -static struct notifier_block ftrace_suspend_notifier;
84196 -
84197 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
84198 {
84199 return 0;
84200 @@ -4897,6 +4902,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
84201 return NOTIFY_DONE;
84202 }
84203
84204 +static struct notifier_block ftrace_suspend_notifier = {
84205 + .notifier_call = ftrace_suspend_notifier_call
84206 +};
84207 +
84208 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84209 trace_func_graph_ent_t entryfunc)
84210 {
84211 @@ -4910,7 +4919,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84212 goto out;
84213 }
84214
84215 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
84216 register_pm_notifier(&ftrace_suspend_notifier);
84217
84218 ftrace_graph_active++;
84219 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
84220 index cc2f66f..05edd54 100644
84221 --- a/kernel/trace/ring_buffer.c
84222 +++ b/kernel/trace/ring_buffer.c
84223 @@ -352,9 +352,9 @@ struct buffer_data_page {
84224 */
84225 struct buffer_page {
84226 struct list_head list; /* list of buffer pages */
84227 - local_t write; /* index for next write */
84228 + local_unchecked_t write; /* index for next write */
84229 unsigned read; /* index for next read */
84230 - local_t entries; /* entries on this page */
84231 + local_unchecked_t entries; /* entries on this page */
84232 unsigned long real_end; /* real end of data */
84233 struct buffer_data_page *page; /* Actual data page */
84234 };
84235 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
84236 unsigned long last_overrun;
84237 local_t entries_bytes;
84238 local_t entries;
84239 - local_t overrun;
84240 - local_t commit_overrun;
84241 + local_unchecked_t overrun;
84242 + local_unchecked_t commit_overrun;
84243 local_t dropped_events;
84244 local_t committing;
84245 local_t commits;
84246 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84247 *
84248 * We add a counter to the write field to denote this.
84249 */
84250 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
84251 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
84252 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
84253 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
84254
84255 /*
84256 * Just make sure we have seen our old_write and synchronize
84257 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84258 * cmpxchg to only update if an interrupt did not already
84259 * do it for us. If the cmpxchg fails, we don't care.
84260 */
84261 - (void)local_cmpxchg(&next_page->write, old_write, val);
84262 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
84263 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
84264 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
84265
84266 /*
84267 * No need to worry about races with clearing out the commit.
84268 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
84269
84270 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
84271 {
84272 - return local_read(&bpage->entries) & RB_WRITE_MASK;
84273 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
84274 }
84275
84276 static inline unsigned long rb_page_write(struct buffer_page *bpage)
84277 {
84278 - return local_read(&bpage->write) & RB_WRITE_MASK;
84279 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
84280 }
84281
84282 static int
84283 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
84284 * bytes consumed in ring buffer from here.
84285 * Increment overrun to account for the lost events.
84286 */
84287 - local_add(page_entries, &cpu_buffer->overrun);
84288 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
84289 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84290 }
84291
84292 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
84293 * it is our responsibility to update
84294 * the counters.
84295 */
84296 - local_add(entries, &cpu_buffer->overrun);
84297 + local_add_unchecked(entries, &cpu_buffer->overrun);
84298 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84299
84300 /*
84301 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84302 if (tail == BUF_PAGE_SIZE)
84303 tail_page->real_end = 0;
84304
84305 - local_sub(length, &tail_page->write);
84306 + local_sub_unchecked(length, &tail_page->write);
84307 return;
84308 }
84309
84310 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84311 rb_event_set_padding(event);
84312
84313 /* Set the write back to the previous setting */
84314 - local_sub(length, &tail_page->write);
84315 + local_sub_unchecked(length, &tail_page->write);
84316 return;
84317 }
84318
84319 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84320
84321 /* Set write to end of buffer */
84322 length = (tail + length) - BUF_PAGE_SIZE;
84323 - local_sub(length, &tail_page->write);
84324 + local_sub_unchecked(length, &tail_page->write);
84325 }
84326
84327 /*
84328 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84329 * about it.
84330 */
84331 if (unlikely(next_page == commit_page)) {
84332 - local_inc(&cpu_buffer->commit_overrun);
84333 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84334 goto out_reset;
84335 }
84336
84337 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84338 cpu_buffer->tail_page) &&
84339 (cpu_buffer->commit_page ==
84340 cpu_buffer->reader_page))) {
84341 - local_inc(&cpu_buffer->commit_overrun);
84342 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84343 goto out_reset;
84344 }
84345 }
84346 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84347 length += RB_LEN_TIME_EXTEND;
84348
84349 tail_page = cpu_buffer->tail_page;
84350 - write = local_add_return(length, &tail_page->write);
84351 + write = local_add_return_unchecked(length, &tail_page->write);
84352
84353 /* set write to only the index of the write */
84354 write &= RB_WRITE_MASK;
84355 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84356 kmemcheck_annotate_bitfield(event, bitfield);
84357 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
84358
84359 - local_inc(&tail_page->entries);
84360 + local_inc_unchecked(&tail_page->entries);
84361
84362 /*
84363 * If this is the first commit on the page, then update
84364 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84365
84366 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
84367 unsigned long write_mask =
84368 - local_read(&bpage->write) & ~RB_WRITE_MASK;
84369 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
84370 unsigned long event_length = rb_event_length(event);
84371 /*
84372 * This is on the tail page. It is possible that
84373 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84374 */
84375 old_index += write_mask;
84376 new_index += write_mask;
84377 - index = local_cmpxchg(&bpage->write, old_index, new_index);
84378 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
84379 if (index == old_index) {
84380 /* update counters */
84381 local_sub(event_length, &cpu_buffer->entries_bytes);
84382 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84383
84384 /* Do the likely case first */
84385 if (likely(bpage->page == (void *)addr)) {
84386 - local_dec(&bpage->entries);
84387 + local_dec_unchecked(&bpage->entries);
84388 return;
84389 }
84390
84391 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84392 start = bpage;
84393 do {
84394 if (bpage->page == (void *)addr) {
84395 - local_dec(&bpage->entries);
84396 + local_dec_unchecked(&bpage->entries);
84397 return;
84398 }
84399 rb_inc_page(cpu_buffer, &bpage);
84400 @@ -3139,7 +3139,7 @@ static inline unsigned long
84401 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
84402 {
84403 return local_read(&cpu_buffer->entries) -
84404 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
84405 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
84406 }
84407
84408 /**
84409 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
84410 return 0;
84411
84412 cpu_buffer = buffer->buffers[cpu];
84413 - ret = local_read(&cpu_buffer->overrun);
84414 + ret = local_read_unchecked(&cpu_buffer->overrun);
84415
84416 return ret;
84417 }
84418 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
84419 return 0;
84420
84421 cpu_buffer = buffer->buffers[cpu];
84422 - ret = local_read(&cpu_buffer->commit_overrun);
84423 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
84424
84425 return ret;
84426 }
84427 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
84428 /* if you care about this being correct, lock the buffer */
84429 for_each_buffer_cpu(buffer, cpu) {
84430 cpu_buffer = buffer->buffers[cpu];
84431 - overruns += local_read(&cpu_buffer->overrun);
84432 + overruns += local_read_unchecked(&cpu_buffer->overrun);
84433 }
84434
84435 return overruns;
84436 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84437 /*
84438 * Reset the reader page to size zero.
84439 */
84440 - local_set(&cpu_buffer->reader_page->write, 0);
84441 - local_set(&cpu_buffer->reader_page->entries, 0);
84442 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84443 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84444 local_set(&cpu_buffer->reader_page->page->commit, 0);
84445 cpu_buffer->reader_page->real_end = 0;
84446
84447 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
84448 * want to compare with the last_overrun.
84449 */
84450 smp_mb();
84451 - overwrite = local_read(&(cpu_buffer->overrun));
84452 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
84453
84454 /*
84455 * Here's the tricky part.
84456 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84457
84458 cpu_buffer->head_page
84459 = list_entry(cpu_buffer->pages, struct buffer_page, list);
84460 - local_set(&cpu_buffer->head_page->write, 0);
84461 - local_set(&cpu_buffer->head_page->entries, 0);
84462 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
84463 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
84464 local_set(&cpu_buffer->head_page->page->commit, 0);
84465
84466 cpu_buffer->head_page->read = 0;
84467 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
84468
84469 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
84470 INIT_LIST_HEAD(&cpu_buffer->new_pages);
84471 - local_set(&cpu_buffer->reader_page->write, 0);
84472 - local_set(&cpu_buffer->reader_page->entries, 0);
84473 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
84474 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
84475 local_set(&cpu_buffer->reader_page->page->commit, 0);
84476 cpu_buffer->reader_page->read = 0;
84477
84478 local_set(&cpu_buffer->entries_bytes, 0);
84479 - local_set(&cpu_buffer->overrun, 0);
84480 - local_set(&cpu_buffer->commit_overrun, 0);
84481 + local_set_unchecked(&cpu_buffer->overrun, 0);
84482 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
84483 local_set(&cpu_buffer->dropped_events, 0);
84484 local_set(&cpu_buffer->entries, 0);
84485 local_set(&cpu_buffer->committing, 0);
84486 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
84487 rb_init_page(bpage);
84488 bpage = reader->page;
84489 reader->page = *data_page;
84490 - local_set(&reader->write, 0);
84491 - local_set(&reader->entries, 0);
84492 + local_set_unchecked(&reader->write, 0);
84493 + local_set_unchecked(&reader->entries, 0);
84494 reader->read = 0;
84495 *data_page = bpage;
84496
84497 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
84498 index 496f94d..754aeea 100644
84499 --- a/kernel/trace/trace.c
84500 +++ b/kernel/trace/trace.c
84501 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
84502 return 0;
84503 }
84504
84505 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
84506 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
84507 {
84508 /* do nothing if flag is already set */
84509 if (!!(trace_flags & mask) == !!enabled)
84510 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
84511 index afaae41..64871f8 100644
84512 --- a/kernel/trace/trace.h
84513 +++ b/kernel/trace/trace.h
84514 @@ -1025,7 +1025,7 @@ extern const char *__stop___trace_bprintk_fmt[];
84515 void trace_printk_init_buffers(void);
84516 void trace_printk_start_comm(void);
84517 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
84518 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
84519 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
84520
84521 /*
84522 * Normal trace_printk() and friends allocates special buffers
84523 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
84524 index 26dc348..8708ca7 100644
84525 --- a/kernel/trace/trace_clock.c
84526 +++ b/kernel/trace/trace_clock.c
84527 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
84528 return now;
84529 }
84530
84531 -static atomic64_t trace_counter;
84532 +static atomic64_unchecked_t trace_counter;
84533
84534 /*
84535 * trace_clock_counter(): simply an atomic counter.
84536 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
84537 */
84538 u64 notrace trace_clock_counter(void)
84539 {
84540 - return atomic64_add_return(1, &trace_counter);
84541 + return atomic64_inc_return_unchecked(&trace_counter);
84542 }
84543 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
84544 index 29a7ebc..eb473cf 100644
84545 --- a/kernel/trace/trace_events.c
84546 +++ b/kernel/trace/trace_events.c
84547 @@ -1778,10 +1778,6 @@ static LIST_HEAD(ftrace_module_file_list);
84548 struct ftrace_module_file_ops {
84549 struct list_head list;
84550 struct module *mod;
84551 - struct file_operations id;
84552 - struct file_operations enable;
84553 - struct file_operations format;
84554 - struct file_operations filter;
84555 };
84556
84557 static struct ftrace_module_file_ops *
84558 @@ -1822,17 +1818,12 @@ trace_create_file_ops(struct module *mod)
84559
84560 file_ops->mod = mod;
84561
84562 - file_ops->id = ftrace_event_id_fops;
84563 - file_ops->id.owner = mod;
84564 -
84565 - file_ops->enable = ftrace_enable_fops;
84566 - file_ops->enable.owner = mod;
84567 -
84568 - file_ops->filter = ftrace_event_filter_fops;
84569 - file_ops->filter.owner = mod;
84570 -
84571 - file_ops->format = ftrace_event_format_fops;
84572 - file_ops->format.owner = mod;
84573 + pax_open_kernel();
84574 + mod->trace_id.owner = mod;
84575 + mod->trace_enable.owner = mod;
84576 + mod->trace_filter.owner = mod;
84577 + mod->trace_format.owner = mod;
84578 + pax_close_kernel();
84579
84580 list_add(&file_ops->list, &ftrace_module_file_list);
84581
84582 @@ -1925,8 +1916,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
84583 struct ftrace_module_file_ops *file_ops)
84584 {
84585 return __trace_add_new_event(call, tr,
84586 - &file_ops->id, &file_ops->enable,
84587 - &file_ops->filter, &file_ops->format);
84588 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
84589 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
84590 }
84591
84592 #else
84593 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
84594 index b3dcfb2..ebee344 100644
84595 --- a/kernel/trace/trace_mmiotrace.c
84596 +++ b/kernel/trace/trace_mmiotrace.c
84597 @@ -24,7 +24,7 @@ struct header_iter {
84598 static struct trace_array *mmio_trace_array;
84599 static bool overrun_detected;
84600 static unsigned long prev_overruns;
84601 -static atomic_t dropped_count;
84602 +static atomic_unchecked_t dropped_count;
84603
84604 static void mmio_reset_data(struct trace_array *tr)
84605 {
84606 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
84607
84608 static unsigned long count_overruns(struct trace_iterator *iter)
84609 {
84610 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
84611 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
84612 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
84613
84614 if (over > prev_overruns)
84615 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
84616 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
84617 sizeof(*entry), 0, pc);
84618 if (!event) {
84619 - atomic_inc(&dropped_count);
84620 + atomic_inc_unchecked(&dropped_count);
84621 return;
84622 }
84623 entry = ring_buffer_event_data(event);
84624 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
84625 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
84626 sizeof(*entry), 0, pc);
84627 if (!event) {
84628 - atomic_inc(&dropped_count);
84629 + atomic_inc_unchecked(&dropped_count);
84630 return;
84631 }
84632 entry = ring_buffer_event_data(event);
84633 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
84634 index 34e7cba..6f9a729 100644
84635 --- a/kernel/trace/trace_output.c
84636 +++ b/kernel/trace/trace_output.c
84637 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
84638
84639 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
84640 if (!IS_ERR(p)) {
84641 - p = mangle_path(s->buffer + s->len, p, "\n");
84642 + p = mangle_path(s->buffer + s->len, p, "\n\\");
84643 if (p) {
84644 s->len = p - s->buffer;
84645 return 1;
84646 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
84647 goto out;
84648 }
84649
84650 + pax_open_kernel();
84651 if (event->funcs->trace == NULL)
84652 - event->funcs->trace = trace_nop_print;
84653 + *(void **)&event->funcs->trace = trace_nop_print;
84654 if (event->funcs->raw == NULL)
84655 - event->funcs->raw = trace_nop_print;
84656 + *(void **)&event->funcs->raw = trace_nop_print;
84657 if (event->funcs->hex == NULL)
84658 - event->funcs->hex = trace_nop_print;
84659 + *(void **)&event->funcs->hex = trace_nop_print;
84660 if (event->funcs->binary == NULL)
84661 - event->funcs->binary = trace_nop_print;
84662 + *(void **)&event->funcs->binary = trace_nop_print;
84663 + pax_close_kernel();
84664
84665 key = event->type & (EVENT_HASHSIZE - 1);
84666
84667 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
84668 index b20428c..4845a10 100644
84669 --- a/kernel/trace/trace_stack.c
84670 +++ b/kernel/trace/trace_stack.c
84671 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
84672 return;
84673
84674 /* we do not handle interrupt stacks yet */
84675 - if (!object_is_on_stack(stack))
84676 + if (!object_starts_on_stack(stack))
84677 return;
84678
84679 local_irq_save(flags);
84680 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
84681 index 9064b91..1f5d2f8 100644
84682 --- a/kernel/user_namespace.c
84683 +++ b/kernel/user_namespace.c
84684 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
84685 !kgid_has_mapping(parent_ns, group))
84686 return -EPERM;
84687
84688 +#ifdef CONFIG_GRKERNSEC
84689 + /*
84690 + * This doesn't really inspire confidence:
84691 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
84692 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
84693 + * Increases kernel attack surface in areas developers
84694 + * previously cared little about ("low importance due
84695 + * to requiring "root" capability")
84696 + * To be removed when this code receives *proper* review
84697 + */
84698 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
84699 + !capable(CAP_SETGID))
84700 + return -EPERM;
84701 +#endif
84702 +
84703 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
84704 if (!ns)
84705 return -ENOMEM;
84706 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
84707 if (atomic_read(&current->mm->mm_users) > 1)
84708 return -EINVAL;
84709
84710 - if (current->fs->users != 1)
84711 + if (atomic_read(&current->fs->users) != 1)
84712 return -EINVAL;
84713
84714 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
84715 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
84716 index 4f69f9a..7c6f8f8 100644
84717 --- a/kernel/utsname_sysctl.c
84718 +++ b/kernel/utsname_sysctl.c
84719 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
84720 static int proc_do_uts_string(ctl_table *table, int write,
84721 void __user *buffer, size_t *lenp, loff_t *ppos)
84722 {
84723 - struct ctl_table uts_table;
84724 + ctl_table_no_const uts_table;
84725 int r;
84726 memcpy(&uts_table, table, sizeof(uts_table));
84727 uts_table.data = get_uts(table, write);
84728 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
84729 index 1241d8c..d5cfc28 100644
84730 --- a/kernel/watchdog.c
84731 +++ b/kernel/watchdog.c
84732 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
84733 static void watchdog_nmi_disable(unsigned int cpu) { return; }
84734 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
84735
84736 -static struct smp_hotplug_thread watchdog_threads = {
84737 +static struct smp_hotplug_thread watchdog_threads __read_only = {
84738 .store = &softlockup_watchdog,
84739 .thread_should_run = watchdog_should_run,
84740 .thread_fn = watchdog,
84741 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
84742 index e93f7b9..989fcd7 100644
84743 --- a/kernel/workqueue.c
84744 +++ b/kernel/workqueue.c
84745 @@ -4627,7 +4627,7 @@ static void rebind_workers(struct worker_pool *pool)
84746 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
84747 worker_flags |= WORKER_REBOUND;
84748 worker_flags &= ~WORKER_UNBOUND;
84749 - ACCESS_ONCE(worker->flags) = worker_flags;
84750 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
84751 }
84752
84753 spin_unlock_irq(&pool->lock);
84754 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
84755 index 1501aa5..e771896 100644
84756 --- a/lib/Kconfig.debug
84757 +++ b/lib/Kconfig.debug
84758 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
84759
84760 config DEBUG_WW_MUTEX_SLOWPATH
84761 bool "Wait/wound mutex debugging: Slowpath testing"
84762 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
84763 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
84764 select DEBUG_LOCK_ALLOC
84765 select DEBUG_SPINLOCK
84766 select DEBUG_MUTEXES
84767 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
84768
84769 config DEBUG_LOCK_ALLOC
84770 bool "Lock debugging: detect incorrect freeing of live locks"
84771 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
84772 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
84773 select DEBUG_SPINLOCK
84774 select DEBUG_MUTEXES
84775 select LOCKDEP
84776 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
84777
84778 config PROVE_LOCKING
84779 bool "Lock debugging: prove locking correctness"
84780 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
84781 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
84782 select LOCKDEP
84783 select DEBUG_SPINLOCK
84784 select DEBUG_MUTEXES
84785 @@ -914,7 +914,7 @@ config LOCKDEP
84786
84787 config LOCK_STAT
84788 bool "Lock usage statistics"
84789 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
84790 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
84791 select LOCKDEP
84792 select DEBUG_SPINLOCK
84793 select DEBUG_MUTEXES
84794 @@ -1357,6 +1357,7 @@ config LATENCYTOP
84795 depends on DEBUG_KERNEL
84796 depends on STACKTRACE_SUPPORT
84797 depends on PROC_FS
84798 + depends on !GRKERNSEC_HIDESYM
84799 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
84800 select KALLSYMS
84801 select KALLSYMS_ALL
84802 @@ -1373,7 +1374,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
84803 config DEBUG_STRICT_USER_COPY_CHECKS
84804 bool "Strict user copy size checks"
84805 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
84806 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
84807 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
84808 help
84809 Enabling this option turns a certain set of sanity checks for user
84810 copy operations into compile time failures.
84811 @@ -1483,7 +1484,7 @@ endmenu # runtime tests
84812
84813 config PROVIDE_OHCI1394_DMA_INIT
84814 bool "Remote debugging over FireWire early on boot"
84815 - depends on PCI && X86
84816 + depends on PCI && X86 && !GRKERNSEC
84817 help
84818 If you want to debug problems which hang or crash the kernel early
84819 on boot and the crashing machine has a FireWire port, you can use
84820 @@ -1512,7 +1513,7 @@ config PROVIDE_OHCI1394_DMA_INIT
84821
84822 config FIREWIRE_OHCI_REMOTE_DMA
84823 bool "Remote debugging over FireWire with firewire-ohci"
84824 - depends on FIREWIRE_OHCI
84825 + depends on FIREWIRE_OHCI && !GRKERNSEC
84826 help
84827 This option lets you use the FireWire bus for remote debugging
84828 with help of the firewire-ohci driver. It enables unfiltered
84829 diff --git a/lib/Makefile b/lib/Makefile
84830 index 7baccfd..3ceb95f 100644
84831 --- a/lib/Makefile
84832 +++ b/lib/Makefile
84833 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
84834
84835 obj-$(CONFIG_BTREE) += btree.o
84836 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
84837 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
84838 +obj-y += list_debug.o
84839 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
84840
84841 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
84842 diff --git a/lib/bitmap.c b/lib/bitmap.c
84843 index 06f7e4f..f3cf2b0 100644
84844 --- a/lib/bitmap.c
84845 +++ b/lib/bitmap.c
84846 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
84847 {
84848 int c, old_c, totaldigits, ndigits, nchunks, nbits;
84849 u32 chunk;
84850 - const char __user __force *ubuf = (const char __user __force *)buf;
84851 + const char __user *ubuf = (const char __force_user *)buf;
84852
84853 bitmap_zero(maskp, nmaskbits);
84854
84855 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
84856 {
84857 if (!access_ok(VERIFY_READ, ubuf, ulen))
84858 return -EFAULT;
84859 - return __bitmap_parse((const char __force *)ubuf,
84860 + return __bitmap_parse((const char __force_kernel *)ubuf,
84861 ulen, 1, maskp, nmaskbits);
84862
84863 }
84864 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
84865 {
84866 unsigned a, b;
84867 int c, old_c, totaldigits;
84868 - const char __user __force *ubuf = (const char __user __force *)buf;
84869 + const char __user *ubuf = (const char __force_user *)buf;
84870 int exp_digit, in_range;
84871
84872 totaldigits = c = 0;
84873 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
84874 {
84875 if (!access_ok(VERIFY_READ, ubuf, ulen))
84876 return -EFAULT;
84877 - return __bitmap_parselist((const char __force *)ubuf,
84878 + return __bitmap_parselist((const char __force_kernel *)ubuf,
84879 ulen, 1, maskp, nmaskbits);
84880 }
84881 EXPORT_SYMBOL(bitmap_parselist_user);
84882 diff --git a/lib/bug.c b/lib/bug.c
84883 index 1686034..a9c00c8 100644
84884 --- a/lib/bug.c
84885 +++ b/lib/bug.c
84886 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
84887 return BUG_TRAP_TYPE_NONE;
84888
84889 bug = find_bug(bugaddr);
84890 + if (!bug)
84891 + return BUG_TRAP_TYPE_NONE;
84892
84893 file = NULL;
84894 line = 0;
84895 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
84896 index 37061ed..da83f48 100644
84897 --- a/lib/debugobjects.c
84898 +++ b/lib/debugobjects.c
84899 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
84900 if (limit > 4)
84901 return;
84902
84903 - is_on_stack = object_is_on_stack(addr);
84904 + is_on_stack = object_starts_on_stack(addr);
84905 if (is_on_stack == onstack)
84906 return;
84907
84908 diff --git a/lib/devres.c b/lib/devres.c
84909 index 8235331..5881053 100644
84910 --- a/lib/devres.c
84911 +++ b/lib/devres.c
84912 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
84913 void devm_iounmap(struct device *dev, void __iomem *addr)
84914 {
84915 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
84916 - (void *)addr));
84917 + (void __force *)addr));
84918 iounmap(addr);
84919 }
84920 EXPORT_SYMBOL(devm_iounmap);
84921 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
84922 {
84923 ioport_unmap(addr);
84924 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
84925 - devm_ioport_map_match, (void *)addr));
84926 + devm_ioport_map_match, (void __force *)addr));
84927 }
84928 EXPORT_SYMBOL(devm_ioport_unmap);
84929 #endif /* CONFIG_HAS_IOPORT */
84930 diff --git a/lib/div64.c b/lib/div64.c
84931 index a163b6c..9618fa5 100644
84932 --- a/lib/div64.c
84933 +++ b/lib/div64.c
84934 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
84935 EXPORT_SYMBOL(__div64_32);
84936
84937 #ifndef div_s64_rem
84938 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
84939 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
84940 {
84941 u64 quotient;
84942
84943 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
84944 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
84945 */
84946 #ifndef div64_u64
84947 -u64 div64_u64(u64 dividend, u64 divisor)
84948 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
84949 {
84950 u32 high = divisor >> 32;
84951 u64 quot;
84952 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
84953 index d87a17a..ac0d79a 100644
84954 --- a/lib/dma-debug.c
84955 +++ b/lib/dma-debug.c
84956 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
84957
84958 void dma_debug_add_bus(struct bus_type *bus)
84959 {
84960 - struct notifier_block *nb;
84961 + notifier_block_no_const *nb;
84962
84963 if (global_disable)
84964 return;
84965 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
84966
84967 static void check_for_stack(struct device *dev, void *addr)
84968 {
84969 - if (object_is_on_stack(addr))
84970 + if (object_starts_on_stack(addr))
84971 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
84972 "stack [addr=%p]\n", addr);
84973 }
84974 diff --git a/lib/inflate.c b/lib/inflate.c
84975 index 013a761..c28f3fc 100644
84976 --- a/lib/inflate.c
84977 +++ b/lib/inflate.c
84978 @@ -269,7 +269,7 @@ static void free(void *where)
84979 malloc_ptr = free_mem_ptr;
84980 }
84981 #else
84982 -#define malloc(a) kmalloc(a, GFP_KERNEL)
84983 +#define malloc(a) kmalloc((a), GFP_KERNEL)
84984 #define free(a) kfree(a)
84985 #endif
84986
84987 diff --git a/lib/ioremap.c b/lib/ioremap.c
84988 index 0c9216c..863bd89 100644
84989 --- a/lib/ioremap.c
84990 +++ b/lib/ioremap.c
84991 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
84992 unsigned long next;
84993
84994 phys_addr -= addr;
84995 - pmd = pmd_alloc(&init_mm, pud, addr);
84996 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
84997 if (!pmd)
84998 return -ENOMEM;
84999 do {
85000 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
85001 unsigned long next;
85002
85003 phys_addr -= addr;
85004 - pud = pud_alloc(&init_mm, pgd, addr);
85005 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85006 if (!pud)
85007 return -ENOMEM;
85008 do {
85009 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
85010 index bd2bea9..6b3c95e 100644
85011 --- a/lib/is_single_threaded.c
85012 +++ b/lib/is_single_threaded.c
85013 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
85014 struct task_struct *p, *t;
85015 bool ret;
85016
85017 + if (!mm)
85018 + return true;
85019 +
85020 if (atomic_read(&task->signal->live) != 1)
85021 return false;
85022
85023 diff --git a/lib/kobject.c b/lib/kobject.c
85024 index 4a1f33d..2f3ca75 100644
85025 --- a/lib/kobject.c
85026 +++ b/lib/kobject.c
85027 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
85028
85029
85030 static DEFINE_SPINLOCK(kobj_ns_type_lock);
85031 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
85032 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
85033
85034 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85035 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85036 {
85037 enum kobj_ns_type type = ops->type;
85038 int error;
85039 diff --git a/lib/list_debug.c b/lib/list_debug.c
85040 index c24c2f7..06e070b 100644
85041 --- a/lib/list_debug.c
85042 +++ b/lib/list_debug.c
85043 @@ -11,7 +11,9 @@
85044 #include <linux/bug.h>
85045 #include <linux/kernel.h>
85046 #include <linux/rculist.h>
85047 +#include <linux/mm.h>
85048
85049 +#ifdef CONFIG_DEBUG_LIST
85050 /*
85051 * Insert a new entry between two known consecutive entries.
85052 *
85053 @@ -19,21 +21,32 @@
85054 * the prev/next entries already!
85055 */
85056
85057 -void __list_add(struct list_head *new,
85058 - struct list_head *prev,
85059 - struct list_head *next)
85060 +static bool __list_add_debug(struct list_head *new,
85061 + struct list_head *prev,
85062 + struct list_head *next)
85063 {
85064 - WARN(next->prev != prev,
85065 + if (WARN(next->prev != prev,
85066 "list_add corruption. next->prev should be "
85067 "prev (%p), but was %p. (next=%p).\n",
85068 - prev, next->prev, next);
85069 - WARN(prev->next != next,
85070 + prev, next->prev, next) ||
85071 + WARN(prev->next != next,
85072 "list_add corruption. prev->next should be "
85073 "next (%p), but was %p. (prev=%p).\n",
85074 - next, prev->next, prev);
85075 - WARN(new == prev || new == next,
85076 - "list_add double add: new=%p, prev=%p, next=%p.\n",
85077 - new, prev, next);
85078 + next, prev->next, prev) ||
85079 + WARN(new == prev || new == next,
85080 + "list_add double add: new=%p, prev=%p, next=%p.\n",
85081 + new, prev, next))
85082 + return false;
85083 + return true;
85084 +}
85085 +
85086 +void __list_add(struct list_head *new,
85087 + struct list_head *prev,
85088 + struct list_head *next)
85089 +{
85090 + if (!__list_add_debug(new, prev, next))
85091 + return;
85092 +
85093 next->prev = new;
85094 new->next = next;
85095 new->prev = prev;
85096 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
85097 }
85098 EXPORT_SYMBOL(__list_add);
85099
85100 -void __list_del_entry(struct list_head *entry)
85101 +static bool __list_del_entry_debug(struct list_head *entry)
85102 {
85103 struct list_head *prev, *next;
85104
85105 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
85106 WARN(next->prev != entry,
85107 "list_del corruption. next->prev should be %p, "
85108 "but was %p\n", entry, next->prev))
85109 + return false;
85110 + return true;
85111 +}
85112 +
85113 +void __list_del_entry(struct list_head *entry)
85114 +{
85115 + if (!__list_del_entry_debug(entry))
85116 return;
85117
85118 - __list_del(prev, next);
85119 + __list_del(entry->prev, entry->next);
85120 }
85121 EXPORT_SYMBOL(__list_del_entry);
85122
85123 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
85124 void __list_add_rcu(struct list_head *new,
85125 struct list_head *prev, struct list_head *next)
85126 {
85127 - WARN(next->prev != prev,
85128 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
85129 - prev, next->prev, next);
85130 - WARN(prev->next != next,
85131 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
85132 - next, prev->next, prev);
85133 + if (!__list_add_debug(new, prev, next))
85134 + return;
85135 +
85136 new->next = next;
85137 new->prev = prev;
85138 rcu_assign_pointer(list_next_rcu(prev), new);
85139 next->prev = new;
85140 }
85141 EXPORT_SYMBOL(__list_add_rcu);
85142 +#endif
85143 +
85144 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
85145 +{
85146 +#ifdef CONFIG_DEBUG_LIST
85147 + if (!__list_add_debug(new, prev, next))
85148 + return;
85149 +#endif
85150 +
85151 + pax_open_kernel();
85152 + next->prev = new;
85153 + new->next = next;
85154 + new->prev = prev;
85155 + prev->next = new;
85156 + pax_close_kernel();
85157 +}
85158 +EXPORT_SYMBOL(__pax_list_add);
85159 +
85160 +void pax_list_del(struct list_head *entry)
85161 +{
85162 +#ifdef CONFIG_DEBUG_LIST
85163 + if (!__list_del_entry_debug(entry))
85164 + return;
85165 +#endif
85166 +
85167 + pax_open_kernel();
85168 + __list_del(entry->prev, entry->next);
85169 + entry->next = LIST_POISON1;
85170 + entry->prev = LIST_POISON2;
85171 + pax_close_kernel();
85172 +}
85173 +EXPORT_SYMBOL(pax_list_del);
85174 +
85175 +void pax_list_del_init(struct list_head *entry)
85176 +{
85177 + pax_open_kernel();
85178 + __list_del(entry->prev, entry->next);
85179 + INIT_LIST_HEAD(entry);
85180 + pax_close_kernel();
85181 +}
85182 +EXPORT_SYMBOL(pax_list_del_init);
85183 +
85184 +void __pax_list_add_rcu(struct list_head *new,
85185 + struct list_head *prev, struct list_head *next)
85186 +{
85187 +#ifdef CONFIG_DEBUG_LIST
85188 + if (!__list_add_debug(new, prev, next))
85189 + return;
85190 +#endif
85191 +
85192 + pax_open_kernel();
85193 + new->next = next;
85194 + new->prev = prev;
85195 + rcu_assign_pointer(list_next_rcu(prev), new);
85196 + next->prev = new;
85197 + pax_close_kernel();
85198 +}
85199 +EXPORT_SYMBOL(__pax_list_add_rcu);
85200 +
85201 +void pax_list_del_rcu(struct list_head *entry)
85202 +{
85203 +#ifdef CONFIG_DEBUG_LIST
85204 + if (!__list_del_entry_debug(entry))
85205 + return;
85206 +#endif
85207 +
85208 + pax_open_kernel();
85209 + __list_del(entry->prev, entry->next);
85210 + entry->next = LIST_POISON1;
85211 + entry->prev = LIST_POISON2;
85212 + pax_close_kernel();
85213 +}
85214 +EXPORT_SYMBOL(pax_list_del_rcu);
85215 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
85216 index 7deeb62..144eb47 100644
85217 --- a/lib/percpu-refcount.c
85218 +++ b/lib/percpu-refcount.c
85219 @@ -29,7 +29,7 @@
85220 * can't hit 0 before we've added up all the percpu refs.
85221 */
85222
85223 -#define PCPU_COUNT_BIAS (1U << 31)
85224 +#define PCPU_COUNT_BIAS (1U << 30)
85225
85226 /**
85227 * percpu_ref_init - initialize a percpu refcount
85228 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
85229 index e796429..6e38f9f 100644
85230 --- a/lib/radix-tree.c
85231 +++ b/lib/radix-tree.c
85232 @@ -92,7 +92,7 @@ struct radix_tree_preload {
85233 int nr;
85234 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
85235 };
85236 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
85237 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
85238
85239 static inline void *ptr_to_indirect(void *ptr)
85240 {
85241 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
85242 index bb2b201..46abaf9 100644
85243 --- a/lib/strncpy_from_user.c
85244 +++ b/lib/strncpy_from_user.c
85245 @@ -21,7 +21,7 @@
85246 */
85247 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
85248 {
85249 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85250 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85251 long res = 0;
85252
85253 /*
85254 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
85255 index a28df52..3d55877 100644
85256 --- a/lib/strnlen_user.c
85257 +++ b/lib/strnlen_user.c
85258 @@ -26,7 +26,7 @@
85259 */
85260 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
85261 {
85262 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85263 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85264 long align, res = 0;
85265 unsigned long c;
85266
85267 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
85268 index d23762e..e21eab2 100644
85269 --- a/lib/swiotlb.c
85270 +++ b/lib/swiotlb.c
85271 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
85272
85273 void
85274 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
85275 - dma_addr_t dev_addr)
85276 + dma_addr_t dev_addr, struct dma_attrs *attrs)
85277 {
85278 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
85279
85280 diff --git a/lib/usercopy.c b/lib/usercopy.c
85281 index 4f5b1dd..7cab418 100644
85282 --- a/lib/usercopy.c
85283 +++ b/lib/usercopy.c
85284 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
85285 WARN(1, "Buffer overflow detected!\n");
85286 }
85287 EXPORT_SYMBOL(copy_from_user_overflow);
85288 +
85289 +void copy_to_user_overflow(void)
85290 +{
85291 + WARN(1, "Buffer overflow detected!\n");
85292 +}
85293 +EXPORT_SYMBOL(copy_to_user_overflow);
85294 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
85295 index 739a363..aa668d7 100644
85296 --- a/lib/vsprintf.c
85297 +++ b/lib/vsprintf.c
85298 @@ -16,6 +16,9 @@
85299 * - scnprintf and vscnprintf
85300 */
85301
85302 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85303 +#define __INCLUDED_BY_HIDESYM 1
85304 +#endif
85305 #include <stdarg.h>
85306 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
85307 #include <linux/types.h>
85308 @@ -1078,7 +1081,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
85309 return number(buf, end, *(const netdev_features_t *)addr, spec);
85310 }
85311
85312 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85313 +int kptr_restrict __read_mostly = 2;
85314 +#else
85315 int kptr_restrict __read_mostly;
85316 +#endif
85317
85318 /*
85319 * Show a '%p' thing. A kernel extension is that the '%p' is followed
85320 @@ -1091,6 +1098,7 @@ int kptr_restrict __read_mostly;
85321 * - 'f' For simple symbolic function names without offset
85322 * - 'S' For symbolic direct pointers with offset
85323 * - 's' For symbolic direct pointers without offset
85324 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
85325 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
85326 * - 'B' For backtraced symbolic direct pointers with offset
85327 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
85328 @@ -1155,12 +1163,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85329
85330 if (!ptr && *fmt != 'K') {
85331 /*
85332 - * Print (null) with the same width as a pointer so it makes
85333 + * Print (nil) with the same width as a pointer so it makes
85334 * tabular output look nice.
85335 */
85336 if (spec.field_width == -1)
85337 spec.field_width = default_width;
85338 - return string(buf, end, "(null)", spec);
85339 + return string(buf, end, "(nil)", spec);
85340 }
85341
85342 switch (*fmt) {
85343 @@ -1170,6 +1178,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85344 /* Fallthrough */
85345 case 'S':
85346 case 's':
85347 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85348 + break;
85349 +#else
85350 + return symbol_string(buf, end, ptr, spec, fmt);
85351 +#endif
85352 + case 'A':
85353 case 'B':
85354 return symbol_string(buf, end, ptr, spec, fmt);
85355 case 'R':
85356 @@ -1225,6 +1239,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85357 va_end(va);
85358 return buf;
85359 }
85360 + case 'P':
85361 + break;
85362 case 'K':
85363 /*
85364 * %pK cannot be used in IRQ context because its test
85365 @@ -1254,6 +1270,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85366 return number(buf, end,
85367 (unsigned long long) *((phys_addr_t *)ptr), spec);
85368 }
85369 +
85370 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85371 + /* 'P' = approved pointers to copy to userland,
85372 + as in the /proc/kallsyms case, as we make it display nothing
85373 + for non-root users, and the real contents for root users
85374 + Also ignore 'K' pointers, since we force their NULLing for non-root users
85375 + above
85376 + */
85377 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
85378 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
85379 + dump_stack();
85380 + ptr = NULL;
85381 + }
85382 +#endif
85383 +
85384 spec.flags |= SMALL;
85385 if (spec.field_width == -1) {
85386 spec.field_width = default_width;
85387 @@ -1977,11 +2008,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85388 typeof(type) value; \
85389 if (sizeof(type) == 8) { \
85390 args = PTR_ALIGN(args, sizeof(u32)); \
85391 - *(u32 *)&value = *(u32 *)args; \
85392 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
85393 + *(u32 *)&value = *(const u32 *)args; \
85394 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
85395 } else { \
85396 args = PTR_ALIGN(args, sizeof(type)); \
85397 - value = *(typeof(type) *)args; \
85398 + value = *(const typeof(type) *)args; \
85399 } \
85400 args += sizeof(type); \
85401 value; \
85402 @@ -2044,7 +2075,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85403 case FORMAT_TYPE_STR: {
85404 const char *str_arg = args;
85405 args += strlen(str_arg) + 1;
85406 - str = string(str, end, (char *)str_arg, spec);
85407 + str = string(str, end, str_arg, spec);
85408 break;
85409 }
85410
85411 diff --git a/localversion-grsec b/localversion-grsec
85412 new file mode 100644
85413 index 0000000..7cd6065
85414 --- /dev/null
85415 +++ b/localversion-grsec
85416 @@ -0,0 +1 @@
85417 +-grsec
85418 diff --git a/mm/Kconfig b/mm/Kconfig
85419 index 8028dcc..9a2dbe7 100644
85420 --- a/mm/Kconfig
85421 +++ b/mm/Kconfig
85422 @@ -317,10 +317,10 @@ config KSM
85423 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
85424
85425 config DEFAULT_MMAP_MIN_ADDR
85426 - int "Low address space to protect from user allocation"
85427 + int "Low address space to protect from user allocation"
85428 depends on MMU
85429 - default 4096
85430 - help
85431 + default 65536
85432 + help
85433 This is the portion of low virtual memory which should be protected
85434 from userspace allocation. Keeping a user from writing to low pages
85435 can help reduce the impact of kernel NULL pointer bugs.
85436 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
85437
85438 config HWPOISON_INJECT
85439 tristate "HWPoison pages injector"
85440 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
85441 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
85442 select PROC_PAGE_MONITOR
85443
85444 config NOMMU_INITIAL_TRIM_EXCESS
85445 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
85446 index e04454c..ca5be3e 100644
85447 --- a/mm/backing-dev.c
85448 +++ b/mm/backing-dev.c
85449 @@ -12,7 +12,7 @@
85450 #include <linux/device.h>
85451 #include <trace/events/writeback.h>
85452
85453 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
85454 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
85455
85456 struct backing_dev_info default_backing_dev_info = {
85457 .name = "default",
85458 @@ -522,7 +522,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
85459 return err;
85460
85461 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
85462 - atomic_long_inc_return(&bdi_seq));
85463 + atomic_long_inc_return_unchecked(&bdi_seq));
85464 if (err) {
85465 bdi_destroy(bdi);
85466 return err;
85467 diff --git a/mm/filemap.c b/mm/filemap.c
85468 index 4b51ac1..5aa90ff 100644
85469 --- a/mm/filemap.c
85470 +++ b/mm/filemap.c
85471 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
85472 struct address_space *mapping = file->f_mapping;
85473
85474 if (!mapping->a_ops->readpage)
85475 - return -ENOEXEC;
85476 + return -ENODEV;
85477 file_accessed(file);
85478 vma->vm_ops = &generic_file_vm_ops;
85479 return 0;
85480 @@ -1948,7 +1948,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
85481
85482 while (bytes) {
85483 char __user *buf = iov->iov_base + base;
85484 - int copy = min(bytes, iov->iov_len - base);
85485 + size_t copy = min(bytes, iov->iov_len - base);
85486
85487 base = 0;
85488 left = __copy_from_user_inatomic(vaddr, buf, copy);
85489 @@ -1977,7 +1977,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
85490 BUG_ON(!in_atomic());
85491 kaddr = kmap_atomic(page);
85492 if (likely(i->nr_segs == 1)) {
85493 - int left;
85494 + size_t left;
85495 char __user *buf = i->iov->iov_base + i->iov_offset;
85496 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
85497 copied = bytes - left;
85498 @@ -2005,7 +2005,7 @@ size_t iov_iter_copy_from_user(struct page *page,
85499
85500 kaddr = kmap(page);
85501 if (likely(i->nr_segs == 1)) {
85502 - int left;
85503 + size_t left;
85504 char __user *buf = i->iov->iov_base + i->iov_offset;
85505 left = __copy_from_user(kaddr + offset, buf, bytes);
85506 copied = bytes - left;
85507 @@ -2035,7 +2035,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
85508 * zero-length segments (without overruning the iovec).
85509 */
85510 while (bytes || unlikely(i->count && !iov->iov_len)) {
85511 - int copy;
85512 + size_t copy;
85513
85514 copy = min(bytes, iov->iov_len - base);
85515 BUG_ON(!i->count || i->count < copy);
85516 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
85517 *pos = i_size_read(inode);
85518
85519 if (limit != RLIM_INFINITY) {
85520 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
85521 if (*pos >= limit) {
85522 send_sig(SIGXFSZ, current, 0);
85523 return -EFBIG;
85524 diff --git a/mm/fremap.c b/mm/fremap.c
85525 index 5bff081..d8189a9 100644
85526 --- a/mm/fremap.c
85527 +++ b/mm/fremap.c
85528 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
85529 retry:
85530 vma = find_vma(mm, start);
85531
85532 +#ifdef CONFIG_PAX_SEGMEXEC
85533 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
85534 + goto out;
85535 +#endif
85536 +
85537 /*
85538 * Make sure the vma is shared, that it supports prefaulting,
85539 * and that the remapped range is valid and fully within
85540 diff --git a/mm/highmem.c b/mm/highmem.c
85541 index b32b70c..e512eb0 100644
85542 --- a/mm/highmem.c
85543 +++ b/mm/highmem.c
85544 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
85545 * So no dangers, even with speculative execution.
85546 */
85547 page = pte_page(pkmap_page_table[i]);
85548 + pax_open_kernel();
85549 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
85550 -
85551 + pax_close_kernel();
85552 set_page_address(page, NULL);
85553 need_flush = 1;
85554 }
85555 @@ -198,9 +199,11 @@ start:
85556 }
85557 }
85558 vaddr = PKMAP_ADDR(last_pkmap_nr);
85559 +
85560 + pax_open_kernel();
85561 set_pte_at(&init_mm, vaddr,
85562 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
85563 -
85564 + pax_close_kernel();
85565 pkmap_count[last_pkmap_nr] = 1;
85566 set_page_address(page, (void *)vaddr);
85567
85568 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
85569 index b60f330..ee7de7e 100644
85570 --- a/mm/hugetlb.c
85571 +++ b/mm/hugetlb.c
85572 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
85573 struct hstate *h = &default_hstate;
85574 unsigned long tmp;
85575 int ret;
85576 + ctl_table_no_const hugetlb_table;
85577
85578 tmp = h->max_huge_pages;
85579
85580 if (write && h->order >= MAX_ORDER)
85581 return -EINVAL;
85582
85583 - table->data = &tmp;
85584 - table->maxlen = sizeof(unsigned long);
85585 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
85586 + hugetlb_table = *table;
85587 + hugetlb_table.data = &tmp;
85588 + hugetlb_table.maxlen = sizeof(unsigned long);
85589 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
85590 if (ret)
85591 goto out;
85592
85593 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
85594 struct hstate *h = &default_hstate;
85595 unsigned long tmp;
85596 int ret;
85597 + ctl_table_no_const hugetlb_table;
85598
85599 tmp = h->nr_overcommit_huge_pages;
85600
85601 if (write && h->order >= MAX_ORDER)
85602 return -EINVAL;
85603
85604 - table->data = &tmp;
85605 - table->maxlen = sizeof(unsigned long);
85606 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
85607 + hugetlb_table = *table;
85608 + hugetlb_table.data = &tmp;
85609 + hugetlb_table.maxlen = sizeof(unsigned long);
85610 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
85611 if (ret)
85612 goto out;
85613
85614 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
85615 return 1;
85616 }
85617
85618 +#ifdef CONFIG_PAX_SEGMEXEC
85619 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
85620 +{
85621 + struct mm_struct *mm = vma->vm_mm;
85622 + struct vm_area_struct *vma_m;
85623 + unsigned long address_m;
85624 + pte_t *ptep_m;
85625 +
85626 + vma_m = pax_find_mirror_vma(vma);
85627 + if (!vma_m)
85628 + return;
85629 +
85630 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
85631 + address_m = address + SEGMEXEC_TASK_SIZE;
85632 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
85633 + get_page(page_m);
85634 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
85635 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
85636 +}
85637 +#endif
85638 +
85639 /*
85640 * Hugetlb_cow() should be called with page lock of the original hugepage held.
85641 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
85642 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
85643 make_huge_pte(vma, new_page, 1));
85644 page_remove_rmap(old_page);
85645 hugepage_add_new_anon_rmap(new_page, vma, address);
85646 +
85647 +#ifdef CONFIG_PAX_SEGMEXEC
85648 + pax_mirror_huge_pte(vma, address, new_page);
85649 +#endif
85650 +
85651 /* Make the old page be freed below */
85652 new_page = old_page;
85653 }
85654 @@ -2821,6 +2851,10 @@ retry:
85655 && (vma->vm_flags & VM_SHARED)));
85656 set_huge_pte_at(mm, address, ptep, new_pte);
85657
85658 +#ifdef CONFIG_PAX_SEGMEXEC
85659 + pax_mirror_huge_pte(vma, address, page);
85660 +#endif
85661 +
85662 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
85663 /* Optimization, do the COW without a second fault */
85664 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
85665 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
85666 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
85667 struct hstate *h = hstate_vma(vma);
85668
85669 +#ifdef CONFIG_PAX_SEGMEXEC
85670 + struct vm_area_struct *vma_m;
85671 +#endif
85672 +
85673 address &= huge_page_mask(h);
85674
85675 ptep = huge_pte_offset(mm, address);
85676 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
85677 VM_FAULT_SET_HINDEX(hstate_index(h));
85678 }
85679
85680 +#ifdef CONFIG_PAX_SEGMEXEC
85681 + vma_m = pax_find_mirror_vma(vma);
85682 + if (vma_m) {
85683 + unsigned long address_m;
85684 +
85685 + if (vma->vm_start > vma_m->vm_start) {
85686 + address_m = address;
85687 + address -= SEGMEXEC_TASK_SIZE;
85688 + vma = vma_m;
85689 + h = hstate_vma(vma);
85690 + } else
85691 + address_m = address + SEGMEXEC_TASK_SIZE;
85692 +
85693 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
85694 + return VM_FAULT_OOM;
85695 + address_m &= HPAGE_MASK;
85696 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
85697 + }
85698 +#endif
85699 +
85700 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
85701 if (!ptep)
85702 return VM_FAULT_OOM;
85703 diff --git a/mm/internal.h b/mm/internal.h
85704 index 4390ac6..fc60373c 100644
85705 --- a/mm/internal.h
85706 +++ b/mm/internal.h
85707 @@ -95,6 +95,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
85708 * in mm/page_alloc.c
85709 */
85710 extern void __free_pages_bootmem(struct page *page, unsigned int order);
85711 +extern void free_compound_page(struct page *page);
85712 extern void prep_compound_page(struct page *page, unsigned long order);
85713 #ifdef CONFIG_MEMORY_FAILURE
85714 extern bool is_free_buddy_page(struct page *page);
85715 @@ -350,7 +351,7 @@ extern u32 hwpoison_filter_enable;
85716
85717 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
85718 unsigned long, unsigned long,
85719 - unsigned long, unsigned long);
85720 + unsigned long, unsigned long) __intentional_overflow(-1);
85721
85722 extern void set_pageblock_order(void);
85723 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
85724 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
85725 index c8d7f31..2dbeffd 100644
85726 --- a/mm/kmemleak.c
85727 +++ b/mm/kmemleak.c
85728 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
85729
85730 for (i = 0; i < object->trace_len; i++) {
85731 void *ptr = (void *)object->trace[i];
85732 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
85733 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
85734 }
85735 }
85736
85737 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
85738 return -ENOMEM;
85739 }
85740
85741 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
85742 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
85743 &kmemleak_fops);
85744 if (!dentry)
85745 pr_warning("Failed to create the debugfs kmemleak file\n");
85746 diff --git a/mm/maccess.c b/mm/maccess.c
85747 index d53adf9..03a24bf 100644
85748 --- a/mm/maccess.c
85749 +++ b/mm/maccess.c
85750 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
85751 set_fs(KERNEL_DS);
85752 pagefault_disable();
85753 ret = __copy_from_user_inatomic(dst,
85754 - (__force const void __user *)src, size);
85755 + (const void __force_user *)src, size);
85756 pagefault_enable();
85757 set_fs(old_fs);
85758
85759 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
85760
85761 set_fs(KERNEL_DS);
85762 pagefault_disable();
85763 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
85764 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
85765 pagefault_enable();
85766 set_fs(old_fs);
85767
85768 diff --git a/mm/madvise.c b/mm/madvise.c
85769 index 7055883..aafb1ed 100644
85770 --- a/mm/madvise.c
85771 +++ b/mm/madvise.c
85772 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
85773 pgoff_t pgoff;
85774 unsigned long new_flags = vma->vm_flags;
85775
85776 +#ifdef CONFIG_PAX_SEGMEXEC
85777 + struct vm_area_struct *vma_m;
85778 +#endif
85779 +
85780 switch (behavior) {
85781 case MADV_NORMAL:
85782 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
85783 @@ -126,6 +130,13 @@ success:
85784 /*
85785 * vm_flags is protected by the mmap_sem held in write mode.
85786 */
85787 +
85788 +#ifdef CONFIG_PAX_SEGMEXEC
85789 + vma_m = pax_find_mirror_vma(vma);
85790 + if (vma_m)
85791 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
85792 +#endif
85793 +
85794 vma->vm_flags = new_flags;
85795
85796 out:
85797 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
85798 struct vm_area_struct ** prev,
85799 unsigned long start, unsigned long end)
85800 {
85801 +
85802 +#ifdef CONFIG_PAX_SEGMEXEC
85803 + struct vm_area_struct *vma_m;
85804 +#endif
85805 +
85806 *prev = vma;
85807 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
85808 return -EINVAL;
85809 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
85810 zap_page_range(vma, start, end - start, &details);
85811 } else
85812 zap_page_range(vma, start, end - start, NULL);
85813 +
85814 +#ifdef CONFIG_PAX_SEGMEXEC
85815 + vma_m = pax_find_mirror_vma(vma);
85816 + if (vma_m) {
85817 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
85818 + struct zap_details details = {
85819 + .nonlinear_vma = vma_m,
85820 + .last_index = ULONG_MAX,
85821 + };
85822 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
85823 + } else
85824 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
85825 + }
85826 +#endif
85827 +
85828 return 0;
85829 }
85830
85831 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
85832 if (end < start)
85833 return error;
85834
85835 +#ifdef CONFIG_PAX_SEGMEXEC
85836 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
85837 + if (end > SEGMEXEC_TASK_SIZE)
85838 + return error;
85839 + } else
85840 +#endif
85841 +
85842 + if (end > TASK_SIZE)
85843 + return error;
85844 +
85845 error = 0;
85846 if (end == start)
85847 return error;
85848 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
85849 index 2c13aa7..64cbc3f 100644
85850 --- a/mm/memory-failure.c
85851 +++ b/mm/memory-failure.c
85852 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
85853
85854 int sysctl_memory_failure_recovery __read_mostly = 1;
85855
85856 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
85857 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
85858
85859 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
85860
85861 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
85862 pfn, t->comm, t->pid);
85863 si.si_signo = SIGBUS;
85864 si.si_errno = 0;
85865 - si.si_addr = (void *)addr;
85866 + si.si_addr = (void __user *)addr;
85867 #ifdef __ARCH_SI_TRAPNO
85868 si.si_trapno = trapno;
85869 #endif
85870 @@ -760,7 +760,7 @@ static struct page_state {
85871 unsigned long res;
85872 char *msg;
85873 int (*action)(struct page *p, unsigned long pfn);
85874 -} error_states[] = {
85875 +} __do_const error_states[] = {
85876 { reserved, reserved, "reserved kernel", me_kernel },
85877 /*
85878 * free pages are specially detected outside this table:
85879 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
85880 nr_pages = 1 << compound_order(hpage);
85881 else /* normal page or thp */
85882 nr_pages = 1;
85883 - atomic_long_add(nr_pages, &num_poisoned_pages);
85884 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
85885
85886 /*
85887 * We need/can do nothing about count=0 pages.
85888 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
85889 if (!PageHWPoison(hpage)
85890 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
85891 || (p != hpage && TestSetPageHWPoison(hpage))) {
85892 - atomic_long_sub(nr_pages, &num_poisoned_pages);
85893 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
85894 return 0;
85895 }
85896 set_page_hwpoison_huge_page(hpage);
85897 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
85898 }
85899 if (hwpoison_filter(p)) {
85900 if (TestClearPageHWPoison(p))
85901 - atomic_long_sub(nr_pages, &num_poisoned_pages);
85902 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
85903 unlock_page(hpage);
85904 put_page(hpage);
85905 return 0;
85906 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
85907 return 0;
85908 }
85909 if (TestClearPageHWPoison(p))
85910 - atomic_long_sub(nr_pages, &num_poisoned_pages);
85911 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
85912 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
85913 return 0;
85914 }
85915 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
85916 */
85917 if (TestClearPageHWPoison(page)) {
85918 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
85919 - atomic_long_sub(nr_pages, &num_poisoned_pages);
85920 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
85921 freeit = 1;
85922 if (PageHuge(page))
85923 clear_page_hwpoison_huge_page(page);
85924 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
85925 } else {
85926 set_page_hwpoison_huge_page(hpage);
85927 dequeue_hwpoisoned_huge_page(hpage);
85928 - atomic_long_add(1 << compound_trans_order(hpage),
85929 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
85930 &num_poisoned_pages);
85931 }
85932 return ret;
85933 @@ -1551,11 +1551,11 @@ int soft_offline_page(struct page *page, int flags)
85934 if (PageHuge(page)) {
85935 set_page_hwpoison_huge_page(hpage);
85936 dequeue_hwpoisoned_huge_page(hpage);
85937 - atomic_long_add(1 << compound_trans_order(hpage),
85938 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
85939 &num_poisoned_pages);
85940 } else {
85941 SetPageHWPoison(page);
85942 - atomic_long_inc(&num_poisoned_pages);
85943 + atomic_long_inc_unchecked(&num_poisoned_pages);
85944 }
85945 }
85946 unset_migratetype_isolate(page, MIGRATE_MOVABLE);
85947 @@ -1595,7 +1595,7 @@ static int __soft_offline_page(struct page *page, int flags)
85948 put_page(page);
85949 pr_info("soft_offline: %#lx: invalidated\n", pfn);
85950 SetPageHWPoison(page);
85951 - atomic_long_inc(&num_poisoned_pages);
85952 + atomic_long_inc_unchecked(&num_poisoned_pages);
85953 return 0;
85954 }
85955
85956 @@ -1640,7 +1640,7 @@ static int __soft_offline_page(struct page *page, int flags)
85957 if (!is_free_buddy_page(page))
85958 pr_info("soft offline: %#lx: page leaked\n",
85959 pfn);
85960 - atomic_long_inc(&num_poisoned_pages);
85961 + atomic_long_inc_unchecked(&num_poisoned_pages);
85962 }
85963 } else {
85964 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
85965 diff --git a/mm/memory.c b/mm/memory.c
85966 index af84bc0..2ed0816 100644
85967 --- a/mm/memory.c
85968 +++ b/mm/memory.c
85969 @@ -426,6 +426,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
85970 free_pte_range(tlb, pmd, addr);
85971 } while (pmd++, addr = next, addr != end);
85972
85973 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
85974 start &= PUD_MASK;
85975 if (start < floor)
85976 return;
85977 @@ -440,6 +441,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
85978 pmd = pmd_offset(pud, start);
85979 pud_clear(pud);
85980 pmd_free_tlb(tlb, pmd, start);
85981 +#endif
85982 +
85983 }
85984
85985 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
85986 @@ -459,6 +462,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
85987 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
85988 } while (pud++, addr = next, addr != end);
85989
85990 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
85991 start &= PGDIR_MASK;
85992 if (start < floor)
85993 return;
85994 @@ -473,6 +477,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
85995 pud = pud_offset(pgd, start);
85996 pgd_clear(pgd);
85997 pud_free_tlb(tlb, pud, start);
85998 +#endif
85999 +
86000 }
86001
86002 /*
86003 @@ -1645,12 +1651,6 @@ no_page_table:
86004 return page;
86005 }
86006
86007 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
86008 -{
86009 - return stack_guard_page_start(vma, addr) ||
86010 - stack_guard_page_end(vma, addr+PAGE_SIZE);
86011 -}
86012 -
86013 /**
86014 * __get_user_pages() - pin user pages in memory
86015 * @tsk: task_struct of target task
86016 @@ -1737,10 +1737,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86017
86018 i = 0;
86019
86020 - do {
86021 + while (nr_pages) {
86022 struct vm_area_struct *vma;
86023
86024 - vma = find_extend_vma(mm, start);
86025 + vma = find_vma(mm, start);
86026 if (!vma && in_gate_area(mm, start)) {
86027 unsigned long pg = start & PAGE_MASK;
86028 pgd_t *pgd;
86029 @@ -1789,7 +1789,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86030 goto next_page;
86031 }
86032
86033 - if (!vma ||
86034 + if (!vma || start < vma->vm_start ||
86035 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
86036 !(vm_flags & vma->vm_flags))
86037 return i ? : -EFAULT;
86038 @@ -1818,11 +1818,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86039 int ret;
86040 unsigned int fault_flags = 0;
86041
86042 - /* For mlock, just skip the stack guard page. */
86043 - if (foll_flags & FOLL_MLOCK) {
86044 - if (stack_guard_page(vma, start))
86045 - goto next_page;
86046 - }
86047 if (foll_flags & FOLL_WRITE)
86048 fault_flags |= FAULT_FLAG_WRITE;
86049 if (nonblocking)
86050 @@ -1902,7 +1897,7 @@ next_page:
86051 start += page_increm * PAGE_SIZE;
86052 nr_pages -= page_increm;
86053 } while (nr_pages && start < vma->vm_end);
86054 - } while (nr_pages);
86055 + }
86056 return i;
86057 }
86058 EXPORT_SYMBOL(__get_user_pages);
86059 @@ -2109,6 +2104,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
86060 page_add_file_rmap(page);
86061 set_pte_at(mm, addr, pte, mk_pte(page, prot));
86062
86063 +#ifdef CONFIG_PAX_SEGMEXEC
86064 + pax_mirror_file_pte(vma, addr, page, ptl);
86065 +#endif
86066 +
86067 retval = 0;
86068 pte_unmap_unlock(pte, ptl);
86069 return retval;
86070 @@ -2153,9 +2152,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
86071 if (!page_count(page))
86072 return -EINVAL;
86073 if (!(vma->vm_flags & VM_MIXEDMAP)) {
86074 +
86075 +#ifdef CONFIG_PAX_SEGMEXEC
86076 + struct vm_area_struct *vma_m;
86077 +#endif
86078 +
86079 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
86080 BUG_ON(vma->vm_flags & VM_PFNMAP);
86081 vma->vm_flags |= VM_MIXEDMAP;
86082 +
86083 +#ifdef CONFIG_PAX_SEGMEXEC
86084 + vma_m = pax_find_mirror_vma(vma);
86085 + if (vma_m)
86086 + vma_m->vm_flags |= VM_MIXEDMAP;
86087 +#endif
86088 +
86089 }
86090 return insert_page(vma, addr, page, vma->vm_page_prot);
86091 }
86092 @@ -2238,6 +2249,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
86093 unsigned long pfn)
86094 {
86095 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
86096 + BUG_ON(vma->vm_mirror);
86097
86098 if (addr < vma->vm_start || addr >= vma->vm_end)
86099 return -EFAULT;
86100 @@ -2485,7 +2497,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
86101
86102 BUG_ON(pud_huge(*pud));
86103
86104 - pmd = pmd_alloc(mm, pud, addr);
86105 + pmd = (mm == &init_mm) ?
86106 + pmd_alloc_kernel(mm, pud, addr) :
86107 + pmd_alloc(mm, pud, addr);
86108 if (!pmd)
86109 return -ENOMEM;
86110 do {
86111 @@ -2505,7 +2519,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
86112 unsigned long next;
86113 int err;
86114
86115 - pud = pud_alloc(mm, pgd, addr);
86116 + pud = (mm == &init_mm) ?
86117 + pud_alloc_kernel(mm, pgd, addr) :
86118 + pud_alloc(mm, pgd, addr);
86119 if (!pud)
86120 return -ENOMEM;
86121 do {
86122 @@ -2593,6 +2609,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
86123 copy_user_highpage(dst, src, va, vma);
86124 }
86125
86126 +#ifdef CONFIG_PAX_SEGMEXEC
86127 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
86128 +{
86129 + struct mm_struct *mm = vma->vm_mm;
86130 + spinlock_t *ptl;
86131 + pte_t *pte, entry;
86132 +
86133 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
86134 + entry = *pte;
86135 + if (!pte_present(entry)) {
86136 + if (!pte_none(entry)) {
86137 + BUG_ON(pte_file(entry));
86138 + free_swap_and_cache(pte_to_swp_entry(entry));
86139 + pte_clear_not_present_full(mm, address, pte, 0);
86140 + }
86141 + } else {
86142 + struct page *page;
86143 +
86144 + flush_cache_page(vma, address, pte_pfn(entry));
86145 + entry = ptep_clear_flush(vma, address, pte);
86146 + BUG_ON(pte_dirty(entry));
86147 + page = vm_normal_page(vma, address, entry);
86148 + if (page) {
86149 + update_hiwater_rss(mm);
86150 + if (PageAnon(page))
86151 + dec_mm_counter_fast(mm, MM_ANONPAGES);
86152 + else
86153 + dec_mm_counter_fast(mm, MM_FILEPAGES);
86154 + page_remove_rmap(page);
86155 + page_cache_release(page);
86156 + }
86157 + }
86158 + pte_unmap_unlock(pte, ptl);
86159 +}
86160 +
86161 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
86162 + *
86163 + * the ptl of the lower mapped page is held on entry and is not released on exit
86164 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
86165 + */
86166 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86167 +{
86168 + struct mm_struct *mm = vma->vm_mm;
86169 + unsigned long address_m;
86170 + spinlock_t *ptl_m;
86171 + struct vm_area_struct *vma_m;
86172 + pmd_t *pmd_m;
86173 + pte_t *pte_m, entry_m;
86174 +
86175 + BUG_ON(!page_m || !PageAnon(page_m));
86176 +
86177 + vma_m = pax_find_mirror_vma(vma);
86178 + if (!vma_m)
86179 + return;
86180 +
86181 + BUG_ON(!PageLocked(page_m));
86182 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86183 + address_m = address + SEGMEXEC_TASK_SIZE;
86184 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86185 + pte_m = pte_offset_map(pmd_m, address_m);
86186 + ptl_m = pte_lockptr(mm, pmd_m);
86187 + if (ptl != ptl_m) {
86188 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86189 + if (!pte_none(*pte_m))
86190 + goto out;
86191 + }
86192 +
86193 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86194 + page_cache_get(page_m);
86195 + page_add_anon_rmap(page_m, vma_m, address_m);
86196 + inc_mm_counter_fast(mm, MM_ANONPAGES);
86197 + set_pte_at(mm, address_m, pte_m, entry_m);
86198 + update_mmu_cache(vma_m, address_m, pte_m);
86199 +out:
86200 + if (ptl != ptl_m)
86201 + spin_unlock(ptl_m);
86202 + pte_unmap(pte_m);
86203 + unlock_page(page_m);
86204 +}
86205 +
86206 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86207 +{
86208 + struct mm_struct *mm = vma->vm_mm;
86209 + unsigned long address_m;
86210 + spinlock_t *ptl_m;
86211 + struct vm_area_struct *vma_m;
86212 + pmd_t *pmd_m;
86213 + pte_t *pte_m, entry_m;
86214 +
86215 + BUG_ON(!page_m || PageAnon(page_m));
86216 +
86217 + vma_m = pax_find_mirror_vma(vma);
86218 + if (!vma_m)
86219 + return;
86220 +
86221 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86222 + address_m = address + SEGMEXEC_TASK_SIZE;
86223 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86224 + pte_m = pte_offset_map(pmd_m, address_m);
86225 + ptl_m = pte_lockptr(mm, pmd_m);
86226 + if (ptl != ptl_m) {
86227 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86228 + if (!pte_none(*pte_m))
86229 + goto out;
86230 + }
86231 +
86232 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86233 + page_cache_get(page_m);
86234 + page_add_file_rmap(page_m);
86235 + inc_mm_counter_fast(mm, MM_FILEPAGES);
86236 + set_pte_at(mm, address_m, pte_m, entry_m);
86237 + update_mmu_cache(vma_m, address_m, pte_m);
86238 +out:
86239 + if (ptl != ptl_m)
86240 + spin_unlock(ptl_m);
86241 + pte_unmap(pte_m);
86242 +}
86243 +
86244 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
86245 +{
86246 + struct mm_struct *mm = vma->vm_mm;
86247 + unsigned long address_m;
86248 + spinlock_t *ptl_m;
86249 + struct vm_area_struct *vma_m;
86250 + pmd_t *pmd_m;
86251 + pte_t *pte_m, entry_m;
86252 +
86253 + vma_m = pax_find_mirror_vma(vma);
86254 + if (!vma_m)
86255 + return;
86256 +
86257 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86258 + address_m = address + SEGMEXEC_TASK_SIZE;
86259 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86260 + pte_m = pte_offset_map(pmd_m, address_m);
86261 + ptl_m = pte_lockptr(mm, pmd_m);
86262 + if (ptl != ptl_m) {
86263 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86264 + if (!pte_none(*pte_m))
86265 + goto out;
86266 + }
86267 +
86268 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
86269 + set_pte_at(mm, address_m, pte_m, entry_m);
86270 +out:
86271 + if (ptl != ptl_m)
86272 + spin_unlock(ptl_m);
86273 + pte_unmap(pte_m);
86274 +}
86275 +
86276 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
86277 +{
86278 + struct page *page_m;
86279 + pte_t entry;
86280 +
86281 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
86282 + goto out;
86283 +
86284 + entry = *pte;
86285 + page_m = vm_normal_page(vma, address, entry);
86286 + if (!page_m)
86287 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
86288 + else if (PageAnon(page_m)) {
86289 + if (pax_find_mirror_vma(vma)) {
86290 + pte_unmap_unlock(pte, ptl);
86291 + lock_page(page_m);
86292 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
86293 + if (pte_same(entry, *pte))
86294 + pax_mirror_anon_pte(vma, address, page_m, ptl);
86295 + else
86296 + unlock_page(page_m);
86297 + }
86298 + } else
86299 + pax_mirror_file_pte(vma, address, page_m, ptl);
86300 +
86301 +out:
86302 + pte_unmap_unlock(pte, ptl);
86303 +}
86304 +#endif
86305 +
86306 /*
86307 * This routine handles present pages, when users try to write
86308 * to a shared page. It is done by copying the page to a new address
86309 @@ -2809,6 +3005,12 @@ gotten:
86310 */
86311 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86312 if (likely(pte_same(*page_table, orig_pte))) {
86313 +
86314 +#ifdef CONFIG_PAX_SEGMEXEC
86315 + if (pax_find_mirror_vma(vma))
86316 + BUG_ON(!trylock_page(new_page));
86317 +#endif
86318 +
86319 if (old_page) {
86320 if (!PageAnon(old_page)) {
86321 dec_mm_counter_fast(mm, MM_FILEPAGES);
86322 @@ -2860,6 +3062,10 @@ gotten:
86323 page_remove_rmap(old_page);
86324 }
86325
86326 +#ifdef CONFIG_PAX_SEGMEXEC
86327 + pax_mirror_anon_pte(vma, address, new_page, ptl);
86328 +#endif
86329 +
86330 /* Free the old page.. */
86331 new_page = old_page;
86332 ret |= VM_FAULT_WRITE;
86333 @@ -3137,6 +3343,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86334 swap_free(entry);
86335 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
86336 try_to_free_swap(page);
86337 +
86338 +#ifdef CONFIG_PAX_SEGMEXEC
86339 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
86340 +#endif
86341 +
86342 unlock_page(page);
86343 if (page != swapcache) {
86344 /*
86345 @@ -3160,6 +3371,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86346
86347 /* No need to invalidate - it was non-present before */
86348 update_mmu_cache(vma, address, page_table);
86349 +
86350 +#ifdef CONFIG_PAX_SEGMEXEC
86351 + pax_mirror_anon_pte(vma, address, page, ptl);
86352 +#endif
86353 +
86354 unlock:
86355 pte_unmap_unlock(page_table, ptl);
86356 out:
86357 @@ -3179,40 +3395,6 @@ out_release:
86358 }
86359
86360 /*
86361 - * This is like a special single-page "expand_{down|up}wards()",
86362 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
86363 - * doesn't hit another vma.
86364 - */
86365 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
86366 -{
86367 - address &= PAGE_MASK;
86368 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
86369 - struct vm_area_struct *prev = vma->vm_prev;
86370 -
86371 - /*
86372 - * Is there a mapping abutting this one below?
86373 - *
86374 - * That's only ok if it's the same stack mapping
86375 - * that has gotten split..
86376 - */
86377 - if (prev && prev->vm_end == address)
86378 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
86379 -
86380 - expand_downwards(vma, address - PAGE_SIZE);
86381 - }
86382 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
86383 - struct vm_area_struct *next = vma->vm_next;
86384 -
86385 - /* As VM_GROWSDOWN but s/below/above/ */
86386 - if (next && next->vm_start == address + PAGE_SIZE)
86387 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
86388 -
86389 - expand_upwards(vma, address + PAGE_SIZE);
86390 - }
86391 - return 0;
86392 -}
86393 -
86394 -/*
86395 * We enter with non-exclusive mmap_sem (to exclude vma changes,
86396 * but allow concurrent faults), and pte mapped but not yet locked.
86397 * We return with mmap_sem still held, but pte unmapped and unlocked.
86398 @@ -3221,27 +3403,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86399 unsigned long address, pte_t *page_table, pmd_t *pmd,
86400 unsigned int flags)
86401 {
86402 - struct page *page;
86403 + struct page *page = NULL;
86404 spinlock_t *ptl;
86405 pte_t entry;
86406
86407 - pte_unmap(page_table);
86408 -
86409 - /* Check if we need to add a guard page to the stack */
86410 - if (check_stack_guard_page(vma, address) < 0)
86411 - return VM_FAULT_SIGBUS;
86412 -
86413 - /* Use the zero-page for reads */
86414 if (!(flags & FAULT_FLAG_WRITE)) {
86415 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
86416 vma->vm_page_prot));
86417 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86418 + ptl = pte_lockptr(mm, pmd);
86419 + spin_lock(ptl);
86420 if (!pte_none(*page_table))
86421 goto unlock;
86422 goto setpte;
86423 }
86424
86425 /* Allocate our own private page. */
86426 + pte_unmap(page_table);
86427 +
86428 if (unlikely(anon_vma_prepare(vma)))
86429 goto oom;
86430 page = alloc_zeroed_user_highpage_movable(vma, address);
86431 @@ -3265,6 +3443,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
86432 if (!pte_none(*page_table))
86433 goto release;
86434
86435 +#ifdef CONFIG_PAX_SEGMEXEC
86436 + if (pax_find_mirror_vma(vma))
86437 + BUG_ON(!trylock_page(page));
86438 +#endif
86439 +
86440 inc_mm_counter_fast(mm, MM_ANONPAGES);
86441 page_add_new_anon_rmap(page, vma, address);
86442 setpte:
86443 @@ -3272,6 +3455,12 @@ setpte:
86444
86445 /* No need to invalidate - it was non-present before */
86446 update_mmu_cache(vma, address, page_table);
86447 +
86448 +#ifdef CONFIG_PAX_SEGMEXEC
86449 + if (page)
86450 + pax_mirror_anon_pte(vma, address, page, ptl);
86451 +#endif
86452 +
86453 unlock:
86454 pte_unmap_unlock(page_table, ptl);
86455 return 0;
86456 @@ -3415,6 +3604,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86457 */
86458 /* Only go through if we didn't race with anybody else... */
86459 if (likely(pte_same(*page_table, orig_pte))) {
86460 +
86461 +#ifdef CONFIG_PAX_SEGMEXEC
86462 + if (anon && pax_find_mirror_vma(vma))
86463 + BUG_ON(!trylock_page(page));
86464 +#endif
86465 +
86466 flush_icache_page(vma, page);
86467 entry = mk_pte(page, vma->vm_page_prot);
86468 if (flags & FAULT_FLAG_WRITE)
86469 @@ -3436,6 +3631,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86470
86471 /* no need to invalidate: a not-present page won't be cached */
86472 update_mmu_cache(vma, address, page_table);
86473 +
86474 +#ifdef CONFIG_PAX_SEGMEXEC
86475 + if (anon)
86476 + pax_mirror_anon_pte(vma, address, page, ptl);
86477 + else
86478 + pax_mirror_file_pte(vma, address, page, ptl);
86479 +#endif
86480 +
86481 } else {
86482 if (cow_page)
86483 mem_cgroup_uncharge_page(cow_page);
86484 @@ -3757,6 +3960,12 @@ int handle_pte_fault(struct mm_struct *mm,
86485 if (flags & FAULT_FLAG_WRITE)
86486 flush_tlb_fix_spurious_fault(vma, address);
86487 }
86488 +
86489 +#ifdef CONFIG_PAX_SEGMEXEC
86490 + pax_mirror_pte(vma, address, pte, pmd, ptl);
86491 + return 0;
86492 +#endif
86493 +
86494 unlock:
86495 pte_unmap_unlock(pte, ptl);
86496 return 0;
86497 @@ -3773,6 +3982,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86498 pmd_t *pmd;
86499 pte_t *pte;
86500
86501 +#ifdef CONFIG_PAX_SEGMEXEC
86502 + struct vm_area_struct *vma_m;
86503 +#endif
86504 +
86505 __set_current_state(TASK_RUNNING);
86506
86507 count_vm_event(PGFAULT);
86508 @@ -3784,6 +3997,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86509 if (unlikely(is_vm_hugetlb_page(vma)))
86510 return hugetlb_fault(mm, vma, address, flags);
86511
86512 +#ifdef CONFIG_PAX_SEGMEXEC
86513 + vma_m = pax_find_mirror_vma(vma);
86514 + if (vma_m) {
86515 + unsigned long address_m;
86516 + pgd_t *pgd_m;
86517 + pud_t *pud_m;
86518 + pmd_t *pmd_m;
86519 +
86520 + if (vma->vm_start > vma_m->vm_start) {
86521 + address_m = address;
86522 + address -= SEGMEXEC_TASK_SIZE;
86523 + vma = vma_m;
86524 + } else
86525 + address_m = address + SEGMEXEC_TASK_SIZE;
86526 +
86527 + pgd_m = pgd_offset(mm, address_m);
86528 + pud_m = pud_alloc(mm, pgd_m, address_m);
86529 + if (!pud_m)
86530 + return VM_FAULT_OOM;
86531 + pmd_m = pmd_alloc(mm, pud_m, address_m);
86532 + if (!pmd_m)
86533 + return VM_FAULT_OOM;
86534 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
86535 + return VM_FAULT_OOM;
86536 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
86537 + }
86538 +#endif
86539 +
86540 retry:
86541 pgd = pgd_offset(mm, address);
86542 pud = pud_alloc(mm, pgd, address);
86543 @@ -3882,6 +4123,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
86544 spin_unlock(&mm->page_table_lock);
86545 return 0;
86546 }
86547 +
86548 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
86549 +{
86550 + pud_t *new = pud_alloc_one(mm, address);
86551 + if (!new)
86552 + return -ENOMEM;
86553 +
86554 + smp_wmb(); /* See comment in __pte_alloc */
86555 +
86556 + spin_lock(&mm->page_table_lock);
86557 + if (pgd_present(*pgd)) /* Another has populated it */
86558 + pud_free(mm, new);
86559 + else
86560 + pgd_populate_kernel(mm, pgd, new);
86561 + spin_unlock(&mm->page_table_lock);
86562 + return 0;
86563 +}
86564 #endif /* __PAGETABLE_PUD_FOLDED */
86565
86566 #ifndef __PAGETABLE_PMD_FOLDED
86567 @@ -3912,6 +4170,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
86568 spin_unlock(&mm->page_table_lock);
86569 return 0;
86570 }
86571 +
86572 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
86573 +{
86574 + pmd_t *new = pmd_alloc_one(mm, address);
86575 + if (!new)
86576 + return -ENOMEM;
86577 +
86578 + smp_wmb(); /* See comment in __pte_alloc */
86579 +
86580 + spin_lock(&mm->page_table_lock);
86581 +#ifndef __ARCH_HAS_4LEVEL_HACK
86582 + if (pud_present(*pud)) /* Another has populated it */
86583 + pmd_free(mm, new);
86584 + else
86585 + pud_populate_kernel(mm, pud, new);
86586 +#else
86587 + if (pgd_present(*pud)) /* Another has populated it */
86588 + pmd_free(mm, new);
86589 + else
86590 + pgd_populate_kernel(mm, pud, new);
86591 +#endif /* __ARCH_HAS_4LEVEL_HACK */
86592 + spin_unlock(&mm->page_table_lock);
86593 + return 0;
86594 +}
86595 #endif /* __PAGETABLE_PMD_FOLDED */
86596
86597 #if !defined(__HAVE_ARCH_GATE_AREA)
86598 @@ -3925,7 +4207,7 @@ static int __init gate_vma_init(void)
86599 gate_vma.vm_start = FIXADDR_USER_START;
86600 gate_vma.vm_end = FIXADDR_USER_END;
86601 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
86602 - gate_vma.vm_page_prot = __P101;
86603 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
86604
86605 return 0;
86606 }
86607 @@ -4059,8 +4341,8 @@ out:
86608 return ret;
86609 }
86610
86611 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
86612 - void *buf, int len, int write)
86613 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
86614 + void *buf, size_t len, int write)
86615 {
86616 resource_size_t phys_addr;
86617 unsigned long prot = 0;
86618 @@ -4085,8 +4367,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
86619 * Access another process' address space as given in mm. If non-NULL, use the
86620 * given task for page fault accounting.
86621 */
86622 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
86623 - unsigned long addr, void *buf, int len, int write)
86624 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
86625 + unsigned long addr, void *buf, size_t len, int write)
86626 {
86627 struct vm_area_struct *vma;
86628 void *old_buf = buf;
86629 @@ -4094,7 +4376,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
86630 down_read(&mm->mmap_sem);
86631 /* ignore errors, just check how much was successfully transferred */
86632 while (len) {
86633 - int bytes, ret, offset;
86634 + ssize_t bytes, ret, offset;
86635 void *maddr;
86636 struct page *page = NULL;
86637
86638 @@ -4153,8 +4435,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
86639 *
86640 * The caller must hold a reference on @mm.
86641 */
86642 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
86643 - void *buf, int len, int write)
86644 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
86645 + void *buf, size_t len, int write)
86646 {
86647 return __access_remote_vm(NULL, mm, addr, buf, len, write);
86648 }
86649 @@ -4164,11 +4446,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
86650 * Source/target buffer must be kernel space,
86651 * Do not walk the page table directly, use get_user_pages
86652 */
86653 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
86654 - void *buf, int len, int write)
86655 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
86656 + void *buf, size_t len, int write)
86657 {
86658 struct mm_struct *mm;
86659 - int ret;
86660 + ssize_t ret;
86661
86662 mm = get_task_mm(tsk);
86663 if (!mm)
86664 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
86665 index 4baf12e..5497066 100644
86666 --- a/mm/mempolicy.c
86667 +++ b/mm/mempolicy.c
86668 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
86669 unsigned long vmstart;
86670 unsigned long vmend;
86671
86672 +#ifdef CONFIG_PAX_SEGMEXEC
86673 + struct vm_area_struct *vma_m;
86674 +#endif
86675 +
86676 vma = find_vma(mm, start);
86677 if (!vma || vma->vm_start > start)
86678 return -EFAULT;
86679 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
86680 err = vma_replace_policy(vma, new_pol);
86681 if (err)
86682 goto out;
86683 +
86684 +#ifdef CONFIG_PAX_SEGMEXEC
86685 + vma_m = pax_find_mirror_vma(vma);
86686 + if (vma_m) {
86687 + err = vma_replace_policy(vma_m, new_pol);
86688 + if (err)
86689 + goto out;
86690 + }
86691 +#endif
86692 +
86693 }
86694
86695 out:
86696 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
86697
86698 if (end < start)
86699 return -EINVAL;
86700 +
86701 +#ifdef CONFIG_PAX_SEGMEXEC
86702 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
86703 + if (end > SEGMEXEC_TASK_SIZE)
86704 + return -EINVAL;
86705 + } else
86706 +#endif
86707 +
86708 + if (end > TASK_SIZE)
86709 + return -EINVAL;
86710 +
86711 if (end == start)
86712 return 0;
86713
86714 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
86715 */
86716 tcred = __task_cred(task);
86717 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
86718 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
86719 - !capable(CAP_SYS_NICE)) {
86720 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
86721 rcu_read_unlock();
86722 err = -EPERM;
86723 goto out_put;
86724 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
86725 goto out;
86726 }
86727
86728 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
86729 + if (mm != current->mm &&
86730 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
86731 + mmput(mm);
86732 + err = -EPERM;
86733 + goto out;
86734 + }
86735 +#endif
86736 +
86737 err = do_migrate_pages(mm, old, new,
86738 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
86739
86740 diff --git a/mm/migrate.c b/mm/migrate.c
86741 index 6f0c244..6d1ae32 100644
86742 --- a/mm/migrate.c
86743 +++ b/mm/migrate.c
86744 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
86745 */
86746 tcred = __task_cred(task);
86747 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
86748 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
86749 - !capable(CAP_SYS_NICE)) {
86750 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
86751 rcu_read_unlock();
86752 err = -EPERM;
86753 goto out;
86754 diff --git a/mm/mlock.c b/mm/mlock.c
86755 index 79b7cf7..37472bf 100644
86756 --- a/mm/mlock.c
86757 +++ b/mm/mlock.c
86758 @@ -13,6 +13,7 @@
86759 #include <linux/pagemap.h>
86760 #include <linux/mempolicy.h>
86761 #include <linux/syscalls.h>
86762 +#include <linux/security.h>
86763 #include <linux/sched.h>
86764 #include <linux/export.h>
86765 #include <linux/rmap.h>
86766 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
86767 {
86768 unsigned long nstart, end, tmp;
86769 struct vm_area_struct * vma, * prev;
86770 - int error;
86771 + int error = 0;
86772
86773 VM_BUG_ON(start & ~PAGE_MASK);
86774 VM_BUG_ON(len != PAGE_ALIGN(len));
86775 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
86776 return -EINVAL;
86777 if (end == start)
86778 return 0;
86779 + if (end > TASK_SIZE)
86780 + return -EINVAL;
86781 +
86782 vma = find_vma(current->mm, start);
86783 if (!vma || vma->vm_start > start)
86784 return -ENOMEM;
86785 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
86786 for (nstart = start ; ; ) {
86787 vm_flags_t newflags;
86788
86789 +#ifdef CONFIG_PAX_SEGMEXEC
86790 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
86791 + break;
86792 +#endif
86793 +
86794 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
86795
86796 newflags = vma->vm_flags & ~VM_LOCKED;
86797 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
86798 lock_limit >>= PAGE_SHIFT;
86799
86800 /* check against resource limits */
86801 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
86802 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
86803 error = do_mlock(start, len, 1);
86804 up_write(&current->mm->mmap_sem);
86805 @@ -500,12 +510,18 @@ static int do_mlockall(int flags)
86806 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
86807 vm_flags_t newflags;
86808
86809 +#ifdef CONFIG_PAX_SEGMEXEC
86810 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
86811 + break;
86812 +#endif
86813 +
86814 newflags = vma->vm_flags & ~VM_LOCKED;
86815 if (flags & MCL_CURRENT)
86816 newflags |= VM_LOCKED;
86817
86818 /* Ignore errors */
86819 mlock_fixup(vma, &prev, vma->vm_start, vma->vm_end, newflags);
86820 + cond_resched();
86821 }
86822 out:
86823 return 0;
86824 @@ -532,6 +548,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
86825 lock_limit >>= PAGE_SHIFT;
86826
86827 ret = -ENOMEM;
86828 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
86829 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
86830 capable(CAP_IPC_LOCK))
86831 ret = do_mlockall(flags);
86832 diff --git a/mm/mmap.c b/mm/mmap.c
86833 index f9c97d1..3468d3b 100644
86834 --- a/mm/mmap.c
86835 +++ b/mm/mmap.c
86836 @@ -36,6 +36,7 @@
86837 #include <linux/sched/sysctl.h>
86838 #include <linux/notifier.h>
86839 #include <linux/memory.h>
86840 +#include <linux/random.h>
86841
86842 #include <asm/uaccess.h>
86843 #include <asm/cacheflush.h>
86844 @@ -52,6 +53,16 @@
86845 #define arch_rebalance_pgtables(addr, len) (addr)
86846 #endif
86847
86848 +static inline void verify_mm_writelocked(struct mm_struct *mm)
86849 +{
86850 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
86851 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
86852 + up_read(&mm->mmap_sem);
86853 + BUG();
86854 + }
86855 +#endif
86856 +}
86857 +
86858 static void unmap_region(struct mm_struct *mm,
86859 struct vm_area_struct *vma, struct vm_area_struct *prev,
86860 unsigned long start, unsigned long end);
86861 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
86862 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
86863 *
86864 */
86865 -pgprot_t protection_map[16] = {
86866 +pgprot_t protection_map[16] __read_only = {
86867 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
86868 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
86869 };
86870
86871 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
86872 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
86873 {
86874 - return __pgprot(pgprot_val(protection_map[vm_flags &
86875 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
86876 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
86877 pgprot_val(arch_vm_get_page_prot(vm_flags)));
86878 +
86879 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
86880 + if (!(__supported_pte_mask & _PAGE_NX) &&
86881 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
86882 + (vm_flags & (VM_READ | VM_WRITE)))
86883 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
86884 +#endif
86885 +
86886 + return prot;
86887 }
86888 EXPORT_SYMBOL(vm_get_page_prot);
86889
86890 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
86891 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
86892 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
86893 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
86894 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
86895 /*
86896 * Make sure vm_committed_as in one cacheline and not cacheline shared with
86897 * other variables. It can be updated by several CPUs frequently.
86898 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
86899 struct vm_area_struct *next = vma->vm_next;
86900
86901 might_sleep();
86902 + BUG_ON(vma->vm_mirror);
86903 if (vma->vm_ops && vma->vm_ops->close)
86904 vma->vm_ops->close(vma);
86905 if (vma->vm_file)
86906 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
86907 * not page aligned -Ram Gupta
86908 */
86909 rlim = rlimit(RLIMIT_DATA);
86910 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
86911 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
86912 (mm->end_data - mm->start_data) > rlim)
86913 goto out;
86914 @@ -933,6 +956,12 @@ static int
86915 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
86916 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
86917 {
86918 +
86919 +#ifdef CONFIG_PAX_SEGMEXEC
86920 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
86921 + return 0;
86922 +#endif
86923 +
86924 if (is_mergeable_vma(vma, file, vm_flags) &&
86925 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
86926 if (vma->vm_pgoff == vm_pgoff)
86927 @@ -952,6 +981,12 @@ static int
86928 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
86929 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
86930 {
86931 +
86932 +#ifdef CONFIG_PAX_SEGMEXEC
86933 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
86934 + return 0;
86935 +#endif
86936 +
86937 if (is_mergeable_vma(vma, file, vm_flags) &&
86938 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
86939 pgoff_t vm_pglen;
86940 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
86941 struct vm_area_struct *vma_merge(struct mm_struct *mm,
86942 struct vm_area_struct *prev, unsigned long addr,
86943 unsigned long end, unsigned long vm_flags,
86944 - struct anon_vma *anon_vma, struct file *file,
86945 + struct anon_vma *anon_vma, struct file *file,
86946 pgoff_t pgoff, struct mempolicy *policy)
86947 {
86948 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
86949 struct vm_area_struct *area, *next;
86950 int err;
86951
86952 +#ifdef CONFIG_PAX_SEGMEXEC
86953 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
86954 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
86955 +
86956 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
86957 +#endif
86958 +
86959 /*
86960 * We later require that vma->vm_flags == vm_flags,
86961 * so this tests vma->vm_flags & VM_SPECIAL, too.
86962 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
86963 if (next && next->vm_end == end) /* cases 6, 7, 8 */
86964 next = next->vm_next;
86965
86966 +#ifdef CONFIG_PAX_SEGMEXEC
86967 + if (prev)
86968 + prev_m = pax_find_mirror_vma(prev);
86969 + if (area)
86970 + area_m = pax_find_mirror_vma(area);
86971 + if (next)
86972 + next_m = pax_find_mirror_vma(next);
86973 +#endif
86974 +
86975 /*
86976 * Can it merge with the predecessor?
86977 */
86978 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
86979 /* cases 1, 6 */
86980 err = vma_adjust(prev, prev->vm_start,
86981 next->vm_end, prev->vm_pgoff, NULL);
86982 - } else /* cases 2, 5, 7 */
86983 +
86984 +#ifdef CONFIG_PAX_SEGMEXEC
86985 + if (!err && prev_m)
86986 + err = vma_adjust(prev_m, prev_m->vm_start,
86987 + next_m->vm_end, prev_m->vm_pgoff, NULL);
86988 +#endif
86989 +
86990 + } else { /* cases 2, 5, 7 */
86991 err = vma_adjust(prev, prev->vm_start,
86992 end, prev->vm_pgoff, NULL);
86993 +
86994 +#ifdef CONFIG_PAX_SEGMEXEC
86995 + if (!err && prev_m)
86996 + err = vma_adjust(prev_m, prev_m->vm_start,
86997 + end_m, prev_m->vm_pgoff, NULL);
86998 +#endif
86999 +
87000 + }
87001 if (err)
87002 return NULL;
87003 khugepaged_enter_vma_merge(prev);
87004 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87005 mpol_equal(policy, vma_policy(next)) &&
87006 can_vma_merge_before(next, vm_flags,
87007 anon_vma, file, pgoff+pglen)) {
87008 - if (prev && addr < prev->vm_end) /* case 4 */
87009 + if (prev && addr < prev->vm_end) { /* case 4 */
87010 err = vma_adjust(prev, prev->vm_start,
87011 addr, prev->vm_pgoff, NULL);
87012 - else /* cases 3, 8 */
87013 +
87014 +#ifdef CONFIG_PAX_SEGMEXEC
87015 + if (!err && prev_m)
87016 + err = vma_adjust(prev_m, prev_m->vm_start,
87017 + addr_m, prev_m->vm_pgoff, NULL);
87018 +#endif
87019 +
87020 + } else { /* cases 3, 8 */
87021 err = vma_adjust(area, addr, next->vm_end,
87022 next->vm_pgoff - pglen, NULL);
87023 +
87024 +#ifdef CONFIG_PAX_SEGMEXEC
87025 + if (!err && area_m)
87026 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
87027 + next_m->vm_pgoff - pglen, NULL);
87028 +#endif
87029 +
87030 + }
87031 if (err)
87032 return NULL;
87033 khugepaged_enter_vma_merge(area);
87034 @@ -1165,8 +1246,10 @@ none:
87035 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87036 struct file *file, long pages)
87037 {
87038 - const unsigned long stack_flags
87039 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
87040 +
87041 +#ifdef CONFIG_PAX_RANDMMAP
87042 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87043 +#endif
87044
87045 mm->total_vm += pages;
87046
87047 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87048 mm->shared_vm += pages;
87049 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
87050 mm->exec_vm += pages;
87051 - } else if (flags & stack_flags)
87052 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
87053 mm->stack_vm += pages;
87054 }
87055 #endif /* CONFIG_PROC_FS */
87056 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87057 * (the exception is when the underlying filesystem is noexec
87058 * mounted, in which case we dont add PROT_EXEC.)
87059 */
87060 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
87061 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
87062 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
87063 prot |= PROT_EXEC;
87064
87065 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87066 /* Obtain the address to map to. we verify (or select) it and ensure
87067 * that it represents a valid section of the address space.
87068 */
87069 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
87070 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
87071 if (addr & ~PAGE_MASK)
87072 return addr;
87073
87074 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87075 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
87076 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
87077
87078 +#ifdef CONFIG_PAX_MPROTECT
87079 + if (mm->pax_flags & MF_PAX_MPROTECT) {
87080 +
87081 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
87082 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
87083 + mm->binfmt->handle_mmap)
87084 + mm->binfmt->handle_mmap(file);
87085 +#endif
87086 +
87087 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
87088 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
87089 + gr_log_rwxmmap(file);
87090 +
87091 +#ifdef CONFIG_PAX_EMUPLT
87092 + vm_flags &= ~VM_EXEC;
87093 +#else
87094 + return -EPERM;
87095 +#endif
87096 +
87097 + }
87098 +
87099 + if (!(vm_flags & VM_EXEC))
87100 + vm_flags &= ~VM_MAYEXEC;
87101 +#else
87102 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
87103 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
87104 +#endif
87105 + else
87106 + vm_flags &= ~VM_MAYWRITE;
87107 + }
87108 +#endif
87109 +
87110 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87111 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
87112 + vm_flags &= ~VM_PAGEEXEC;
87113 +#endif
87114 +
87115 if (flags & MAP_LOCKED)
87116 if (!can_do_mlock())
87117 return -EPERM;
87118 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87119 locked += mm->locked_vm;
87120 lock_limit = rlimit(RLIMIT_MEMLOCK);
87121 lock_limit >>= PAGE_SHIFT;
87122 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87123 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
87124 return -EAGAIN;
87125 }
87126 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87127 vm_flags |= VM_NORESERVE;
87128 }
87129
87130 + if (!gr_acl_handle_mmap(file, prot))
87131 + return -EACCES;
87132 +
87133 addr = mmap_region(file, addr, len, vm_flags, pgoff);
87134 if (!IS_ERR_VALUE(addr) &&
87135 ((vm_flags & VM_LOCKED) ||
87136 @@ -1434,7 +1558,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
87137 vm_flags_t vm_flags = vma->vm_flags;
87138
87139 /* If it was private or non-writable, the write bit is already clear */
87140 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
87141 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
87142 return 0;
87143
87144 /* The backer wishes to know when pages are first written to? */
87145 @@ -1482,7 +1606,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87146 unsigned long charged = 0;
87147 struct inode *inode = file ? file_inode(file) : NULL;
87148
87149 +#ifdef CONFIG_PAX_SEGMEXEC
87150 + struct vm_area_struct *vma_m = NULL;
87151 +#endif
87152 +
87153 + /*
87154 + * mm->mmap_sem is required to protect against another thread
87155 + * changing the mappings in case we sleep.
87156 + */
87157 + verify_mm_writelocked(mm);
87158 +
87159 /* Check against address space limit. */
87160 +
87161 +#ifdef CONFIG_PAX_RANDMMAP
87162 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87163 +#endif
87164 +
87165 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
87166 unsigned long nr_pages;
87167
87168 @@ -1501,11 +1640,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87169
87170 /* Clear old maps */
87171 error = -ENOMEM;
87172 -munmap_back:
87173 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
87174 if (do_munmap(mm, addr, len))
87175 return -ENOMEM;
87176 - goto munmap_back;
87177 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
87178 }
87179
87180 /*
87181 @@ -1536,6 +1674,16 @@ munmap_back:
87182 goto unacct_error;
87183 }
87184
87185 +#ifdef CONFIG_PAX_SEGMEXEC
87186 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
87187 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87188 + if (!vma_m) {
87189 + error = -ENOMEM;
87190 + goto free_vma;
87191 + }
87192 + }
87193 +#endif
87194 +
87195 vma->vm_mm = mm;
87196 vma->vm_start = addr;
87197 vma->vm_end = addr + len;
87198 @@ -1560,6 +1708,13 @@ munmap_back:
87199 if (error)
87200 goto unmap_and_free_vma;
87201
87202 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87203 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
87204 + vma->vm_flags |= VM_PAGEEXEC;
87205 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
87206 + }
87207 +#endif
87208 +
87209 /* Can addr have changed??
87210 *
87211 * Answer: Yes, several device drivers can do it in their
87212 @@ -1598,6 +1753,11 @@ munmap_back:
87213 vma_link(mm, vma, prev, rb_link, rb_parent);
87214 file = vma->vm_file;
87215
87216 +#ifdef CONFIG_PAX_SEGMEXEC
87217 + if (vma_m)
87218 + BUG_ON(pax_mirror_vma(vma_m, vma));
87219 +#endif
87220 +
87221 /* Once vma denies write, undo our temporary denial count */
87222 if (correct_wcount)
87223 atomic_inc(&inode->i_writecount);
87224 @@ -1605,6 +1765,7 @@ out:
87225 perf_event_mmap(vma);
87226
87227 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
87228 + track_exec_limit(mm, addr, addr + len, vm_flags);
87229 if (vm_flags & VM_LOCKED) {
87230 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
87231 vma == get_gate_vma(current->mm)))
87232 @@ -1628,6 +1789,12 @@ unmap_and_free_vma:
87233 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
87234 charged = 0;
87235 free_vma:
87236 +
87237 +#ifdef CONFIG_PAX_SEGMEXEC
87238 + if (vma_m)
87239 + kmem_cache_free(vm_area_cachep, vma_m);
87240 +#endif
87241 +
87242 kmem_cache_free(vm_area_cachep, vma);
87243 unacct_error:
87244 if (charged)
87245 @@ -1635,7 +1802,63 @@ unacct_error:
87246 return error;
87247 }
87248
87249 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87250 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
87251 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
87252 +{
87253 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
87254 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
87255 +
87256 + return 0;
87257 +}
87258 +#endif
87259 +
87260 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
87261 +{
87262 + if (!vma) {
87263 +#ifdef CONFIG_STACK_GROWSUP
87264 + if (addr > sysctl_heap_stack_gap)
87265 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
87266 + else
87267 + vma = find_vma(current->mm, 0);
87268 + if (vma && (vma->vm_flags & VM_GROWSUP))
87269 + return false;
87270 +#endif
87271 + return true;
87272 + }
87273 +
87274 + if (addr + len > vma->vm_start)
87275 + return false;
87276 +
87277 + if (vma->vm_flags & VM_GROWSDOWN)
87278 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
87279 +#ifdef CONFIG_STACK_GROWSUP
87280 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
87281 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
87282 +#endif
87283 + else if (offset)
87284 + return offset <= vma->vm_start - addr - len;
87285 +
87286 + return true;
87287 +}
87288 +
87289 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
87290 +{
87291 + if (vma->vm_start < len)
87292 + return -ENOMEM;
87293 +
87294 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
87295 + if (offset <= vma->vm_start - len)
87296 + return vma->vm_start - len - offset;
87297 + else
87298 + return -ENOMEM;
87299 + }
87300 +
87301 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
87302 + return vma->vm_start - len - sysctl_heap_stack_gap;
87303 + return -ENOMEM;
87304 +}
87305 +
87306 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
87307 {
87308 /*
87309 * We implement the search by looking for an rbtree node that
87310 @@ -1683,11 +1906,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87311 }
87312 }
87313
87314 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
87315 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
87316 check_current:
87317 /* Check if current node has a suitable gap */
87318 if (gap_start > high_limit)
87319 return -ENOMEM;
87320 +
87321 + if (gap_end - gap_start > info->threadstack_offset)
87322 + gap_start += info->threadstack_offset;
87323 + else
87324 + gap_start = gap_end;
87325 +
87326 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87327 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87328 + gap_start += sysctl_heap_stack_gap;
87329 + else
87330 + gap_start = gap_end;
87331 + }
87332 + if (vma->vm_flags & VM_GROWSDOWN) {
87333 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87334 + gap_end -= sysctl_heap_stack_gap;
87335 + else
87336 + gap_end = gap_start;
87337 + }
87338 if (gap_end >= low_limit && gap_end - gap_start >= length)
87339 goto found;
87340
87341 @@ -1737,7 +1978,7 @@ found:
87342 return gap_start;
87343 }
87344
87345 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
87346 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
87347 {
87348 struct mm_struct *mm = current->mm;
87349 struct vm_area_struct *vma;
87350 @@ -1791,6 +2032,24 @@ check_current:
87351 gap_end = vma->vm_start;
87352 if (gap_end < low_limit)
87353 return -ENOMEM;
87354 +
87355 + if (gap_end - gap_start > info->threadstack_offset)
87356 + gap_end -= info->threadstack_offset;
87357 + else
87358 + gap_end = gap_start;
87359 +
87360 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87361 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87362 + gap_start += sysctl_heap_stack_gap;
87363 + else
87364 + gap_start = gap_end;
87365 + }
87366 + if (vma->vm_flags & VM_GROWSDOWN) {
87367 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87368 + gap_end -= sysctl_heap_stack_gap;
87369 + else
87370 + gap_end = gap_start;
87371 + }
87372 if (gap_start <= high_limit && gap_end - gap_start >= length)
87373 goto found;
87374
87375 @@ -1854,6 +2113,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87376 struct mm_struct *mm = current->mm;
87377 struct vm_area_struct *vma;
87378 struct vm_unmapped_area_info info;
87379 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87380
87381 if (len > TASK_SIZE)
87382 return -ENOMEM;
87383 @@ -1861,19 +2121,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87384 if (flags & MAP_FIXED)
87385 return addr;
87386
87387 +#ifdef CONFIG_PAX_RANDMMAP
87388 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87389 +#endif
87390 +
87391 if (addr) {
87392 addr = PAGE_ALIGN(addr);
87393 vma = find_vma(mm, addr);
87394 - if (TASK_SIZE - len >= addr &&
87395 - (!vma || addr + len <= vma->vm_start))
87396 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87397 return addr;
87398 }
87399
87400 info.flags = 0;
87401 info.length = len;
87402 info.low_limit = TASK_UNMAPPED_BASE;
87403 +
87404 +#ifdef CONFIG_PAX_RANDMMAP
87405 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87406 + info.low_limit += mm->delta_mmap;
87407 +#endif
87408 +
87409 info.high_limit = TASK_SIZE;
87410 info.align_mask = 0;
87411 + info.threadstack_offset = offset;
87412 return vm_unmapped_area(&info);
87413 }
87414 #endif
87415 @@ -1892,6 +2162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87416 struct mm_struct *mm = current->mm;
87417 unsigned long addr = addr0;
87418 struct vm_unmapped_area_info info;
87419 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87420
87421 /* requested length too big for entire address space */
87422 if (len > TASK_SIZE)
87423 @@ -1900,12 +2171,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87424 if (flags & MAP_FIXED)
87425 return addr;
87426
87427 +#ifdef CONFIG_PAX_RANDMMAP
87428 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87429 +#endif
87430 +
87431 /* requesting a specific address */
87432 if (addr) {
87433 addr = PAGE_ALIGN(addr);
87434 vma = find_vma(mm, addr);
87435 - if (TASK_SIZE - len >= addr &&
87436 - (!vma || addr + len <= vma->vm_start))
87437 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87438 return addr;
87439 }
87440
87441 @@ -1914,6 +2188,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87442 info.low_limit = PAGE_SIZE;
87443 info.high_limit = mm->mmap_base;
87444 info.align_mask = 0;
87445 + info.threadstack_offset = offset;
87446 addr = vm_unmapped_area(&info);
87447
87448 /*
87449 @@ -1926,6 +2201,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
87450 VM_BUG_ON(addr != -ENOMEM);
87451 info.flags = 0;
87452 info.low_limit = TASK_UNMAPPED_BASE;
87453 +
87454 +#ifdef CONFIG_PAX_RANDMMAP
87455 + if (mm->pax_flags & MF_PAX_RANDMMAP)
87456 + info.low_limit += mm->delta_mmap;
87457 +#endif
87458 +
87459 info.high_limit = TASK_SIZE;
87460 addr = vm_unmapped_area(&info);
87461 }
87462 @@ -2027,6 +2308,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
87463 return vma;
87464 }
87465
87466 +#ifdef CONFIG_PAX_SEGMEXEC
87467 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
87468 +{
87469 + struct vm_area_struct *vma_m;
87470 +
87471 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
87472 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
87473 + BUG_ON(vma->vm_mirror);
87474 + return NULL;
87475 + }
87476 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
87477 + vma_m = vma->vm_mirror;
87478 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
87479 + BUG_ON(vma->vm_file != vma_m->vm_file);
87480 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
87481 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
87482 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
87483 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
87484 + return vma_m;
87485 +}
87486 +#endif
87487 +
87488 /*
87489 * Verify that the stack growth is acceptable and
87490 * update accounting. This is shared with both the
87491 @@ -2043,6 +2346,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87492 return -ENOMEM;
87493
87494 /* Stack limit test */
87495 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
87496 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
87497 return -ENOMEM;
87498
87499 @@ -2053,6 +2357,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87500 locked = mm->locked_vm + grow;
87501 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
87502 limit >>= PAGE_SHIFT;
87503 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87504 if (locked > limit && !capable(CAP_IPC_LOCK))
87505 return -ENOMEM;
87506 }
87507 @@ -2082,37 +2387,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
87508 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
87509 * vma is the last one with address > vma->vm_end. Have to extend vma.
87510 */
87511 +#ifndef CONFIG_IA64
87512 +static
87513 +#endif
87514 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
87515 {
87516 int error;
87517 + bool locknext;
87518
87519 if (!(vma->vm_flags & VM_GROWSUP))
87520 return -EFAULT;
87521
87522 + /* Also guard against wrapping around to address 0. */
87523 + if (address < PAGE_ALIGN(address+1))
87524 + address = PAGE_ALIGN(address+1);
87525 + else
87526 + return -ENOMEM;
87527 +
87528 /*
87529 * We must make sure the anon_vma is allocated
87530 * so that the anon_vma locking is not a noop.
87531 */
87532 if (unlikely(anon_vma_prepare(vma)))
87533 return -ENOMEM;
87534 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
87535 + if (locknext && anon_vma_prepare(vma->vm_next))
87536 + return -ENOMEM;
87537 vma_lock_anon_vma(vma);
87538 + if (locknext)
87539 + vma_lock_anon_vma(vma->vm_next);
87540
87541 /*
87542 * vma->vm_start/vm_end cannot change under us because the caller
87543 * is required to hold the mmap_sem in read mode. We need the
87544 - * anon_vma lock to serialize against concurrent expand_stacks.
87545 - * Also guard against wrapping around to address 0.
87546 + * anon_vma locks to serialize against concurrent expand_stacks
87547 + * and expand_upwards.
87548 */
87549 - if (address < PAGE_ALIGN(address+4))
87550 - address = PAGE_ALIGN(address+4);
87551 - else {
87552 - vma_unlock_anon_vma(vma);
87553 - return -ENOMEM;
87554 - }
87555 error = 0;
87556
87557 /* Somebody else might have raced and expanded it already */
87558 - if (address > vma->vm_end) {
87559 + 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)
87560 + error = -ENOMEM;
87561 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
87562 unsigned long size, grow;
87563
87564 size = address - vma->vm_start;
87565 @@ -2147,6 +2463,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
87566 }
87567 }
87568 }
87569 + if (locknext)
87570 + vma_unlock_anon_vma(vma->vm_next);
87571 vma_unlock_anon_vma(vma);
87572 khugepaged_enter_vma_merge(vma);
87573 validate_mm(vma->vm_mm);
87574 @@ -2161,6 +2479,8 @@ int expand_downwards(struct vm_area_struct *vma,
87575 unsigned long address)
87576 {
87577 int error;
87578 + bool lockprev = false;
87579 + struct vm_area_struct *prev;
87580
87581 /*
87582 * We must make sure the anon_vma is allocated
87583 @@ -2174,6 +2494,15 @@ int expand_downwards(struct vm_area_struct *vma,
87584 if (error)
87585 return error;
87586
87587 + prev = vma->vm_prev;
87588 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
87589 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
87590 +#endif
87591 + if (lockprev && anon_vma_prepare(prev))
87592 + return -ENOMEM;
87593 + if (lockprev)
87594 + vma_lock_anon_vma(prev);
87595 +
87596 vma_lock_anon_vma(vma);
87597
87598 /*
87599 @@ -2183,9 +2512,17 @@ int expand_downwards(struct vm_area_struct *vma,
87600 */
87601
87602 /* Somebody else might have raced and expanded it already */
87603 - if (address < vma->vm_start) {
87604 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
87605 + error = -ENOMEM;
87606 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
87607 unsigned long size, grow;
87608
87609 +#ifdef CONFIG_PAX_SEGMEXEC
87610 + struct vm_area_struct *vma_m;
87611 +
87612 + vma_m = pax_find_mirror_vma(vma);
87613 +#endif
87614 +
87615 size = vma->vm_end - address;
87616 grow = (vma->vm_start - address) >> PAGE_SHIFT;
87617
87618 @@ -2210,13 +2547,27 @@ int expand_downwards(struct vm_area_struct *vma,
87619 vma->vm_pgoff -= grow;
87620 anon_vma_interval_tree_post_update_vma(vma);
87621 vma_gap_update(vma);
87622 +
87623 +#ifdef CONFIG_PAX_SEGMEXEC
87624 + if (vma_m) {
87625 + anon_vma_interval_tree_pre_update_vma(vma_m);
87626 + vma_m->vm_start -= grow << PAGE_SHIFT;
87627 + vma_m->vm_pgoff -= grow;
87628 + anon_vma_interval_tree_post_update_vma(vma_m);
87629 + vma_gap_update(vma_m);
87630 + }
87631 +#endif
87632 +
87633 spin_unlock(&vma->vm_mm->page_table_lock);
87634
87635 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
87636 perf_event_mmap(vma);
87637 }
87638 }
87639 }
87640 vma_unlock_anon_vma(vma);
87641 + if (lockprev)
87642 + vma_unlock_anon_vma(prev);
87643 khugepaged_enter_vma_merge(vma);
87644 validate_mm(vma->vm_mm);
87645 return error;
87646 @@ -2314,6 +2665,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
87647 do {
87648 long nrpages = vma_pages(vma);
87649
87650 +#ifdef CONFIG_PAX_SEGMEXEC
87651 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
87652 + vma = remove_vma(vma);
87653 + continue;
87654 + }
87655 +#endif
87656 +
87657 if (vma->vm_flags & VM_ACCOUNT)
87658 nr_accounted += nrpages;
87659 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
87660 @@ -2358,6 +2716,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
87661 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
87662 vma->vm_prev = NULL;
87663 do {
87664 +
87665 +#ifdef CONFIG_PAX_SEGMEXEC
87666 + if (vma->vm_mirror) {
87667 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
87668 + vma->vm_mirror->vm_mirror = NULL;
87669 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
87670 + vma->vm_mirror = NULL;
87671 + }
87672 +#endif
87673 +
87674 vma_rb_erase(vma, &mm->mm_rb);
87675 mm->map_count--;
87676 tail_vma = vma;
87677 @@ -2384,14 +2752,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
87678 struct vm_area_struct *new;
87679 int err = -ENOMEM;
87680
87681 +#ifdef CONFIG_PAX_SEGMEXEC
87682 + struct vm_area_struct *vma_m, *new_m = NULL;
87683 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
87684 +#endif
87685 +
87686 if (is_vm_hugetlb_page(vma) && (addr &
87687 ~(huge_page_mask(hstate_vma(vma)))))
87688 return -EINVAL;
87689
87690 +#ifdef CONFIG_PAX_SEGMEXEC
87691 + vma_m = pax_find_mirror_vma(vma);
87692 +#endif
87693 +
87694 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
87695 if (!new)
87696 goto out_err;
87697
87698 +#ifdef CONFIG_PAX_SEGMEXEC
87699 + if (vma_m) {
87700 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
87701 + if (!new_m) {
87702 + kmem_cache_free(vm_area_cachep, new);
87703 + goto out_err;
87704 + }
87705 + }
87706 +#endif
87707 +
87708 /* most fields are the same, copy all, and then fixup */
87709 *new = *vma;
87710
87711 @@ -2404,6 +2791,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
87712 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
87713 }
87714
87715 +#ifdef CONFIG_PAX_SEGMEXEC
87716 + if (vma_m) {
87717 + *new_m = *vma_m;
87718 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
87719 + new_m->vm_mirror = new;
87720 + new->vm_mirror = new_m;
87721 +
87722 + if (new_below)
87723 + new_m->vm_end = addr_m;
87724 + else {
87725 + new_m->vm_start = addr_m;
87726 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
87727 + }
87728 + }
87729 +#endif
87730 +
87731 pol = mpol_dup(vma_policy(vma));
87732 if (IS_ERR(pol)) {
87733 err = PTR_ERR(pol);
87734 @@ -2426,6 +2829,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
87735 else
87736 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
87737
87738 +#ifdef CONFIG_PAX_SEGMEXEC
87739 + if (!err && vma_m) {
87740 + if (anon_vma_clone(new_m, vma_m))
87741 + goto out_free_mpol;
87742 +
87743 + mpol_get(pol);
87744 + vma_set_policy(new_m, pol);
87745 +
87746 + if (new_m->vm_file)
87747 + get_file(new_m->vm_file);
87748 +
87749 + if (new_m->vm_ops && new_m->vm_ops->open)
87750 + new_m->vm_ops->open(new_m);
87751 +
87752 + if (new_below)
87753 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
87754 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
87755 + else
87756 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
87757 +
87758 + if (err) {
87759 + if (new_m->vm_ops && new_m->vm_ops->close)
87760 + new_m->vm_ops->close(new_m);
87761 + if (new_m->vm_file)
87762 + fput(new_m->vm_file);
87763 + mpol_put(pol);
87764 + }
87765 + }
87766 +#endif
87767 +
87768 /* Success. */
87769 if (!err)
87770 return 0;
87771 @@ -2435,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
87772 new->vm_ops->close(new);
87773 if (new->vm_file)
87774 fput(new->vm_file);
87775 - unlink_anon_vmas(new);
87776 out_free_mpol:
87777 mpol_put(pol);
87778 out_free_vma:
87779 +
87780 +#ifdef CONFIG_PAX_SEGMEXEC
87781 + if (new_m) {
87782 + unlink_anon_vmas(new_m);
87783 + kmem_cache_free(vm_area_cachep, new_m);
87784 + }
87785 +#endif
87786 +
87787 + unlink_anon_vmas(new);
87788 kmem_cache_free(vm_area_cachep, new);
87789 out_err:
87790 return err;
87791 @@ -2451,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
87792 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
87793 unsigned long addr, int new_below)
87794 {
87795 +
87796 +#ifdef CONFIG_PAX_SEGMEXEC
87797 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
87798 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
87799 + if (mm->map_count >= sysctl_max_map_count-1)
87800 + return -ENOMEM;
87801 + } else
87802 +#endif
87803 +
87804 if (mm->map_count >= sysctl_max_map_count)
87805 return -ENOMEM;
87806
87807 @@ -2462,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
87808 * work. This now handles partial unmappings.
87809 * Jeremy Fitzhardinge <jeremy@goop.org>
87810 */
87811 +#ifdef CONFIG_PAX_SEGMEXEC
87812 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
87813 {
87814 + int ret = __do_munmap(mm, start, len);
87815 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
87816 + return ret;
87817 +
87818 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
87819 +}
87820 +
87821 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
87822 +#else
87823 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
87824 +#endif
87825 +{
87826 unsigned long end;
87827 struct vm_area_struct *vma, *prev, *last;
87828
87829 + /*
87830 + * mm->mmap_sem is required to protect against another thread
87831 + * changing the mappings in case we sleep.
87832 + */
87833 + verify_mm_writelocked(mm);
87834 +
87835 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
87836 return -EINVAL;
87837
87838 @@ -2541,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
87839 /* Fix up all other VM information */
87840 remove_vma_list(mm, vma);
87841
87842 + track_exec_limit(mm, start, end, 0UL);
87843 +
87844 return 0;
87845 }
87846
87847 @@ -2549,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
87848 int ret;
87849 struct mm_struct *mm = current->mm;
87850
87851 +
87852 +#ifdef CONFIG_PAX_SEGMEXEC
87853 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
87854 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
87855 + return -EINVAL;
87856 +#endif
87857 +
87858 down_write(&mm->mmap_sem);
87859 ret = do_munmap(mm, start, len);
87860 up_write(&mm->mmap_sem);
87861 @@ -2562,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
87862 return vm_munmap(addr, len);
87863 }
87864
87865 -static inline void verify_mm_writelocked(struct mm_struct *mm)
87866 -{
87867 -#ifdef CONFIG_DEBUG_VM
87868 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
87869 - WARN_ON(1);
87870 - up_read(&mm->mmap_sem);
87871 - }
87872 -#endif
87873 -}
87874 -
87875 /*
87876 * this is really a simplified "do_mmap". it only handles
87877 * anonymous maps. eventually we may be able to do some
87878 @@ -2585,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
87879 struct rb_node ** rb_link, * rb_parent;
87880 pgoff_t pgoff = addr >> PAGE_SHIFT;
87881 int error;
87882 + unsigned long charged;
87883
87884 len = PAGE_ALIGN(len);
87885 if (!len)
87886 @@ -2592,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
87887
87888 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
87889
87890 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
87891 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
87892 + flags &= ~VM_EXEC;
87893 +
87894 +#ifdef CONFIG_PAX_MPROTECT
87895 + if (mm->pax_flags & MF_PAX_MPROTECT)
87896 + flags &= ~VM_MAYEXEC;
87897 +#endif
87898 +
87899 + }
87900 +#endif
87901 +
87902 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
87903 if (error & ~PAGE_MASK)
87904 return error;
87905
87906 + charged = len >> PAGE_SHIFT;
87907 +
87908 /*
87909 * mlock MCL_FUTURE?
87910 */
87911 if (mm->def_flags & VM_LOCKED) {
87912 unsigned long locked, lock_limit;
87913 - locked = len >> PAGE_SHIFT;
87914 + locked = charged;
87915 locked += mm->locked_vm;
87916 lock_limit = rlimit(RLIMIT_MEMLOCK);
87917 lock_limit >>= PAGE_SHIFT;
87918 @@ -2618,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
87919 /*
87920 * Clear old maps. this also does some error checking for us
87921 */
87922 - munmap_back:
87923 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
87924 if (do_munmap(mm, addr, len))
87925 return -ENOMEM;
87926 - goto munmap_back;
87927 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
87928 }
87929
87930 /* Check against address space limits *after* clearing old maps... */
87931 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
87932 + if (!may_expand_vm(mm, charged))
87933 return -ENOMEM;
87934
87935 if (mm->map_count > sysctl_max_map_count)
87936 return -ENOMEM;
87937
87938 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
87939 + if (security_vm_enough_memory_mm(mm, charged))
87940 return -ENOMEM;
87941
87942 /* Can we just expand an old private anonymous mapping? */
87943 @@ -2646,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
87944 */
87945 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87946 if (!vma) {
87947 - vm_unacct_memory(len >> PAGE_SHIFT);
87948 + vm_unacct_memory(charged);
87949 return -ENOMEM;
87950 }
87951
87952 @@ -2660,9 +3142,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
87953 vma_link(mm, vma, prev, rb_link, rb_parent);
87954 out:
87955 perf_event_mmap(vma);
87956 - mm->total_vm += len >> PAGE_SHIFT;
87957 + mm->total_vm += charged;
87958 if (flags & VM_LOCKED)
87959 - mm->locked_vm += (len >> PAGE_SHIFT);
87960 + mm->locked_vm += charged;
87961 + track_exec_limit(mm, addr, addr + len, flags);
87962 return addr;
87963 }
87964
87965 @@ -2724,6 +3207,7 @@ void exit_mmap(struct mm_struct *mm)
87966 while (vma) {
87967 if (vma->vm_flags & VM_ACCOUNT)
87968 nr_accounted += vma_pages(vma);
87969 + vma->vm_mirror = NULL;
87970 vma = remove_vma(vma);
87971 }
87972 vm_unacct_memory(nr_accounted);
87973 @@ -2740,6 +3224,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
87974 struct vm_area_struct *prev;
87975 struct rb_node **rb_link, *rb_parent;
87976
87977 +#ifdef CONFIG_PAX_SEGMEXEC
87978 + struct vm_area_struct *vma_m = NULL;
87979 +#endif
87980 +
87981 + if (security_mmap_addr(vma->vm_start))
87982 + return -EPERM;
87983 +
87984 /*
87985 * The vm_pgoff of a purely anonymous vma should be irrelevant
87986 * until its first write fault, when page's anon_vma and index
87987 @@ -2763,7 +3254,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
87988 security_vm_enough_memory_mm(mm, vma_pages(vma)))
87989 return -ENOMEM;
87990
87991 +#ifdef CONFIG_PAX_SEGMEXEC
87992 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
87993 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87994 + if (!vma_m)
87995 + return -ENOMEM;
87996 + }
87997 +#endif
87998 +
87999 vma_link(mm, vma, prev, rb_link, rb_parent);
88000 +
88001 +#ifdef CONFIG_PAX_SEGMEXEC
88002 + if (vma_m)
88003 + BUG_ON(pax_mirror_vma(vma_m, vma));
88004 +#endif
88005 +
88006 return 0;
88007 }
88008
88009 @@ -2783,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88010 struct mempolicy *pol;
88011 bool faulted_in_anon_vma = true;
88012
88013 + BUG_ON(vma->vm_mirror);
88014 +
88015 /*
88016 * If anonymous vma has not yet been faulted, update new pgoff
88017 * to match new location, to increase its chance of merging.
88018 @@ -2849,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88019 return NULL;
88020 }
88021
88022 +#ifdef CONFIG_PAX_SEGMEXEC
88023 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
88024 +{
88025 + struct vm_area_struct *prev_m;
88026 + struct rb_node **rb_link_m, *rb_parent_m;
88027 + struct mempolicy *pol_m;
88028 +
88029 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
88030 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
88031 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
88032 + *vma_m = *vma;
88033 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
88034 + if (anon_vma_clone(vma_m, vma))
88035 + return -ENOMEM;
88036 + pol_m = vma_policy(vma_m);
88037 + mpol_get(pol_m);
88038 + vma_set_policy(vma_m, pol_m);
88039 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
88040 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
88041 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
88042 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
88043 + if (vma_m->vm_file)
88044 + get_file(vma_m->vm_file);
88045 + if (vma_m->vm_ops && vma_m->vm_ops->open)
88046 + vma_m->vm_ops->open(vma_m);
88047 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
88048 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
88049 + vma_m->vm_mirror = vma;
88050 + vma->vm_mirror = vma_m;
88051 + return 0;
88052 +}
88053 +#endif
88054 +
88055 /*
88056 * Return true if the calling process may expand its vm space by the passed
88057 * number of pages
88058 @@ -2860,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
88059
88060 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
88061
88062 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
88063 if (cur + npages > lim)
88064 return 0;
88065 return 1;
88066 @@ -2930,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
88067 vma->vm_start = addr;
88068 vma->vm_end = addr + len;
88069
88070 +#ifdef CONFIG_PAX_MPROTECT
88071 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88072 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88073 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
88074 + return -EPERM;
88075 + if (!(vm_flags & VM_EXEC))
88076 + vm_flags &= ~VM_MAYEXEC;
88077 +#else
88078 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88079 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88080 +#endif
88081 + else
88082 + vm_flags &= ~VM_MAYWRITE;
88083 + }
88084 +#endif
88085 +
88086 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
88087 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88088
88089 diff --git a/mm/mprotect.c b/mm/mprotect.c
88090 index 94722a4..e661e29 100644
88091 --- a/mm/mprotect.c
88092 +++ b/mm/mprotect.c
88093 @@ -23,10 +23,18 @@
88094 #include <linux/mmu_notifier.h>
88095 #include <linux/migrate.h>
88096 #include <linux/perf_event.h>
88097 +#include <linux/sched/sysctl.h>
88098 +
88099 +#ifdef CONFIG_PAX_MPROTECT
88100 +#include <linux/elf.h>
88101 +#include <linux/binfmts.h>
88102 +#endif
88103 +
88104 #include <asm/uaccess.h>
88105 #include <asm/pgtable.h>
88106 #include <asm/cacheflush.h>
88107 #include <asm/tlbflush.h>
88108 +#include <asm/mmu_context.h>
88109
88110 #ifndef pgprot_modify
88111 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
88112 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
88113 return pages;
88114 }
88115
88116 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88117 +/* called while holding the mmap semaphor for writing except stack expansion */
88118 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
88119 +{
88120 + unsigned long oldlimit, newlimit = 0UL;
88121 +
88122 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
88123 + return;
88124 +
88125 + spin_lock(&mm->page_table_lock);
88126 + oldlimit = mm->context.user_cs_limit;
88127 + if ((prot & VM_EXEC) && oldlimit < end)
88128 + /* USER_CS limit moved up */
88129 + newlimit = end;
88130 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
88131 + /* USER_CS limit moved down */
88132 + newlimit = start;
88133 +
88134 + if (newlimit) {
88135 + mm->context.user_cs_limit = newlimit;
88136 +
88137 +#ifdef CONFIG_SMP
88138 + wmb();
88139 + cpus_clear(mm->context.cpu_user_cs_mask);
88140 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
88141 +#endif
88142 +
88143 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
88144 + }
88145 + spin_unlock(&mm->page_table_lock);
88146 + if (newlimit == end) {
88147 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
88148 +
88149 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
88150 + if (is_vm_hugetlb_page(vma))
88151 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
88152 + else
88153 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
88154 + }
88155 +}
88156 +#endif
88157 +
88158 int
88159 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88160 unsigned long start, unsigned long end, unsigned long newflags)
88161 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88162 int error;
88163 int dirty_accountable = 0;
88164
88165 +#ifdef CONFIG_PAX_SEGMEXEC
88166 + struct vm_area_struct *vma_m = NULL;
88167 + unsigned long start_m, end_m;
88168 +
88169 + start_m = start + SEGMEXEC_TASK_SIZE;
88170 + end_m = end + SEGMEXEC_TASK_SIZE;
88171 +#endif
88172 +
88173 if (newflags == oldflags) {
88174 *pprev = vma;
88175 return 0;
88176 }
88177
88178 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
88179 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
88180 +
88181 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
88182 + return -ENOMEM;
88183 +
88184 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
88185 + return -ENOMEM;
88186 + }
88187 +
88188 /*
88189 * If we make a private mapping writable we increase our commit;
88190 * but (without finer accounting) cannot reduce our commit if we
88191 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88192 }
88193 }
88194
88195 +#ifdef CONFIG_PAX_SEGMEXEC
88196 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
88197 + if (start != vma->vm_start) {
88198 + error = split_vma(mm, vma, start, 1);
88199 + if (error)
88200 + goto fail;
88201 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
88202 + *pprev = (*pprev)->vm_next;
88203 + }
88204 +
88205 + if (end != vma->vm_end) {
88206 + error = split_vma(mm, vma, end, 0);
88207 + if (error)
88208 + goto fail;
88209 + }
88210 +
88211 + if (pax_find_mirror_vma(vma)) {
88212 + error = __do_munmap(mm, start_m, end_m - start_m);
88213 + if (error)
88214 + goto fail;
88215 + } else {
88216 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88217 + if (!vma_m) {
88218 + error = -ENOMEM;
88219 + goto fail;
88220 + }
88221 + vma->vm_flags = newflags;
88222 + error = pax_mirror_vma(vma_m, vma);
88223 + if (error) {
88224 + vma->vm_flags = oldflags;
88225 + goto fail;
88226 + }
88227 + }
88228 + }
88229 +#endif
88230 +
88231 /*
88232 * First try to merge with previous and/or next vma.
88233 */
88234 @@ -296,9 +400,21 @@ success:
88235 * vm_flags and vm_page_prot are protected by the mmap_sem
88236 * held in write mode.
88237 */
88238 +
88239 +#ifdef CONFIG_PAX_SEGMEXEC
88240 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
88241 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
88242 +#endif
88243 +
88244 vma->vm_flags = newflags;
88245 +
88246 +#ifdef CONFIG_PAX_MPROTECT
88247 + if (mm->binfmt && mm->binfmt->handle_mprotect)
88248 + mm->binfmt->handle_mprotect(vma, newflags);
88249 +#endif
88250 +
88251 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
88252 - vm_get_page_prot(newflags));
88253 + vm_get_page_prot(vma->vm_flags));
88254
88255 if (vma_wants_writenotify(vma)) {
88256 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
88257 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88258 end = start + len;
88259 if (end <= start)
88260 return -ENOMEM;
88261 +
88262 +#ifdef CONFIG_PAX_SEGMEXEC
88263 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
88264 + if (end > SEGMEXEC_TASK_SIZE)
88265 + return -EINVAL;
88266 + } else
88267 +#endif
88268 +
88269 + if (end > TASK_SIZE)
88270 + return -EINVAL;
88271 +
88272 if (!arch_validate_prot(prot))
88273 return -EINVAL;
88274
88275 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88276 /*
88277 * Does the application expect PROT_READ to imply PROT_EXEC:
88278 */
88279 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88280 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88281 prot |= PROT_EXEC;
88282
88283 vm_flags = calc_vm_prot_bits(prot);
88284 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88285 if (start > vma->vm_start)
88286 prev = vma;
88287
88288 +#ifdef CONFIG_PAX_MPROTECT
88289 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
88290 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
88291 +#endif
88292 +
88293 for (nstart = start ; ; ) {
88294 unsigned long newflags;
88295
88296 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88297
88298 /* newflags >> 4 shift VM_MAY% in place of VM_% */
88299 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
88300 + if (prot & (PROT_WRITE | PROT_EXEC))
88301 + gr_log_rwxmprotect(vma);
88302 +
88303 + error = -EACCES;
88304 + goto out;
88305 + }
88306 +
88307 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
88308 error = -EACCES;
88309 goto out;
88310 }
88311 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88312 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
88313 if (error)
88314 goto out;
88315 +
88316 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
88317 +
88318 nstart = tmp;
88319
88320 if (nstart < prev->vm_end)
88321 diff --git a/mm/mremap.c b/mm/mremap.c
88322 index 0843feb..5607f47 100644
88323 --- a/mm/mremap.c
88324 +++ b/mm/mremap.c
88325 @@ -25,6 +25,7 @@
88326 #include <asm/uaccess.h>
88327 #include <asm/cacheflush.h>
88328 #include <asm/tlbflush.h>
88329 +#include <asm/pgalloc.h>
88330
88331 #include "internal.h"
88332
88333 @@ -62,8 +63,10 @@ static pmd_t *alloc_new_pmd(struct mm_struct *mm, struct vm_area_struct *vma,
88334 return NULL;
88335
88336 pmd = pmd_alloc(mm, pud, addr);
88337 - if (!pmd)
88338 + if (!pmd) {
88339 + pud_free(mm, pud);
88340 return NULL;
88341 + }
88342
88343 VM_BUG_ON(pmd_trans_huge(*pmd));
88344
88345 @@ -144,6 +147,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
88346 continue;
88347 pte = ptep_get_and_clear(mm, old_addr, old_pte);
88348 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
88349 +
88350 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88351 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
88352 + pte = pte_exprotect(pte);
88353 +#endif
88354 +
88355 pte = move_soft_dirty_pte(pte);
88356 set_pte_at(mm, new_addr, new_pte, pte);
88357 }
88358 @@ -337,6 +346,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
88359 if (is_vm_hugetlb_page(vma))
88360 goto Einval;
88361
88362 +#ifdef CONFIG_PAX_SEGMEXEC
88363 + if (pax_find_mirror_vma(vma))
88364 + goto Einval;
88365 +#endif
88366 +
88367 /* We can't remap across vm area boundaries */
88368 if (old_len > vma->vm_end - addr)
88369 goto Efault;
88370 @@ -392,20 +406,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
88371 unsigned long ret = -EINVAL;
88372 unsigned long charged = 0;
88373 unsigned long map_flags;
88374 + unsigned long pax_task_size = TASK_SIZE;
88375
88376 if (new_addr & ~PAGE_MASK)
88377 goto out;
88378
88379 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
88380 +#ifdef CONFIG_PAX_SEGMEXEC
88381 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88382 + pax_task_size = SEGMEXEC_TASK_SIZE;
88383 +#endif
88384 +
88385 + pax_task_size -= PAGE_SIZE;
88386 +
88387 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
88388 goto out;
88389
88390 /* Check if the location we're moving into overlaps the
88391 * old location at all, and fail if it does.
88392 */
88393 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
88394 - goto out;
88395 -
88396 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
88397 + if (addr + old_len > new_addr && new_addr + new_len > addr)
88398 goto out;
88399
88400 ret = do_munmap(mm, new_addr, new_len);
88401 @@ -474,6 +493,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88402 unsigned long ret = -EINVAL;
88403 unsigned long charged = 0;
88404 bool locked = false;
88405 + unsigned long pax_task_size = TASK_SIZE;
88406
88407 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
88408 return ret;
88409 @@ -495,6 +515,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88410 if (!new_len)
88411 return ret;
88412
88413 +#ifdef CONFIG_PAX_SEGMEXEC
88414 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88415 + pax_task_size = SEGMEXEC_TASK_SIZE;
88416 +#endif
88417 +
88418 + pax_task_size -= PAGE_SIZE;
88419 +
88420 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
88421 + old_len > pax_task_size || addr > pax_task_size-old_len)
88422 + return ret;
88423 +
88424 down_write(&current->mm->mmap_sem);
88425
88426 if (flags & MREMAP_FIXED) {
88427 @@ -545,6 +576,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88428 new_addr = addr;
88429 }
88430 ret = addr;
88431 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
88432 goto out;
88433 }
88434 }
88435 @@ -568,7 +600,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88436 goto out;
88437 }
88438
88439 + map_flags = vma->vm_flags;
88440 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
88441 + if (!(ret & ~PAGE_MASK)) {
88442 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
88443 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
88444 + }
88445 }
88446 out:
88447 if (ret & ~PAGE_MASK)
88448 diff --git a/mm/nommu.c b/mm/nommu.c
88449 index ecd1f15..77039bd 100644
88450 --- a/mm/nommu.c
88451 +++ b/mm/nommu.c
88452 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
88453 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
88454 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88455 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88456 -int heap_stack_gap = 0;
88457
88458 atomic_long_t mmap_pages_allocated;
88459
88460 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
88461 EXPORT_SYMBOL(find_vma);
88462
88463 /*
88464 - * find a VMA
88465 - * - we don't extend stack VMAs under NOMMU conditions
88466 - */
88467 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
88468 -{
88469 - return find_vma(mm, addr);
88470 -}
88471 -
88472 -/*
88473 * expand a stack to a given address
88474 * - not supported under NOMMU conditions
88475 */
88476 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88477
88478 /* most fields are the same, copy all, and then fixup */
88479 *new = *vma;
88480 + INIT_LIST_HEAD(&new->anon_vma_chain);
88481 *region = *vma->vm_region;
88482 new->vm_region = region;
88483
88484 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
88485 }
88486 EXPORT_SYMBOL(generic_file_remap_pages);
88487
88488 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88489 - unsigned long addr, void *buf, int len, int write)
88490 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88491 + unsigned long addr, void *buf, size_t len, int write)
88492 {
88493 struct vm_area_struct *vma;
88494
88495 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88496 *
88497 * The caller must hold a reference on @mm.
88498 */
88499 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88500 - void *buf, int len, int write)
88501 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88502 + void *buf, size_t len, int write)
88503 {
88504 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88505 }
88506 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88507 * Access another process' address space.
88508 * - source/target buffer must be kernel space
88509 */
88510 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
88511 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
88512 {
88513 struct mm_struct *mm;
88514
88515 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
88516 index 3f0c895..60cd104 100644
88517 --- a/mm/page-writeback.c
88518 +++ b/mm/page-writeback.c
88519 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
88520 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
88521 * - the bdi dirty thresh drops quickly due to change of JBOD workload
88522 */
88523 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
88524 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
88525 unsigned long thresh,
88526 unsigned long bg_thresh,
88527 unsigned long dirty,
88528 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
88529 index b100255..fba1254 100644
88530 --- a/mm/page_alloc.c
88531 +++ b/mm/page_alloc.c
88532 @@ -60,6 +60,7 @@
88533 #include <linux/page-debug-flags.h>
88534 #include <linux/hugetlb.h>
88535 #include <linux/sched/rt.h>
88536 +#include <linux/random.h>
88537
88538 #include <asm/sections.h>
88539 #include <asm/tlbflush.h>
88540 @@ -353,7 +354,7 @@ out:
88541 * This usage means that zero-order pages may not be compound.
88542 */
88543
88544 -static void free_compound_page(struct page *page)
88545 +void free_compound_page(struct page *page)
88546 {
88547 __free_pages_ok(page, compound_order(page));
88548 }
88549 @@ -710,6 +711,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
88550 int i;
88551 int bad = 0;
88552
88553 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88554 + unsigned long index = 1UL << order;
88555 +#endif
88556 +
88557 trace_mm_page_free(page, order);
88558 kmemcheck_free_shadow(page, order);
88559
88560 @@ -725,6 +730,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
88561 debug_check_no_obj_freed(page_address(page),
88562 PAGE_SIZE << order);
88563 }
88564 +
88565 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88566 + for (; index; --index)
88567 + sanitize_highpage(page + index - 1);
88568 +#endif
88569 +
88570 arch_free_page(page, order);
88571 kernel_map_pages(page, 1 << order, 0);
88572
88573 @@ -747,6 +758,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
88574 local_irq_restore(flags);
88575 }
88576
88577 +#ifdef CONFIG_PAX_LATENT_ENTROPY
88578 +bool __meminitdata extra_latent_entropy;
88579 +
88580 +static int __init setup_pax_extra_latent_entropy(char *str)
88581 +{
88582 + extra_latent_entropy = true;
88583 + return 0;
88584 +}
88585 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
88586 +
88587 +volatile u64 latent_entropy;
88588 +EXPORT_SYMBOL(latent_entropy);
88589 +#endif
88590 +
88591 void __init __free_pages_bootmem(struct page *page, unsigned int order)
88592 {
88593 unsigned int nr_pages = 1 << order;
88594 @@ -762,6 +787,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
88595 set_page_count(p, 0);
88596 }
88597
88598 +#ifdef CONFIG_PAX_LATENT_ENTROPY
88599 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
88600 + u64 hash = 0;
88601 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
88602 + const u64 *data = lowmem_page_address(page);
88603 +
88604 + for (index = 0; index < end; index++)
88605 + hash ^= hash + data[index];
88606 + latent_entropy ^= hash;
88607 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
88608 + }
88609 +#endif
88610 +
88611 page_zone(page)->managed_pages += 1 << order;
88612 set_page_refcounted(page);
88613 __free_pages(page, order);
88614 @@ -867,8 +905,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
88615 arch_alloc_page(page, order);
88616 kernel_map_pages(page, 1 << order, 1);
88617
88618 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
88619 if (gfp_flags & __GFP_ZERO)
88620 prep_zero_page(page, order, gfp_flags);
88621 +#endif
88622
88623 if (order && (gfp_flags & __GFP_COMP))
88624 prep_compound_page(page, order);
88625 diff --git a/mm/page_io.c b/mm/page_io.c
88626 index ba05b64..ef2f314 100644
88627 --- a/mm/page_io.c
88628 +++ b/mm/page_io.c
88629 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
88630 struct file *swap_file = sis->swap_file;
88631 struct address_space *mapping = swap_file->f_mapping;
88632 struct iovec iov = {
88633 - .iov_base = kmap(page),
88634 + .iov_base = (void __force_user *)kmap(page),
88635 .iov_len = PAGE_SIZE,
88636 };
88637
88638 diff --git a/mm/percpu.c b/mm/percpu.c
88639 index 8c8e08f..73a5cda 100644
88640 --- a/mm/percpu.c
88641 +++ b/mm/percpu.c
88642 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
88643 static unsigned int pcpu_high_unit_cpu __read_mostly;
88644
88645 /* the address of the first chunk which starts with the kernel static area */
88646 -void *pcpu_base_addr __read_mostly;
88647 +void *pcpu_base_addr __read_only;
88648 EXPORT_SYMBOL_GPL(pcpu_base_addr);
88649
88650 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
88651 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
88652 index fd26d04..0cea1b0 100644
88653 --- a/mm/process_vm_access.c
88654 +++ b/mm/process_vm_access.c
88655 @@ -13,6 +13,7 @@
88656 #include <linux/uio.h>
88657 #include <linux/sched.h>
88658 #include <linux/highmem.h>
88659 +#include <linux/security.h>
88660 #include <linux/ptrace.h>
88661 #include <linux/slab.h>
88662 #include <linux/syscalls.h>
88663 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
88664 size_t iov_l_curr_offset = 0;
88665 ssize_t iov_len;
88666
88667 + return -ENOSYS; // PaX: until properly audited
88668 +
88669 /*
88670 * Work out how many pages of struct pages we're going to need
88671 * when eventually calling get_user_pages
88672 */
88673 for (i = 0; i < riovcnt; i++) {
88674 iov_len = rvec[i].iov_len;
88675 - if (iov_len > 0) {
88676 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
88677 - + iov_len)
88678 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
88679 - / PAGE_SIZE + 1;
88680 - nr_pages = max(nr_pages, nr_pages_iov);
88681 - }
88682 + if (iov_len <= 0)
88683 + continue;
88684 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
88685 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
88686 + nr_pages = max(nr_pages, nr_pages_iov);
88687 }
88688
88689 if (nr_pages == 0)
88690 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
88691 goto free_proc_pages;
88692 }
88693
88694 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
88695 + rc = -EPERM;
88696 + goto put_task_struct;
88697 + }
88698 +
88699 mm = mm_access(task, PTRACE_MODE_ATTACH);
88700 if (!mm || IS_ERR(mm)) {
88701 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
88702 diff --git a/mm/rmap.c b/mm/rmap.c
88703 index b2e29ac..4168491 100644
88704 --- a/mm/rmap.c
88705 +++ b/mm/rmap.c
88706 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
88707 struct anon_vma *anon_vma = vma->anon_vma;
88708 struct anon_vma_chain *avc;
88709
88710 +#ifdef CONFIG_PAX_SEGMEXEC
88711 + struct anon_vma_chain *avc_m = NULL;
88712 +#endif
88713 +
88714 might_sleep();
88715 if (unlikely(!anon_vma)) {
88716 struct mm_struct *mm = vma->vm_mm;
88717 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
88718 if (!avc)
88719 goto out_enomem;
88720
88721 +#ifdef CONFIG_PAX_SEGMEXEC
88722 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
88723 + if (!avc_m)
88724 + goto out_enomem_free_avc;
88725 +#endif
88726 +
88727 anon_vma = find_mergeable_anon_vma(vma);
88728 allocated = NULL;
88729 if (!anon_vma) {
88730 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
88731 /* page_table_lock to protect against threads */
88732 spin_lock(&mm->page_table_lock);
88733 if (likely(!vma->anon_vma)) {
88734 +
88735 +#ifdef CONFIG_PAX_SEGMEXEC
88736 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
88737 +
88738 + if (vma_m) {
88739 + BUG_ON(vma_m->anon_vma);
88740 + vma_m->anon_vma = anon_vma;
88741 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
88742 + avc_m = NULL;
88743 + }
88744 +#endif
88745 +
88746 vma->anon_vma = anon_vma;
88747 anon_vma_chain_link(vma, avc, anon_vma);
88748 allocated = NULL;
88749 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
88750
88751 if (unlikely(allocated))
88752 put_anon_vma(allocated);
88753 +
88754 +#ifdef CONFIG_PAX_SEGMEXEC
88755 + if (unlikely(avc_m))
88756 + anon_vma_chain_free(avc_m);
88757 +#endif
88758 +
88759 if (unlikely(avc))
88760 anon_vma_chain_free(avc);
88761 }
88762 return 0;
88763
88764 out_enomem_free_avc:
88765 +
88766 +#ifdef CONFIG_PAX_SEGMEXEC
88767 + if (avc_m)
88768 + anon_vma_chain_free(avc_m);
88769 +#endif
88770 +
88771 anon_vma_chain_free(avc);
88772 out_enomem:
88773 return -ENOMEM;
88774 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
88775 * Attach the anon_vmas from src to dst.
88776 * Returns 0 on success, -ENOMEM on failure.
88777 */
88778 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
88779 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
88780 {
88781 struct anon_vma_chain *avc, *pavc;
88782 struct anon_vma *root = NULL;
88783 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
88784 * the corresponding VMA in the parent process is attached to.
88785 * Returns 0 on success, non-zero on failure.
88786 */
88787 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
88788 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
88789 {
88790 struct anon_vma_chain *avc;
88791 struct anon_vma *anon_vma;
88792 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
88793 void __init anon_vma_init(void)
88794 {
88795 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
88796 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
88797 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
88798 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
88799 + anon_vma_ctor);
88800 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
88801 + SLAB_PANIC|SLAB_NO_SANITIZE);
88802 }
88803
88804 /*
88805 diff --git a/mm/shmem.c b/mm/shmem.c
88806 index e43dc55..930e3a2 100644
88807 --- a/mm/shmem.c
88808 +++ b/mm/shmem.c
88809 @@ -33,7 +33,7 @@
88810 #include <linux/swap.h>
88811 #include <linux/aio.h>
88812
88813 -static struct vfsmount *shm_mnt;
88814 +struct vfsmount *shm_mnt;
88815
88816 #ifdef CONFIG_SHMEM
88817 /*
88818 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
88819 #define BOGO_DIRENT_SIZE 20
88820
88821 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
88822 -#define SHORT_SYMLINK_LEN 128
88823 +#define SHORT_SYMLINK_LEN 64
88824
88825 /*
88826 * shmem_fallocate and shmem_writepage communicate via inode->i_private
88827 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
88828 static int shmem_xattr_validate(const char *name)
88829 {
88830 struct { const char *prefix; size_t len; } arr[] = {
88831 +
88832 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
88833 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
88834 +#endif
88835 +
88836 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
88837 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
88838 };
88839 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
88840 if (err)
88841 return err;
88842
88843 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
88844 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
88845 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
88846 + return -EOPNOTSUPP;
88847 + if (size > 8)
88848 + return -EINVAL;
88849 + }
88850 +#endif
88851 +
88852 return simple_xattr_set(&info->xattrs, name, value, size, flags);
88853 }
88854
88855 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
88856 int err = -ENOMEM;
88857
88858 /* Round up to L1_CACHE_BYTES to resist false sharing */
88859 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
88860 - L1_CACHE_BYTES), GFP_KERNEL);
88861 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
88862 if (!sbinfo)
88863 return -ENOMEM;
88864
88865 diff --git a/mm/slab.c b/mm/slab.c
88866 index 2580db0..0523956 100644
88867 --- a/mm/slab.c
88868 +++ b/mm/slab.c
88869 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
88870 if ((x)->max_freeable < i) \
88871 (x)->max_freeable = i; \
88872 } while (0)
88873 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
88874 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
88875 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
88876 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
88877 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
88878 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
88879 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
88880 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
88881 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
88882 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
88883 #else
88884 #define STATS_INC_ACTIVE(x) do { } while (0)
88885 #define STATS_DEC_ACTIVE(x) do { } while (0)
88886 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
88887 #define STATS_INC_ALLOCMISS(x) do { } while (0)
88888 #define STATS_INC_FREEHIT(x) do { } while (0)
88889 #define STATS_INC_FREEMISS(x) do { } while (0)
88890 +#define STATS_INC_SANITIZED(x) do { } while (0)
88891 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
88892 #endif
88893
88894 #if DEBUG
88895 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
88896 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
88897 */
88898 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
88899 - const struct slab *slab, void *obj)
88900 + const struct slab *slab, const void *obj)
88901 {
88902 u32 offset = (obj - slab->s_mem);
88903 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
88904 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
88905 */
88906
88907 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
88908 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
88909 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
88910
88911 if (INDEX_AC != INDEX_NODE)
88912 kmalloc_caches[INDEX_NODE] =
88913 create_kmalloc_cache("kmalloc-node",
88914 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
88915 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
88916
88917 slab_early_init = 0;
88918
88919 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
88920 struct array_cache *ac = cpu_cache_get(cachep);
88921
88922 check_irq_off();
88923 +
88924 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88925 + if (pax_sanitize_slab) {
88926 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
88927 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
88928 +
88929 + if (cachep->ctor)
88930 + cachep->ctor(objp);
88931 +
88932 + STATS_INC_SANITIZED(cachep);
88933 + } else
88934 + STATS_INC_NOT_SANITIZED(cachep);
88935 + }
88936 +#endif
88937 +
88938 kmemleak_free_recursive(objp, cachep->flags);
88939 objp = cache_free_debugcheck(cachep, objp, caller);
88940
88941 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
88942
88943 if (unlikely(ZERO_OR_NULL_PTR(objp)))
88944 return;
88945 + VM_BUG_ON(!virt_addr_valid(objp));
88946 local_irq_save(flags);
88947 kfree_debugcheck(objp);
88948 c = virt_to_cache(objp);
88949 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
88950 }
88951 /* cpu stats */
88952 {
88953 - unsigned long allochit = atomic_read(&cachep->allochit);
88954 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
88955 - unsigned long freehit = atomic_read(&cachep->freehit);
88956 - unsigned long freemiss = atomic_read(&cachep->freemiss);
88957 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
88958 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
88959 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
88960 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
88961
88962 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
88963 allochit, allocmiss, freehit, freemiss);
88964 }
88965 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88966 + {
88967 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
88968 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
88969 +
88970 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
88971 + }
88972 +#endif
88973 #endif
88974 }
88975
88976 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
88977 static int __init slab_proc_init(void)
88978 {
88979 #ifdef CONFIG_DEBUG_SLAB_LEAK
88980 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
88981 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
88982 #endif
88983 return 0;
88984 }
88985 module_init(slab_proc_init);
88986 #endif
88987
88988 +bool is_usercopy_object(const void *ptr)
88989 +{
88990 + struct page *page;
88991 + struct kmem_cache *cachep;
88992 +
88993 + if (ZERO_OR_NULL_PTR(ptr))
88994 + return false;
88995 +
88996 + if (!slab_is_available())
88997 + return false;
88998 +
88999 + if (!virt_addr_valid(ptr))
89000 + return false;
89001 +
89002 + page = virt_to_head_page(ptr);
89003 +
89004 + if (!PageSlab(page))
89005 + return false;
89006 +
89007 + cachep = page->slab_cache;
89008 + return cachep->flags & SLAB_USERCOPY;
89009 +}
89010 +
89011 +#ifdef CONFIG_PAX_USERCOPY
89012 +const char *check_heap_object(const void *ptr, unsigned long n)
89013 +{
89014 + struct page *page;
89015 + struct kmem_cache *cachep;
89016 + struct slab *slabp;
89017 + unsigned int objnr;
89018 + unsigned long offset;
89019 +
89020 + if (ZERO_OR_NULL_PTR(ptr))
89021 + return "<null>";
89022 +
89023 + if (!virt_addr_valid(ptr))
89024 + return NULL;
89025 +
89026 + page = virt_to_head_page(ptr);
89027 +
89028 + if (!PageSlab(page))
89029 + return NULL;
89030 +
89031 + cachep = page->slab_cache;
89032 + if (!(cachep->flags & SLAB_USERCOPY))
89033 + return cachep->name;
89034 +
89035 + slabp = page->slab_page;
89036 + objnr = obj_to_index(cachep, slabp, ptr);
89037 + BUG_ON(objnr >= cachep->num);
89038 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
89039 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
89040 + return NULL;
89041 +
89042 + return cachep->name;
89043 +}
89044 +#endif
89045 +
89046 /**
89047 * ksize - get the actual amount of memory allocated for a given object
89048 * @objp: Pointer to the object
89049 diff --git a/mm/slab.h b/mm/slab.h
89050 index a535033..2f98fe5 100644
89051 --- a/mm/slab.h
89052 +++ b/mm/slab.h
89053 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
89054 /* The slab cache that manages slab cache information */
89055 extern struct kmem_cache *kmem_cache;
89056
89057 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89058 +#ifdef CONFIG_X86_64
89059 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
89060 +#else
89061 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
89062 +#endif
89063 +extern bool pax_sanitize_slab;
89064 +#endif
89065 +
89066 unsigned long calculate_alignment(unsigned long flags,
89067 unsigned long align, unsigned long size);
89068
89069 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89070
89071 /* Legal flag mask for kmem_cache_create(), for various configurations */
89072 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
89073 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
89074 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
89075 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
89076
89077 #if defined(CONFIG_DEBUG_SLAB)
89078 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
89079 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
89080 return s;
89081
89082 page = virt_to_head_page(x);
89083 +
89084 + BUG_ON(!PageSlab(page));
89085 +
89086 cachep = page->slab_cache;
89087 if (slab_equal_or_root(cachep, s))
89088 return cachep;
89089 diff --git a/mm/slab_common.c b/mm/slab_common.c
89090 index 538bade..36fed99 100644
89091 --- a/mm/slab_common.c
89092 +++ b/mm/slab_common.c
89093 @@ -22,11 +22,22 @@
89094
89095 #include "slab.h"
89096
89097 -enum slab_state slab_state;
89098 +enum slab_state slab_state __read_only;
89099 LIST_HEAD(slab_caches);
89100 DEFINE_MUTEX(slab_mutex);
89101 struct kmem_cache *kmem_cache;
89102
89103 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89104 +bool pax_sanitize_slab __read_only = true;
89105 +static int __init pax_sanitize_slab_setup(char *str)
89106 +{
89107 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
89108 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
89109 + return 1;
89110 +}
89111 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
89112 +#endif
89113 +
89114 #ifdef CONFIG_DEBUG_VM
89115 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
89116 size_t size)
89117 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
89118
89119 err = __kmem_cache_create(s, flags);
89120 if (!err) {
89121 - s->refcount = 1;
89122 + atomic_set(&s->refcount, 1);
89123 list_add(&s->list, &slab_caches);
89124 memcg_cache_list_add(memcg, s);
89125 } else {
89126 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
89127
89128 get_online_cpus();
89129 mutex_lock(&slab_mutex);
89130 - s->refcount--;
89131 - if (!s->refcount) {
89132 + if (atomic_dec_and_test(&s->refcount)) {
89133 list_del(&s->list);
89134
89135 if (!__kmem_cache_shutdown(s)) {
89136 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
89137 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
89138 name, size, err);
89139
89140 - s->refcount = -1; /* Exempt from merging for now */
89141 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
89142 }
89143
89144 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89145 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89146
89147 create_boot_cache(s, name, size, flags);
89148 list_add(&s->list, &slab_caches);
89149 - s->refcount = 1;
89150 + atomic_set(&s->refcount, 1);
89151 return s;
89152 }
89153
89154 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
89155 EXPORT_SYMBOL(kmalloc_dma_caches);
89156 #endif
89157
89158 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89159 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
89160 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
89161 +#endif
89162 +
89163 /*
89164 * Conversion table for small slabs sizes / 8 to the index in the
89165 * kmalloc array. This is necessary for slabs < 192 since we have non power
89166 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
89167 return kmalloc_dma_caches[index];
89168
89169 #endif
89170 +
89171 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89172 + if (unlikely((flags & GFP_USERCOPY)))
89173 + return kmalloc_usercopy_caches[index];
89174 +
89175 +#endif
89176 +
89177 return kmalloc_caches[index];
89178 }
89179
89180 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
89181 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
89182 if (!kmalloc_caches[i]) {
89183 kmalloc_caches[i] = create_kmalloc_cache(NULL,
89184 - 1 << i, flags);
89185 + 1 << i, SLAB_USERCOPY | flags);
89186 }
89187
89188 /*
89189 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
89190 * earlier power of two caches
89191 */
89192 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
89193 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
89194 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
89195
89196 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
89197 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
89198 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
89199 }
89200
89201 /* Kmalloc array is now usable */
89202 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
89203 }
89204 }
89205 #endif
89206 +
89207 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89208 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
89209 + struct kmem_cache *s = kmalloc_caches[i];
89210 +
89211 + if (s) {
89212 + int size = kmalloc_size(i);
89213 + char *n = kasprintf(GFP_NOWAIT,
89214 + "usercopy-kmalloc-%d", size);
89215 +
89216 + BUG_ON(!n);
89217 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
89218 + size, SLAB_USERCOPY | flags);
89219 + }
89220 + }
89221 +#endif
89222 +
89223 }
89224 #endif /* !CONFIG_SLOB */
89225
89226 @@ -523,6 +562,9 @@ void print_slabinfo_header(struct seq_file *m)
89227 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
89228 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
89229 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
89230 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89231 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
89232 +#endif
89233 #endif
89234 seq_putc(m, '\n');
89235 }
89236 diff --git a/mm/slob.c b/mm/slob.c
89237 index 91bd3f2..e2f549e 100644
89238 --- a/mm/slob.c
89239 +++ b/mm/slob.c
89240 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
89241 /*
89242 * Return the size of a slob block.
89243 */
89244 -static slobidx_t slob_units(slob_t *s)
89245 +static slobidx_t slob_units(const slob_t *s)
89246 {
89247 if (s->units > 0)
89248 return s->units;
89249 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
89250 /*
89251 * Return the next free slob block pointer after this one.
89252 */
89253 -static slob_t *slob_next(slob_t *s)
89254 +static slob_t *slob_next(const slob_t *s)
89255 {
89256 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
89257 slobidx_t next;
89258 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
89259 /*
89260 * Returns true if s is the last free block in its page.
89261 */
89262 -static int slob_last(slob_t *s)
89263 +static int slob_last(const slob_t *s)
89264 {
89265 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
89266 }
89267
89268 -static void *slob_new_pages(gfp_t gfp, int order, int node)
89269 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
89270 {
89271 - void *page;
89272 + struct page *page;
89273
89274 #ifdef CONFIG_NUMA
89275 if (node != NUMA_NO_NODE)
89276 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
89277 if (!page)
89278 return NULL;
89279
89280 - return page_address(page);
89281 + __SetPageSlab(page);
89282 + return page;
89283 }
89284
89285 -static void slob_free_pages(void *b, int order)
89286 +static void slob_free_pages(struct page *sp, int order)
89287 {
89288 if (current->reclaim_state)
89289 current->reclaim_state->reclaimed_slab += 1 << order;
89290 - free_pages((unsigned long)b, order);
89291 + __ClearPageSlab(sp);
89292 + page_mapcount_reset(sp);
89293 + sp->private = 0;
89294 + __free_pages(sp, order);
89295 }
89296
89297 /*
89298 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
89299
89300 /* Not enough space: must allocate a new page */
89301 if (!b) {
89302 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89303 - if (!b)
89304 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89305 + if (!sp)
89306 return NULL;
89307 - sp = virt_to_page(b);
89308 - __SetPageSlab(sp);
89309 + b = page_address(sp);
89310
89311 spin_lock_irqsave(&slob_lock, flags);
89312 sp->units = SLOB_UNITS(PAGE_SIZE);
89313 sp->freelist = b;
89314 + sp->private = 0;
89315 INIT_LIST_HEAD(&sp->list);
89316 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
89317 set_slob_page_free(sp, slob_list);
89318 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
89319 if (slob_page_free(sp))
89320 clear_slob_page_free(sp);
89321 spin_unlock_irqrestore(&slob_lock, flags);
89322 - __ClearPageSlab(sp);
89323 - page_mapcount_reset(sp);
89324 - slob_free_pages(b, 0);
89325 + slob_free_pages(sp, 0);
89326 return;
89327 }
89328
89329 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89330 + if (pax_sanitize_slab)
89331 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
89332 +#endif
89333 +
89334 if (!slob_page_free(sp)) {
89335 /* This slob page is about to become partially free. Easy! */
89336 sp->units = units;
89337 @@ -424,11 +431,10 @@ out:
89338 */
89339
89340 static __always_inline void *
89341 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89342 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
89343 {
89344 - unsigned int *m;
89345 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89346 - void *ret;
89347 + slob_t *m;
89348 + void *ret = NULL;
89349
89350 gfp &= gfp_allowed_mask;
89351
89352 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89353
89354 if (!m)
89355 return NULL;
89356 - *m = size;
89357 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
89358 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
89359 + m[0].units = size;
89360 + m[1].units = align;
89361 ret = (void *)m + align;
89362
89363 trace_kmalloc_node(caller, ret,
89364 size, size + align, gfp, node);
89365 } else {
89366 unsigned int order = get_order(size);
89367 + struct page *page;
89368
89369 if (likely(order))
89370 gfp |= __GFP_COMP;
89371 - ret = slob_new_pages(gfp, order, node);
89372 + page = slob_new_pages(gfp, order, node);
89373 + if (page) {
89374 + ret = page_address(page);
89375 + page->private = size;
89376 + }
89377
89378 trace_kmalloc_node(caller, ret,
89379 size, PAGE_SIZE << order, gfp, node);
89380 }
89381
89382 - kmemleak_alloc(ret, size, 1, gfp);
89383 + return ret;
89384 +}
89385 +
89386 +static __always_inline void *
89387 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89388 +{
89389 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89390 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
89391 +
89392 + if (!ZERO_OR_NULL_PTR(ret))
89393 + kmemleak_alloc(ret, size, 1, gfp);
89394 return ret;
89395 }
89396
89397 @@ -493,34 +517,112 @@ void kfree(const void *block)
89398 return;
89399 kmemleak_free(block);
89400
89401 + VM_BUG_ON(!virt_addr_valid(block));
89402 sp = virt_to_page(block);
89403 - if (PageSlab(sp)) {
89404 + VM_BUG_ON(!PageSlab(sp));
89405 + if (!sp->private) {
89406 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89407 - unsigned int *m = (unsigned int *)(block - align);
89408 - slob_free(m, *m + align);
89409 - } else
89410 + slob_t *m = (slob_t *)(block - align);
89411 + slob_free(m, m[0].units + align);
89412 + } else {
89413 + __ClearPageSlab(sp);
89414 + page_mapcount_reset(sp);
89415 + sp->private = 0;
89416 __free_pages(sp, compound_order(sp));
89417 + }
89418 }
89419 EXPORT_SYMBOL(kfree);
89420
89421 +bool is_usercopy_object(const void *ptr)
89422 +{
89423 + if (!slab_is_available())
89424 + return false;
89425 +
89426 + // PAX: TODO
89427 +
89428 + return false;
89429 +}
89430 +
89431 +#ifdef CONFIG_PAX_USERCOPY
89432 +const char *check_heap_object(const void *ptr, unsigned long n)
89433 +{
89434 + struct page *page;
89435 + const slob_t *free;
89436 + const void *base;
89437 + unsigned long flags;
89438 +
89439 + if (ZERO_OR_NULL_PTR(ptr))
89440 + return "<null>";
89441 +
89442 + if (!virt_addr_valid(ptr))
89443 + return NULL;
89444 +
89445 + page = virt_to_head_page(ptr);
89446 + if (!PageSlab(page))
89447 + return NULL;
89448 +
89449 + if (page->private) {
89450 + base = page;
89451 + if (base <= ptr && n <= page->private - (ptr - base))
89452 + return NULL;
89453 + return "<slob>";
89454 + }
89455 +
89456 + /* some tricky double walking to find the chunk */
89457 + spin_lock_irqsave(&slob_lock, flags);
89458 + base = (void *)((unsigned long)ptr & PAGE_MASK);
89459 + free = page->freelist;
89460 +
89461 + while (!slob_last(free) && (void *)free <= ptr) {
89462 + base = free + slob_units(free);
89463 + free = slob_next(free);
89464 + }
89465 +
89466 + while (base < (void *)free) {
89467 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
89468 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
89469 + int offset;
89470 +
89471 + if (ptr < base + align)
89472 + break;
89473 +
89474 + offset = ptr - base - align;
89475 + if (offset >= m) {
89476 + base += size;
89477 + continue;
89478 + }
89479 +
89480 + if (n > m - offset)
89481 + break;
89482 +
89483 + spin_unlock_irqrestore(&slob_lock, flags);
89484 + return NULL;
89485 + }
89486 +
89487 + spin_unlock_irqrestore(&slob_lock, flags);
89488 + return "<slob>";
89489 +}
89490 +#endif
89491 +
89492 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
89493 size_t ksize(const void *block)
89494 {
89495 struct page *sp;
89496 int align;
89497 - unsigned int *m;
89498 + slob_t *m;
89499
89500 BUG_ON(!block);
89501 if (unlikely(block == ZERO_SIZE_PTR))
89502 return 0;
89503
89504 sp = virt_to_page(block);
89505 - if (unlikely(!PageSlab(sp)))
89506 - return PAGE_SIZE << compound_order(sp);
89507 + VM_BUG_ON(!PageSlab(sp));
89508 + if (sp->private)
89509 + return sp->private;
89510
89511 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89512 - m = (unsigned int *)(block - align);
89513 - return SLOB_UNITS(*m) * SLOB_UNIT;
89514 + m = (slob_t *)(block - align);
89515 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
89516 }
89517 EXPORT_SYMBOL(ksize);
89518
89519 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
89520
89521 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
89522 {
89523 - void *b;
89524 + void *b = NULL;
89525
89526 flags &= gfp_allowed_mask;
89527
89528 lockdep_trace_alloc(flags);
89529
89530 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89531 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
89532 +#else
89533 if (c->size < PAGE_SIZE) {
89534 b = slob_alloc(c->size, flags, c->align, node);
89535 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
89536 SLOB_UNITS(c->size) * SLOB_UNIT,
89537 flags, node);
89538 } else {
89539 - b = slob_new_pages(flags, get_order(c->size), node);
89540 + struct page *sp;
89541 +
89542 + sp = slob_new_pages(flags, get_order(c->size), node);
89543 + if (sp) {
89544 + b = page_address(sp);
89545 + sp->private = c->size;
89546 + }
89547 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
89548 PAGE_SIZE << get_order(c->size),
89549 flags, node);
89550 }
89551 +#endif
89552
89553 if (b && c->ctor)
89554 c->ctor(b);
89555 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
89556
89557 static void __kmem_cache_free(void *b, int size)
89558 {
89559 - if (size < PAGE_SIZE)
89560 + struct page *sp;
89561 +
89562 + sp = virt_to_page(b);
89563 + BUG_ON(!PageSlab(sp));
89564 + if (!sp->private)
89565 slob_free(b, size);
89566 else
89567 - slob_free_pages(b, get_order(size));
89568 + slob_free_pages(sp, get_order(size));
89569 }
89570
89571 static void kmem_rcu_free(struct rcu_head *head)
89572 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
89573
89574 void kmem_cache_free(struct kmem_cache *c, void *b)
89575 {
89576 + int size = c->size;
89577 +
89578 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89579 + if (size + c->align < PAGE_SIZE) {
89580 + size += c->align;
89581 + b -= c->align;
89582 + }
89583 +#endif
89584 +
89585 kmemleak_free_recursive(b, c->flags);
89586 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
89587 struct slob_rcu *slob_rcu;
89588 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
89589 - slob_rcu->size = c->size;
89590 + slob_rcu = b + (size - sizeof(struct slob_rcu));
89591 + slob_rcu->size = size;
89592 call_rcu(&slob_rcu->head, kmem_rcu_free);
89593 } else {
89594 - __kmem_cache_free(b, c->size);
89595 + __kmem_cache_free(b, size);
89596 }
89597
89598 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89599 + trace_kfree(_RET_IP_, b);
89600 +#else
89601 trace_kmem_cache_free(_RET_IP_, b);
89602 +#endif
89603 +
89604 }
89605 EXPORT_SYMBOL(kmem_cache_free);
89606
89607 diff --git a/mm/slub.c b/mm/slub.c
89608 index e3ba1f2..bd45dac 100644
89609 --- a/mm/slub.c
89610 +++ b/mm/slub.c
89611 @@ -207,7 +207,7 @@ struct track {
89612
89613 enum track_item { TRACK_ALLOC, TRACK_FREE };
89614
89615 -#ifdef CONFIG_SYSFS
89616 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
89617 static int sysfs_slab_add(struct kmem_cache *);
89618 static int sysfs_slab_alias(struct kmem_cache *, const char *);
89619 static void sysfs_slab_remove(struct kmem_cache *);
89620 @@ -528,7 +528,7 @@ static void print_track(const char *s, struct track *t)
89621 if (!t->addr)
89622 return;
89623
89624 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
89625 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
89626 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
89627 #ifdef CONFIG_STACKTRACE
89628 {
89629 @@ -2609,6 +2609,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
89630
89631 slab_free_hook(s, x);
89632
89633 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89634 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
89635 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
89636 + if (s->ctor)
89637 + s->ctor(x);
89638 + }
89639 +#endif
89640 +
89641 redo:
89642 /*
89643 * Determine the currently cpus per cpu slab.
89644 @@ -2676,7 +2684,7 @@ static int slub_min_objects;
89645 * Merge control. If this is set then no merging of slab caches will occur.
89646 * (Could be removed. This was introduced to pacify the merge skeptics.)
89647 */
89648 -static int slub_nomerge;
89649 +static int slub_nomerge = 1;
89650
89651 /*
89652 * Calculate the order of allocation given an slab object size.
89653 @@ -2953,6 +2961,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
89654 s->inuse = size;
89655
89656 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
89657 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89658 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
89659 +#endif
89660 s->ctor)) {
89661 /*
89662 * Relocate free pointer after the object if it is not
89663 @@ -3298,6 +3309,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
89664 EXPORT_SYMBOL(__kmalloc_node);
89665 #endif
89666
89667 +bool is_usercopy_object(const void *ptr)
89668 +{
89669 + struct page *page;
89670 + struct kmem_cache *s;
89671 +
89672 + if (ZERO_OR_NULL_PTR(ptr))
89673 + return false;
89674 +
89675 + if (!slab_is_available())
89676 + return false;
89677 +
89678 + if (!virt_addr_valid(ptr))
89679 + return false;
89680 +
89681 + page = virt_to_head_page(ptr);
89682 +
89683 + if (!PageSlab(page))
89684 + return false;
89685 +
89686 + s = page->slab_cache;
89687 + return s->flags & SLAB_USERCOPY;
89688 +}
89689 +
89690 +#ifdef CONFIG_PAX_USERCOPY
89691 +const char *check_heap_object(const void *ptr, unsigned long n)
89692 +{
89693 + struct page *page;
89694 + struct kmem_cache *s;
89695 + unsigned long offset;
89696 +
89697 + if (ZERO_OR_NULL_PTR(ptr))
89698 + return "<null>";
89699 +
89700 + if (!virt_addr_valid(ptr))
89701 + return NULL;
89702 +
89703 + page = virt_to_head_page(ptr);
89704 +
89705 + if (!PageSlab(page))
89706 + return NULL;
89707 +
89708 + s = page->slab_cache;
89709 + if (!(s->flags & SLAB_USERCOPY))
89710 + return s->name;
89711 +
89712 + offset = (ptr - page_address(page)) % s->size;
89713 + if (offset <= s->object_size && n <= s->object_size - offset)
89714 + return NULL;
89715 +
89716 + return s->name;
89717 +}
89718 +#endif
89719 +
89720 size_t ksize(const void *object)
89721 {
89722 struct page *page;
89723 @@ -3362,6 +3426,7 @@ void kfree(const void *x)
89724 if (unlikely(ZERO_OR_NULL_PTR(x)))
89725 return;
89726
89727 + VM_BUG_ON(!virt_addr_valid(x));
89728 page = virt_to_head_page(x);
89729 if (unlikely(!PageSlab(page))) {
89730 BUG_ON(!PageCompound(page));
89731 @@ -3667,7 +3732,7 @@ static int slab_unmergeable(struct kmem_cache *s)
89732 /*
89733 * We may have set a slab to be unmergeable during bootstrap.
89734 */
89735 - if (s->refcount < 0)
89736 + if (atomic_read(&s->refcount) < 0)
89737 return 1;
89738
89739 return 0;
89740 @@ -3725,7 +3790,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89741
89742 s = find_mergeable(memcg, size, align, flags, name, ctor);
89743 if (s) {
89744 - s->refcount++;
89745 + atomic_inc(&s->refcount);
89746 /*
89747 * Adjust the object sizes so that we clear
89748 * the complete object on kzalloc.
89749 @@ -3734,7 +3799,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89750 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
89751
89752 if (sysfs_slab_alias(s, name)) {
89753 - s->refcount--;
89754 + atomic_dec(&s->refcount);
89755 s = NULL;
89756 }
89757 }
89758 @@ -3854,7 +3919,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
89759 }
89760 #endif
89761
89762 -#ifdef CONFIG_SYSFS
89763 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
89764 static int count_inuse(struct page *page)
89765 {
89766 return page->inuse;
89767 @@ -4241,12 +4306,12 @@ static void resiliency_test(void)
89768 validate_slab_cache(kmalloc_caches[9]);
89769 }
89770 #else
89771 -#ifdef CONFIG_SYSFS
89772 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
89773 static void resiliency_test(void) {};
89774 #endif
89775 #endif
89776
89777 -#ifdef CONFIG_SYSFS
89778 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
89779 enum slab_stat_type {
89780 SL_ALL, /* All slabs */
89781 SL_PARTIAL, /* Only partially allocated slabs */
89782 @@ -4490,7 +4555,7 @@ SLAB_ATTR_RO(ctor);
89783
89784 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
89785 {
89786 - return sprintf(buf, "%d\n", s->refcount - 1);
89787 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
89788 }
89789 SLAB_ATTR_RO(aliases);
89790
89791 @@ -4578,6 +4643,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
89792 SLAB_ATTR_RO(cache_dma);
89793 #endif
89794
89795 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89796 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
89797 +{
89798 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
89799 +}
89800 +SLAB_ATTR_RO(usercopy);
89801 +#endif
89802 +
89803 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
89804 {
89805 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
89806 @@ -4912,6 +4985,9 @@ static struct attribute *slab_attrs[] = {
89807 #ifdef CONFIG_ZONE_DMA
89808 &cache_dma_attr.attr,
89809 #endif
89810 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89811 + &usercopy_attr.attr,
89812 +#endif
89813 #ifdef CONFIG_NUMA
89814 &remote_node_defrag_ratio_attr.attr,
89815 #endif
89816 @@ -5143,6 +5219,7 @@ static char *create_unique_id(struct kmem_cache *s)
89817 return name;
89818 }
89819
89820 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
89821 static int sysfs_slab_add(struct kmem_cache *s)
89822 {
89823 int err;
89824 @@ -5166,7 +5243,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
89825 }
89826
89827 s->kobj.kset = slab_kset;
89828 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
89829 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
89830 if (err) {
89831 kobject_put(&s->kobj);
89832 return err;
89833 @@ -5200,6 +5277,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
89834 kobject_del(&s->kobj);
89835 kobject_put(&s->kobj);
89836 }
89837 +#endif
89838
89839 /*
89840 * Need to buffer aliases during bootup until sysfs becomes
89841 @@ -5213,6 +5291,7 @@ struct saved_alias {
89842
89843 static struct saved_alias *alias_list;
89844
89845 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
89846 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
89847 {
89848 struct saved_alias *al;
89849 @@ -5235,6 +5314,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
89850 alias_list = al;
89851 return 0;
89852 }
89853 +#endif
89854
89855 static int __init slab_sysfs_init(void)
89856 {
89857 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
89858 index 27eeab3..7c3f7f2 100644
89859 --- a/mm/sparse-vmemmap.c
89860 +++ b/mm/sparse-vmemmap.c
89861 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
89862 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
89863 if (!p)
89864 return NULL;
89865 - pud_populate(&init_mm, pud, p);
89866 + pud_populate_kernel(&init_mm, pud, p);
89867 }
89868 return pud;
89869 }
89870 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
89871 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
89872 if (!p)
89873 return NULL;
89874 - pgd_populate(&init_mm, pgd, p);
89875 + pgd_populate_kernel(&init_mm, pgd, p);
89876 }
89877 return pgd;
89878 }
89879 diff --git a/mm/sparse.c b/mm/sparse.c
89880 index 308d503..3dbbd04 100644
89881 --- a/mm/sparse.c
89882 +++ b/mm/sparse.c
89883 @@ -764,7 +764,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
89884
89885 for (i = 0; i < PAGES_PER_SECTION; i++) {
89886 if (PageHWPoison(&memmap[i])) {
89887 - atomic_long_sub(1, &num_poisoned_pages);
89888 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
89889 ClearPageHWPoison(&memmap[i]);
89890 }
89891 }
89892 diff --git a/mm/swap.c b/mm/swap.c
89893 index c899502..d4dc2cd 100644
89894 --- a/mm/swap.c
89895 +++ b/mm/swap.c
89896 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
89897
89898 __page_cache_release(page);
89899 dtor = get_compound_page_dtor(page);
89900 + if (!PageHuge(page))
89901 + BUG_ON(dtor != free_compound_page);
89902 (*dtor)(page);
89903 }
89904
89905 diff --git a/mm/swapfile.c b/mm/swapfile.c
89906 index 6cf2e60..d204b3e 100644
89907 --- a/mm/swapfile.c
89908 +++ b/mm/swapfile.c
89909 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
89910
89911 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
89912 /* Activity counter to indicate that a swapon or swapoff has occurred */
89913 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
89914 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
89915
89916 static inline unsigned char swap_count(unsigned char ent)
89917 {
89918 @@ -1699,7 +1699,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
89919 }
89920 filp_close(swap_file, NULL);
89921 err = 0;
89922 - atomic_inc(&proc_poll_event);
89923 + atomic_inc_unchecked(&proc_poll_event);
89924 wake_up_interruptible(&proc_poll_wait);
89925
89926 out_dput:
89927 @@ -1716,8 +1716,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
89928
89929 poll_wait(file, &proc_poll_wait, wait);
89930
89931 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
89932 - seq->poll_event = atomic_read(&proc_poll_event);
89933 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
89934 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
89935 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
89936 }
89937
89938 @@ -1815,7 +1815,7 @@ static int swaps_open(struct inode *inode, struct file *file)
89939 return ret;
89940
89941 seq = file->private_data;
89942 - seq->poll_event = atomic_read(&proc_poll_event);
89943 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
89944 return 0;
89945 }
89946
89947 @@ -2203,7 +2203,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
89948 (frontswap_map) ? "FS" : "");
89949
89950 mutex_unlock(&swapon_mutex);
89951 - atomic_inc(&proc_poll_event);
89952 + atomic_inc_unchecked(&proc_poll_event);
89953 wake_up_interruptible(&proc_poll_wait);
89954
89955 if (S_ISREG(inode->i_mode))
89956 diff --git a/mm/util.c b/mm/util.c
89957 index 7441c41..c3de793 100644
89958 --- a/mm/util.c
89959 +++ b/mm/util.c
89960 @@ -294,6 +294,12 @@ done:
89961 void arch_pick_mmap_layout(struct mm_struct *mm)
89962 {
89963 mm->mmap_base = TASK_UNMAPPED_BASE;
89964 +
89965 +#ifdef CONFIG_PAX_RANDMMAP
89966 + if (mm->pax_flags & MF_PAX_RANDMMAP)
89967 + mm->mmap_base += mm->delta_mmap;
89968 +#endif
89969 +
89970 mm->get_unmapped_area = arch_get_unmapped_area;
89971 }
89972 #endif
89973 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
89974 index 13a5495..6707d97 100644
89975 --- a/mm/vmalloc.c
89976 +++ b/mm/vmalloc.c
89977 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
89978
89979 pte = pte_offset_kernel(pmd, addr);
89980 do {
89981 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
89982 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
89983 +
89984 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
89985 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
89986 + BUG_ON(!pte_exec(*pte));
89987 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
89988 + continue;
89989 + }
89990 +#endif
89991 +
89992 + {
89993 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
89994 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
89995 + }
89996 } while (pte++, addr += PAGE_SIZE, addr != end);
89997 }
89998
89999 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
90000 pte = pte_alloc_kernel(pmd, addr);
90001 if (!pte)
90002 return -ENOMEM;
90003 +
90004 + pax_open_kernel();
90005 do {
90006 struct page *page = pages[*nr];
90007
90008 - if (WARN_ON(!pte_none(*pte)))
90009 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90010 + if (pgprot_val(prot) & _PAGE_NX)
90011 +#endif
90012 +
90013 + if (!pte_none(*pte)) {
90014 + pax_close_kernel();
90015 + WARN_ON(1);
90016 return -EBUSY;
90017 - if (WARN_ON(!page))
90018 + }
90019 + if (!page) {
90020 + pax_close_kernel();
90021 + WARN_ON(1);
90022 return -ENOMEM;
90023 + }
90024 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
90025 (*nr)++;
90026 } while (pte++, addr += PAGE_SIZE, addr != end);
90027 + pax_close_kernel();
90028 return 0;
90029 }
90030
90031 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
90032 pmd_t *pmd;
90033 unsigned long next;
90034
90035 - pmd = pmd_alloc(&init_mm, pud, addr);
90036 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
90037 if (!pmd)
90038 return -ENOMEM;
90039 do {
90040 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
90041 pud_t *pud;
90042 unsigned long next;
90043
90044 - pud = pud_alloc(&init_mm, pgd, addr);
90045 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
90046 if (!pud)
90047 return -ENOMEM;
90048 do {
90049 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
90050 if (addr >= MODULES_VADDR && addr < MODULES_END)
90051 return 1;
90052 #endif
90053 +
90054 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90055 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
90056 + return 1;
90057 +#endif
90058 +
90059 return is_vmalloc_addr(x);
90060 }
90061
90062 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
90063
90064 if (!pgd_none(*pgd)) {
90065 pud_t *pud = pud_offset(pgd, addr);
90066 +#ifdef CONFIG_X86
90067 + if (!pud_large(*pud))
90068 +#endif
90069 if (!pud_none(*pud)) {
90070 pmd_t *pmd = pmd_offset(pud, addr);
90071 +#ifdef CONFIG_X86
90072 + if (!pmd_large(*pmd))
90073 +#endif
90074 if (!pmd_none(*pmd)) {
90075 pte_t *ptep, pte;
90076
90077 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
90078 * Allocate a region of KVA of the specified size and alignment, within the
90079 * vstart and vend.
90080 */
90081 -static struct vmap_area *alloc_vmap_area(unsigned long size,
90082 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
90083 unsigned long align,
90084 unsigned long vstart, unsigned long vend,
90085 int node, gfp_t gfp_mask)
90086 @@ -1308,6 +1344,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
90087 struct vm_struct *area;
90088
90089 BUG_ON(in_interrupt());
90090 +
90091 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90092 + if (flags & VM_KERNEXEC) {
90093 + if (start != VMALLOC_START || end != VMALLOC_END)
90094 + return NULL;
90095 + start = (unsigned long)MODULES_EXEC_VADDR;
90096 + end = (unsigned long)MODULES_EXEC_END;
90097 + }
90098 +#endif
90099 +
90100 if (flags & VM_IOREMAP)
90101 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
90102
90103 @@ -1533,6 +1579,11 @@ void *vmap(struct page **pages, unsigned int count,
90104 if (count > totalram_pages)
90105 return NULL;
90106
90107 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90108 + if (!(pgprot_val(prot) & _PAGE_NX))
90109 + flags |= VM_KERNEXEC;
90110 +#endif
90111 +
90112 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
90113 __builtin_return_address(0));
90114 if (!area)
90115 @@ -1634,6 +1685,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
90116 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
90117 goto fail;
90118
90119 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90120 + if (!(pgprot_val(prot) & _PAGE_NX))
90121 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
90122 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
90123 + else
90124 +#endif
90125 +
90126 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
90127 start, end, node, gfp_mask, caller);
90128 if (!area)
90129 @@ -1810,10 +1868,9 @@ EXPORT_SYMBOL(vzalloc_node);
90130 * For tight control over page level allocator and protection flags
90131 * use __vmalloc() instead.
90132 */
90133 -
90134 void *vmalloc_exec(unsigned long size)
90135 {
90136 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
90137 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
90138 NUMA_NO_NODE, __builtin_return_address(0));
90139 }
90140
90141 @@ -2120,6 +2177,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
90142 {
90143 struct vm_struct *area;
90144
90145 + BUG_ON(vma->vm_mirror);
90146 +
90147 size = PAGE_ALIGN(size);
90148
90149 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
90150 @@ -2605,7 +2664,11 @@ static int s_show(struct seq_file *m, void *p)
90151 v->addr, v->addr + v->size, v->size);
90152
90153 if (v->caller)
90154 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90155 + seq_printf(m, " %pK", v->caller);
90156 +#else
90157 seq_printf(m, " %pS", v->caller);
90158 +#endif
90159
90160 if (v->nr_pages)
90161 seq_printf(m, " pages=%d", v->nr_pages);
90162 diff --git a/mm/vmstat.c b/mm/vmstat.c
90163 index 20c2ef4..15e7ab7 100644
90164 --- a/mm/vmstat.c
90165 +++ b/mm/vmstat.c
90166 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
90167 *
90168 * vm_stat contains the global counters
90169 */
90170 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90171 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90172 EXPORT_SYMBOL(vm_stat);
90173
90174 #ifdef CONFIG_SMP
90175 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
90176 v = p->vm_stat_diff[i];
90177 p->vm_stat_diff[i] = 0;
90178 local_irq_restore(flags);
90179 - atomic_long_add(v, &zone->vm_stat[i]);
90180 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90181 global_diff[i] += v;
90182 #ifdef CONFIG_NUMA
90183 /* 3 seconds idle till flush */
90184 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
90185
90186 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
90187 if (global_diff[i])
90188 - atomic_long_add(global_diff[i], &vm_stat[i]);
90189 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
90190 }
90191
90192 /*
90193 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
90194 if (pset->vm_stat_diff[i]) {
90195 int v = pset->vm_stat_diff[i];
90196 pset->vm_stat_diff[i] = 0;
90197 - atomic_long_add(v, &zone->vm_stat[i]);
90198 - atomic_long_add(v, &vm_stat[i]);
90199 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90200 + atomic_long_add_unchecked(v, &vm_stat[i]);
90201 }
90202 }
90203 #endif
90204 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
90205 start_cpu_timer(cpu);
90206 #endif
90207 #ifdef CONFIG_PROC_FS
90208 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
90209 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
90210 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
90211 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
90212 + {
90213 + mode_t gr_mode = S_IRUGO;
90214 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
90215 + gr_mode = S_IRUSR;
90216 +#endif
90217 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
90218 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
90219 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
90220 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
90221 +#else
90222 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
90223 +#endif
90224 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
90225 + }
90226 #endif
90227 return 0;
90228 }
90229 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
90230 index 2fb2d88..8c06e40 100644
90231 --- a/net/8021q/vlan.c
90232 +++ b/net/8021q/vlan.c
90233 @@ -469,7 +469,7 @@ out:
90234 return NOTIFY_DONE;
90235 }
90236
90237 -static struct notifier_block vlan_notifier_block __read_mostly = {
90238 +static struct notifier_block vlan_notifier_block = {
90239 .notifier_call = vlan_device_event,
90240 };
90241
90242 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
90243 err = -EPERM;
90244 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
90245 break;
90246 - if ((args.u.name_type >= 0) &&
90247 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
90248 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
90249 struct vlan_net *vn;
90250
90251 vn = net_generic(net, vlan_net_id);
90252 diff --git a/net/9p/mod.c b/net/9p/mod.c
90253 index 6ab36ae..6f1841b 100644
90254 --- a/net/9p/mod.c
90255 +++ b/net/9p/mod.c
90256 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
90257 void v9fs_register_trans(struct p9_trans_module *m)
90258 {
90259 spin_lock(&v9fs_trans_lock);
90260 - list_add_tail(&m->list, &v9fs_trans_list);
90261 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
90262 spin_unlock(&v9fs_trans_lock);
90263 }
90264 EXPORT_SYMBOL(v9fs_register_trans);
90265 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
90266 void v9fs_unregister_trans(struct p9_trans_module *m)
90267 {
90268 spin_lock(&v9fs_trans_lock);
90269 - list_del_init(&m->list);
90270 + pax_list_del_init((struct list_head *)&m->list);
90271 spin_unlock(&v9fs_trans_lock);
90272 }
90273 EXPORT_SYMBOL(v9fs_unregister_trans);
90274 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
90275 index 3ffda1b..fceac96 100644
90276 --- a/net/9p/trans_fd.c
90277 +++ b/net/9p/trans_fd.c
90278 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
90279 oldfs = get_fs();
90280 set_fs(get_ds());
90281 /* The cast to a user pointer is valid due to the set_fs() */
90282 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
90283 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
90284 set_fs(oldfs);
90285
90286 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
90287 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
90288 index 876fbe8..8bbea9f 100644
90289 --- a/net/atm/atm_misc.c
90290 +++ b/net/atm/atm_misc.c
90291 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
90292 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
90293 return 1;
90294 atm_return(vcc, truesize);
90295 - atomic_inc(&vcc->stats->rx_drop);
90296 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90297 return 0;
90298 }
90299 EXPORT_SYMBOL(atm_charge);
90300 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
90301 }
90302 }
90303 atm_return(vcc, guess);
90304 - atomic_inc(&vcc->stats->rx_drop);
90305 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90306 return NULL;
90307 }
90308 EXPORT_SYMBOL(atm_alloc_charge);
90309 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
90310
90311 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90312 {
90313 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90314 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90315 __SONET_ITEMS
90316 #undef __HANDLE_ITEM
90317 }
90318 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
90319
90320 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90321 {
90322 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90323 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
90324 __SONET_ITEMS
90325 #undef __HANDLE_ITEM
90326 }
90327 diff --git a/net/atm/lec.h b/net/atm/lec.h
90328 index 4149db1..f2ab682 100644
90329 --- a/net/atm/lec.h
90330 +++ b/net/atm/lec.h
90331 @@ -48,7 +48,7 @@ struct lane2_ops {
90332 const u8 *tlvs, u32 sizeoftlvs);
90333 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
90334 const u8 *tlvs, u32 sizeoftlvs);
90335 -};
90336 +} __no_const;
90337
90338 /*
90339 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
90340 diff --git a/net/atm/proc.c b/net/atm/proc.c
90341 index bbb6461..cf04016 100644
90342 --- a/net/atm/proc.c
90343 +++ b/net/atm/proc.c
90344 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
90345 const struct k_atm_aal_stats *stats)
90346 {
90347 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
90348 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
90349 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
90350 - atomic_read(&stats->rx_drop));
90351 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
90352 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
90353 + atomic_read_unchecked(&stats->rx_drop));
90354 }
90355
90356 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
90357 diff --git a/net/atm/resources.c b/net/atm/resources.c
90358 index 0447d5d..3cf4728 100644
90359 --- a/net/atm/resources.c
90360 +++ b/net/atm/resources.c
90361 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
90362 static void copy_aal_stats(struct k_atm_aal_stats *from,
90363 struct atm_aal_stats *to)
90364 {
90365 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90366 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90367 __AAL_STAT_ITEMS
90368 #undef __HANDLE_ITEM
90369 }
90370 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
90371 static void subtract_aal_stats(struct k_atm_aal_stats *from,
90372 struct atm_aal_stats *to)
90373 {
90374 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90375 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
90376 __AAL_STAT_ITEMS
90377 #undef __HANDLE_ITEM
90378 }
90379 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
90380 index 919a5ce..cc6b444 100644
90381 --- a/net/ax25/sysctl_net_ax25.c
90382 +++ b/net/ax25/sysctl_net_ax25.c
90383 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
90384 {
90385 char path[sizeof("net/ax25/") + IFNAMSIZ];
90386 int k;
90387 - struct ctl_table *table;
90388 + ctl_table_no_const *table;
90389
90390 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
90391 if (!table)
90392 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
90393 index 62da527..aa27535 100644
90394 --- a/net/batman-adv/bat_iv_ogm.c
90395 +++ b/net/batman-adv/bat_iv_ogm.c
90396 @@ -120,7 +120,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
90397
90398 /* randomize initial seqno to avoid collision */
90399 get_random_bytes(&random_seqno, sizeof(random_seqno));
90400 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90401 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90402
90403 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
90404 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
90405 @@ -701,9 +701,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
90406 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
90407
90408 /* change sequence number to network order */
90409 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
90410 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
90411 batadv_ogm_packet->seqno = htonl(seqno);
90412 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
90413 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
90414
90415 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
90416 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
90417 @@ -1109,7 +1109,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
90418 return;
90419
90420 /* could be changed by schedule_own_packet() */
90421 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
90422 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
90423
90424 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
90425 has_directlink_flag = 1;
90426 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
90427 index c478e6b..469fd2f 100644
90428 --- a/net/batman-adv/hard-interface.c
90429 +++ b/net/batman-adv/hard-interface.c
90430 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
90431 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
90432 dev_add_pack(&hard_iface->batman_adv_ptype);
90433
90434 - atomic_set(&hard_iface->frag_seqno, 1);
90435 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
90436 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
90437 hard_iface->net_dev->name);
90438
90439 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
90440 index 0f04e1c..9c0ac11 100644
90441 --- a/net/batman-adv/soft-interface.c
90442 +++ b/net/batman-adv/soft-interface.c
90443 @@ -260,7 +260,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
90444 primary_if->net_dev->dev_addr, ETH_ALEN);
90445
90446 /* set broadcast sequence number */
90447 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
90448 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
90449 bcast_packet->seqno = htonl(seqno);
90450
90451 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
90452 @@ -479,7 +479,7 @@ static int batadv_softif_init_late(struct net_device *dev)
90453 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
90454
90455 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
90456 - atomic_set(&bat_priv->bcast_seqno, 1);
90457 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
90458 atomic_set(&bat_priv->tt.vn, 0);
90459 atomic_set(&bat_priv->tt.local_changes, 0);
90460 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
90461 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
90462 index b2c94e1..3d47e07 100644
90463 --- a/net/batman-adv/types.h
90464 +++ b/net/batman-adv/types.h
90465 @@ -51,7 +51,7 @@
90466 struct batadv_hard_iface_bat_iv {
90467 unsigned char *ogm_buff;
90468 int ogm_buff_len;
90469 - atomic_t ogm_seqno;
90470 + atomic_unchecked_t ogm_seqno;
90471 };
90472
90473 /**
90474 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
90475 int16_t if_num;
90476 char if_status;
90477 struct net_device *net_dev;
90478 - atomic_t frag_seqno;
90479 + atomic_unchecked_t frag_seqno;
90480 uint8_t num_bcasts;
90481 struct kobject *hardif_obj;
90482 atomic_t refcount;
90483 @@ -560,7 +560,7 @@ struct batadv_priv {
90484 #ifdef CONFIG_BATMAN_ADV_DEBUG
90485 atomic_t log_level;
90486 #endif
90487 - atomic_t bcast_seqno;
90488 + atomic_unchecked_t bcast_seqno;
90489 atomic_t bcast_queue_left;
90490 atomic_t batman_queue_left;
90491 char num_ifaces;
90492 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
90493 index 857e1b8..5ad07b2 100644
90494 --- a/net/batman-adv/unicast.c
90495 +++ b/net/batman-adv/unicast.c
90496 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
90497 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
90498 frag2->flags = large_tail;
90499
90500 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
90501 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
90502 frag1->seqno = htons(seqno - 1);
90503 frag2->seqno = htons(seqno);
90504
90505 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
90506 index 9bd7d95..6c4884f 100644
90507 --- a/net/bluetooth/hci_sock.c
90508 +++ b/net/bluetooth/hci_sock.c
90509 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
90510 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
90511 }
90512
90513 - len = min_t(unsigned int, len, sizeof(uf));
90514 + len = min((size_t)len, sizeof(uf));
90515 if (copy_from_user(&uf, optval, len)) {
90516 err = -EFAULT;
90517 break;
90518 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
90519 index 8c3499b..2661c6a 100644
90520 --- a/net/bluetooth/l2cap_core.c
90521 +++ b/net/bluetooth/l2cap_core.c
90522 @@ -3510,8 +3510,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
90523 break;
90524
90525 case L2CAP_CONF_RFC:
90526 - if (olen == sizeof(rfc))
90527 - memcpy(&rfc, (void *)val, olen);
90528 + if (olen != sizeof(rfc))
90529 + break;
90530 +
90531 + memcpy(&rfc, (void *)val, olen);
90532
90533 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
90534 rfc.mode != chan->mode)
90535 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
90536 index 0098af8..fb5a31f 100644
90537 --- a/net/bluetooth/l2cap_sock.c
90538 +++ b/net/bluetooth/l2cap_sock.c
90539 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
90540 struct sock *sk = sock->sk;
90541 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
90542 struct l2cap_options opts;
90543 - int len, err = 0;
90544 + int err = 0;
90545 + size_t len = optlen;
90546 u32 opt;
90547
90548 BT_DBG("sk %p", sk);
90549 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
90550 opts.max_tx = chan->max_tx;
90551 opts.txwin_size = chan->tx_win;
90552
90553 - len = min_t(unsigned int, sizeof(opts), optlen);
90554 + len = min(sizeof(opts), len);
90555 if (copy_from_user((char *) &opts, optval, len)) {
90556 err = -EFAULT;
90557 break;
90558 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
90559 struct bt_security sec;
90560 struct bt_power pwr;
90561 struct l2cap_conn *conn;
90562 - int len, err = 0;
90563 + int err = 0;
90564 + size_t len = optlen;
90565 u32 opt;
90566
90567 BT_DBG("sk %p", sk);
90568 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
90569
90570 sec.level = BT_SECURITY_LOW;
90571
90572 - len = min_t(unsigned int, sizeof(sec), optlen);
90573 + len = min(sizeof(sec), len);
90574 if (copy_from_user((char *) &sec, optval, len)) {
90575 err = -EFAULT;
90576 break;
90577 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
90578
90579 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
90580
90581 - len = min_t(unsigned int, sizeof(pwr), optlen);
90582 + len = min(sizeof(pwr), len);
90583 if (copy_from_user((char *) &pwr, optval, len)) {
90584 err = -EFAULT;
90585 break;
90586 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
90587 index 30b3721..c1bd0a0 100644
90588 --- a/net/bluetooth/rfcomm/sock.c
90589 +++ b/net/bluetooth/rfcomm/sock.c
90590 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
90591 struct sock *sk = sock->sk;
90592 struct bt_security sec;
90593 int err = 0;
90594 - size_t len;
90595 + size_t len = optlen;
90596 u32 opt;
90597
90598 BT_DBG("sk %p", sk);
90599 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
90600
90601 sec.level = BT_SECURITY_LOW;
90602
90603 - len = min_t(unsigned int, sizeof(sec), optlen);
90604 + len = min(sizeof(sec), len);
90605 if (copy_from_user((char *) &sec, optval, len)) {
90606 err = -EFAULT;
90607 break;
90608 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
90609 index b6e44ad..5b0d514 100644
90610 --- a/net/bluetooth/rfcomm/tty.c
90611 +++ b/net/bluetooth/rfcomm/tty.c
90612 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
90613 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
90614
90615 spin_lock_irqsave(&dev->port.lock, flags);
90616 - if (dev->port.count > 0) {
90617 + if (atomic_read(&dev->port.count) > 0) {
90618 spin_unlock_irqrestore(&dev->port.lock, flags);
90619 return;
90620 }
90621 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
90622 return -ENODEV;
90623
90624 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
90625 - dev->channel, dev->port.count);
90626 + dev->channel, atomic_read(&dev->port.count));
90627
90628 spin_lock_irqsave(&dev->port.lock, flags);
90629 - if (++dev->port.count > 1) {
90630 + if (atomic_inc_return(&dev->port.count) > 1) {
90631 spin_unlock_irqrestore(&dev->port.lock, flags);
90632 return 0;
90633 }
90634 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
90635 return;
90636
90637 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
90638 - dev->port.count);
90639 + atomic_read(&dev->port.count));
90640
90641 spin_lock_irqsave(&dev->port.lock, flags);
90642 - if (!--dev->port.count) {
90643 + if (!atomic_dec_return(&dev->port.count)) {
90644 spin_unlock_irqrestore(&dev->port.lock, flags);
90645 if (dev->tty_dev->parent)
90646 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
90647 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
90648 index ac78024..161a80c 100644
90649 --- a/net/bridge/netfilter/ebtables.c
90650 +++ b/net/bridge/netfilter/ebtables.c
90651 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
90652 tmp.valid_hooks = t->table->valid_hooks;
90653 }
90654 mutex_unlock(&ebt_mutex);
90655 - if (copy_to_user(user, &tmp, *len) != 0){
90656 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
90657 BUGPRINT("c2u Didn't work\n");
90658 ret = -EFAULT;
90659 break;
90660 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
90661 goto out;
90662 tmp.valid_hooks = t->valid_hooks;
90663
90664 - if (copy_to_user(user, &tmp, *len) != 0) {
90665 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
90666 ret = -EFAULT;
90667 break;
90668 }
90669 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
90670 tmp.entries_size = t->table->entries_size;
90671 tmp.valid_hooks = t->table->valid_hooks;
90672
90673 - if (copy_to_user(user, &tmp, *len) != 0) {
90674 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
90675 ret = -EFAULT;
90676 break;
90677 }
90678 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
90679 index 2bd4b58..0dc30a1 100644
90680 --- a/net/caif/cfctrl.c
90681 +++ b/net/caif/cfctrl.c
90682 @@ -10,6 +10,7 @@
90683 #include <linux/spinlock.h>
90684 #include <linux/slab.h>
90685 #include <linux/pkt_sched.h>
90686 +#include <linux/sched.h>
90687 #include <net/caif/caif_layer.h>
90688 #include <net/caif/cfpkt.h>
90689 #include <net/caif/cfctrl.h>
90690 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
90691 memset(&dev_info, 0, sizeof(dev_info));
90692 dev_info.id = 0xff;
90693 cfsrvl_init(&this->serv, 0, &dev_info, false);
90694 - atomic_set(&this->req_seq_no, 1);
90695 - atomic_set(&this->rsp_seq_no, 1);
90696 + atomic_set_unchecked(&this->req_seq_no, 1);
90697 + atomic_set_unchecked(&this->rsp_seq_no, 1);
90698 this->serv.layer.receive = cfctrl_recv;
90699 sprintf(this->serv.layer.name, "ctrl");
90700 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
90701 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
90702 struct cfctrl_request_info *req)
90703 {
90704 spin_lock_bh(&ctrl->info_list_lock);
90705 - atomic_inc(&ctrl->req_seq_no);
90706 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
90707 + atomic_inc_unchecked(&ctrl->req_seq_no);
90708 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
90709 list_add_tail(&req->list, &ctrl->list);
90710 spin_unlock_bh(&ctrl->info_list_lock);
90711 }
90712 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
90713 if (p != first)
90714 pr_warn("Requests are not received in order\n");
90715
90716 - atomic_set(&ctrl->rsp_seq_no,
90717 + atomic_set_unchecked(&ctrl->rsp_seq_no,
90718 p->sequence_no);
90719 list_del(&p->list);
90720 goto out;
90721 diff --git a/net/can/af_can.c b/net/can/af_can.c
90722 index 3ab8dd2..b9aef13 100644
90723 --- a/net/can/af_can.c
90724 +++ b/net/can/af_can.c
90725 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
90726 };
90727
90728 /* notifier block for netdevice event */
90729 -static struct notifier_block can_netdev_notifier __read_mostly = {
90730 +static struct notifier_block can_netdev_notifier = {
90731 .notifier_call = can_notifier,
90732 };
90733
90734 diff --git a/net/can/gw.c b/net/can/gw.c
90735 index 2f291f9..98c986a 100644
90736 --- a/net/can/gw.c
90737 +++ b/net/can/gw.c
90738 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
90739 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
90740
90741 static HLIST_HEAD(cgw_list);
90742 -static struct notifier_block notifier;
90743
90744 static struct kmem_cache *cgw_cache __read_mostly;
90745
90746 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
90747 return err;
90748 }
90749
90750 +static struct notifier_block notifier = {
90751 + .notifier_call = cgw_notifier
90752 +};
90753 +
90754 static __init int cgw_module_init(void)
90755 {
90756 /* sanitize given module parameter */
90757 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
90758 return -ENOMEM;
90759
90760 /* set notifier */
90761 - notifier.notifier_call = cgw_notifier;
90762 register_netdevice_notifier(&notifier);
90763
90764 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
90765 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
90766 index eb0a46a..5f3bae8 100644
90767 --- a/net/ceph/messenger.c
90768 +++ b/net/ceph/messenger.c
90769 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
90770 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
90771
90772 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
90773 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
90774 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
90775
90776 static struct page *zero_page; /* used in certain error cases */
90777
90778 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
90779 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
90780 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
90781
90782 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
90783 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
90784 s = addr_str[i];
90785
90786 switch (ss->ss_family) {
90787 diff --git a/net/compat.c b/net/compat.c
90788 index f0a1ba6..0541331 100644
90789 --- a/net/compat.c
90790 +++ b/net/compat.c
90791 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
90792 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
90793 __get_user(kmsg->msg_flags, &umsg->msg_flags))
90794 return -EFAULT;
90795 - kmsg->msg_name = compat_ptr(tmp1);
90796 - kmsg->msg_iov = compat_ptr(tmp2);
90797 - kmsg->msg_control = compat_ptr(tmp3);
90798 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
90799 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
90800 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
90801 return 0;
90802 }
90803
90804 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
90805
90806 if (kern_msg->msg_namelen) {
90807 if (mode == VERIFY_READ) {
90808 - int err = move_addr_to_kernel(kern_msg->msg_name,
90809 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
90810 kern_msg->msg_namelen,
90811 kern_address);
90812 if (err < 0)
90813 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
90814 kern_msg->msg_name = NULL;
90815
90816 tot_len = iov_from_user_compat_to_kern(kern_iov,
90817 - (struct compat_iovec __user *)kern_msg->msg_iov,
90818 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
90819 kern_msg->msg_iovlen);
90820 if (tot_len >= 0)
90821 kern_msg->msg_iov = kern_iov;
90822 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
90823
90824 #define CMSG_COMPAT_FIRSTHDR(msg) \
90825 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
90826 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
90827 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
90828 (struct compat_cmsghdr __user *)NULL)
90829
90830 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
90831 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
90832 (ucmlen) <= (unsigned long) \
90833 ((mhdr)->msg_controllen - \
90834 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
90835 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
90836
90837 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
90838 struct compat_cmsghdr __user *cmsg, int cmsg_len)
90839 {
90840 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
90841 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
90842 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
90843 msg->msg_controllen)
90844 return NULL;
90845 return (struct compat_cmsghdr __user *)ptr;
90846 @@ -219,7 +219,7 @@ Efault:
90847
90848 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
90849 {
90850 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
90851 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
90852 struct compat_cmsghdr cmhdr;
90853 struct compat_timeval ctv;
90854 struct compat_timespec cts[3];
90855 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
90856
90857 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
90858 {
90859 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
90860 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
90861 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
90862 int fdnum = scm->fp->count;
90863 struct file **fp = scm->fp->fp;
90864 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
90865 return -EFAULT;
90866 old_fs = get_fs();
90867 set_fs(KERNEL_DS);
90868 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
90869 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
90870 set_fs(old_fs);
90871
90872 return err;
90873 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
90874 len = sizeof(ktime);
90875 old_fs = get_fs();
90876 set_fs(KERNEL_DS);
90877 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
90878 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
90879 set_fs(old_fs);
90880
90881 if (!err) {
90882 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
90883 case MCAST_JOIN_GROUP:
90884 case MCAST_LEAVE_GROUP:
90885 {
90886 - struct compat_group_req __user *gr32 = (void *)optval;
90887 + struct compat_group_req __user *gr32 = (void __user *)optval;
90888 struct group_req __user *kgr =
90889 compat_alloc_user_space(sizeof(struct group_req));
90890 u32 interface;
90891 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
90892 case MCAST_BLOCK_SOURCE:
90893 case MCAST_UNBLOCK_SOURCE:
90894 {
90895 - struct compat_group_source_req __user *gsr32 = (void *)optval;
90896 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
90897 struct group_source_req __user *kgsr = compat_alloc_user_space(
90898 sizeof(struct group_source_req));
90899 u32 interface;
90900 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
90901 }
90902 case MCAST_MSFILTER:
90903 {
90904 - struct compat_group_filter __user *gf32 = (void *)optval;
90905 + struct compat_group_filter __user *gf32 = (void __user *)optval;
90906 struct group_filter __user *kgf;
90907 u32 interface, fmode, numsrc;
90908
90909 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
90910 char __user *optval, int __user *optlen,
90911 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
90912 {
90913 - struct compat_group_filter __user *gf32 = (void *)optval;
90914 + struct compat_group_filter __user *gf32 = (void __user *)optval;
90915 struct group_filter __user *kgf;
90916 int __user *koptlen;
90917 u32 interface, fmode, numsrc;
90918 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
90919
90920 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
90921 return -EINVAL;
90922 - if (copy_from_user(a, args, nas[call]))
90923 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
90924 return -EFAULT;
90925 a0 = a[0];
90926 a1 = a[1];
90927 diff --git a/net/core/datagram.c b/net/core/datagram.c
90928 index 8ab48cd..57b1a80 100644
90929 --- a/net/core/datagram.c
90930 +++ b/net/core/datagram.c
90931 @@ -300,7 +300,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
90932 }
90933
90934 kfree_skb(skb);
90935 - atomic_inc(&sk->sk_drops);
90936 + atomic_inc_unchecked(&sk->sk_drops);
90937 sk_mem_reclaim_partial(sk);
90938
90939 return err;
90940 diff --git a/net/core/dev.c b/net/core/dev.c
90941 index 26755dd..2a232de 100644
90942 --- a/net/core/dev.c
90943 +++ b/net/core/dev.c
90944 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
90945 {
90946 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
90947 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
90948 - atomic_long_inc(&dev->rx_dropped);
90949 + atomic_long_inc_unchecked(&dev->rx_dropped);
90950 kfree_skb(skb);
90951 return NET_RX_DROP;
90952 }
90953 }
90954
90955 if (unlikely(!is_skb_forwardable(dev, skb))) {
90956 - atomic_long_inc(&dev->rx_dropped);
90957 + atomic_long_inc_unchecked(&dev->rx_dropped);
90958 kfree_skb(skb);
90959 return NET_RX_DROP;
90960 }
90961 @@ -2431,7 +2431,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
90962
90963 struct dev_gso_cb {
90964 void (*destructor)(struct sk_buff *skb);
90965 -};
90966 +} __no_const;
90967
90968 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
90969
90970 @@ -3206,7 +3206,7 @@ enqueue:
90971
90972 local_irq_restore(flags);
90973
90974 - atomic_long_inc(&skb->dev->rx_dropped);
90975 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
90976 kfree_skb(skb);
90977 return NET_RX_DROP;
90978 }
90979 @@ -3278,7 +3278,7 @@ int netif_rx_ni(struct sk_buff *skb)
90980 }
90981 EXPORT_SYMBOL(netif_rx_ni);
90982
90983 -static void net_tx_action(struct softirq_action *h)
90984 +static __latent_entropy void net_tx_action(void)
90985 {
90986 struct softnet_data *sd = &__get_cpu_var(softnet_data);
90987
90988 @@ -3612,7 +3612,7 @@ ncls:
90989 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
90990 } else {
90991 drop:
90992 - atomic_long_inc(&skb->dev->rx_dropped);
90993 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
90994 kfree_skb(skb);
90995 /* Jamal, now you will not able to escape explaining
90996 * me how you were going to use this. :-)
90997 @@ -4272,7 +4272,7 @@ void netif_napi_del(struct napi_struct *napi)
90998 }
90999 EXPORT_SYMBOL(netif_napi_del);
91000
91001 -static void net_rx_action(struct softirq_action *h)
91002 +static __latent_entropy void net_rx_action(void)
91003 {
91004 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91005 unsigned long time_limit = jiffies + 2;
91006 @@ -5730,7 +5730,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
91007 } else {
91008 netdev_stats_to_stats64(storage, &dev->stats);
91009 }
91010 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
91011 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
91012 return storage;
91013 }
91014 EXPORT_SYMBOL(dev_get_stats);
91015 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
91016 index 5b7d0e1..cb960fc 100644
91017 --- a/net/core/dev_ioctl.c
91018 +++ b/net/core/dev_ioctl.c
91019 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
91020 if (no_module && capable(CAP_NET_ADMIN))
91021 no_module = request_module("netdev-%s", name);
91022 if (no_module && capable(CAP_SYS_MODULE)) {
91023 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
91024 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
91025 +#else
91026 if (!request_module("%s", name))
91027 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
91028 name);
91029 +#endif
91030 }
91031 }
91032 EXPORT_SYMBOL(dev_load);
91033 diff --git a/net/core/flow.c b/net/core/flow.c
91034 index dfa602c..3103d88 100644
91035 --- a/net/core/flow.c
91036 +++ b/net/core/flow.c
91037 @@ -61,7 +61,7 @@ struct flow_cache {
91038 struct timer_list rnd_timer;
91039 };
91040
91041 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
91042 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
91043 EXPORT_SYMBOL(flow_cache_genid);
91044 static struct flow_cache flow_cache_global;
91045 static struct kmem_cache *flow_cachep __read_mostly;
91046 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
91047
91048 static int flow_entry_valid(struct flow_cache_entry *fle)
91049 {
91050 - if (atomic_read(&flow_cache_genid) != fle->genid)
91051 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
91052 return 0;
91053 if (fle->object && !fle->object->ops->check(fle->object))
91054 return 0;
91055 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
91056 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
91057 fcp->hash_count++;
91058 }
91059 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
91060 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
91061 flo = fle->object;
91062 if (!flo)
91063 goto ret_object;
91064 @@ -279,7 +279,7 @@ nocache:
91065 }
91066 flo = resolver(net, key, family, dir, flo, ctx);
91067 if (fle) {
91068 - fle->genid = atomic_read(&flow_cache_genid);
91069 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
91070 if (!IS_ERR(flo))
91071 fle->object = flo;
91072 else
91073 diff --git a/net/core/iovec.c b/net/core/iovec.c
91074 index de178e4..1dabd8b 100644
91075 --- a/net/core/iovec.c
91076 +++ b/net/core/iovec.c
91077 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91078 if (m->msg_namelen) {
91079 if (mode == VERIFY_READ) {
91080 void __user *namep;
91081 - namep = (void __user __force *) m->msg_name;
91082 + namep = (void __force_user *) m->msg_name;
91083 err = move_addr_to_kernel(namep, m->msg_namelen,
91084 address);
91085 if (err < 0)
91086 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91087 }
91088
91089 size = m->msg_iovlen * sizeof(struct iovec);
91090 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
91091 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
91092 return -EFAULT;
91093
91094 m->msg_iov = iov;
91095 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
91096 index 60533db..14842cc 100644
91097 --- a/net/core/neighbour.c
91098 +++ b/net/core/neighbour.c
91099 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
91100 void __user *buffer, size_t *lenp, loff_t *ppos)
91101 {
91102 int size, ret;
91103 - struct ctl_table tmp = *ctl;
91104 + ctl_table_no_const tmp = *ctl;
91105
91106 tmp.extra1 = &zero;
91107 tmp.extra2 = &unres_qlen_max;
91108 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
91109 index 2bf8329..7960607 100644
91110 --- a/net/core/net-procfs.c
91111 +++ b/net/core/net-procfs.c
91112 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
91113 else
91114 seq_printf(seq, "%04x", ntohs(pt->type));
91115
91116 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91117 + seq_printf(seq, " %-8s %pf\n",
91118 + pt->dev ? pt->dev->name : "", NULL);
91119 +#else
91120 seq_printf(seq, " %-8s %pf\n",
91121 pt->dev ? pt->dev->name : "", pt->func);
91122 +#endif
91123 }
91124
91125 return 0;
91126 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
91127 index 981fed3..536af34 100644
91128 --- a/net/core/net-sysfs.c
91129 +++ b/net/core/net-sysfs.c
91130 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
91131 }
91132 EXPORT_SYMBOL(netdev_class_remove_file);
91133
91134 -int netdev_kobject_init(void)
91135 +int __init netdev_kobject_init(void)
91136 {
91137 kobj_ns_type_register(&net_ns_type_operations);
91138 return class_register(&net_class);
91139 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
91140 index f9765203..9feaef8 100644
91141 --- a/net/core/net_namespace.c
91142 +++ b/net/core/net_namespace.c
91143 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
91144 int error;
91145 LIST_HEAD(net_exit_list);
91146
91147 - list_add_tail(&ops->list, list);
91148 + pax_list_add_tail((struct list_head *)&ops->list, list);
91149 if (ops->init || (ops->id && ops->size)) {
91150 for_each_net(net) {
91151 error = ops_init(ops, net);
91152 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
91153
91154 out_undo:
91155 /* If I have an error cleanup all namespaces I initialized */
91156 - list_del(&ops->list);
91157 + pax_list_del((struct list_head *)&ops->list);
91158 ops_exit_list(ops, &net_exit_list);
91159 ops_free_list(ops, &net_exit_list);
91160 return error;
91161 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
91162 struct net *net;
91163 LIST_HEAD(net_exit_list);
91164
91165 - list_del(&ops->list);
91166 + pax_list_del((struct list_head *)&ops->list);
91167 for_each_net(net)
91168 list_add_tail(&net->exit_list, &net_exit_list);
91169 ops_exit_list(ops, &net_exit_list);
91170 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
91171 mutex_lock(&net_mutex);
91172 error = register_pernet_operations(&pernet_list, ops);
91173 if (!error && (first_device == &pernet_list))
91174 - first_device = &ops->list;
91175 + first_device = (struct list_head *)&ops->list;
91176 mutex_unlock(&net_mutex);
91177 return error;
91178 }
91179 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
91180 index 2c637e9..68c9087 100644
91181 --- a/net/core/netpoll.c
91182 +++ b/net/core/netpoll.c
91183 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91184 struct udphdr *udph;
91185 struct iphdr *iph;
91186 struct ethhdr *eth;
91187 - static atomic_t ip_ident;
91188 + static atomic_unchecked_t ip_ident;
91189 struct ipv6hdr *ip6h;
91190
91191 udp_len = len + sizeof(*udph);
91192 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91193 put_unaligned(0x45, (unsigned char *)iph);
91194 iph->tos = 0;
91195 put_unaligned(htons(ip_len), &(iph->tot_len));
91196 - iph->id = htons(atomic_inc_return(&ip_ident));
91197 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
91198 iph->frag_off = 0;
91199 iph->ttl = 64;
91200 iph->protocol = IPPROTO_UDP;
91201 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
91202 index ca198c1d1..125372f 100644
91203 --- a/net/core/rtnetlink.c
91204 +++ b/net/core/rtnetlink.c
91205 @@ -58,7 +58,7 @@ struct rtnl_link {
91206 rtnl_doit_func doit;
91207 rtnl_dumpit_func dumpit;
91208 rtnl_calcit_func calcit;
91209 -};
91210 +} __no_const;
91211
91212 static DEFINE_MUTEX(rtnl_mutex);
91213
91214 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
91215 if (rtnl_link_ops_get(ops->kind))
91216 return -EEXIST;
91217
91218 - if (!ops->dellink)
91219 - ops->dellink = unregister_netdevice_queue;
91220 + if (!ops->dellink) {
91221 + pax_open_kernel();
91222 + *(void **)&ops->dellink = unregister_netdevice_queue;
91223 + pax_close_kernel();
91224 + }
91225
91226 - list_add_tail(&ops->list, &link_ops);
91227 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
91228 return 0;
91229 }
91230 EXPORT_SYMBOL_GPL(__rtnl_link_register);
91231 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
91232 for_each_net(net) {
91233 __rtnl_kill_links(net, ops);
91234 }
91235 - list_del(&ops->list);
91236 + pax_list_del((struct list_head *)&ops->list);
91237 }
91238 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
91239
91240 diff --git a/net/core/scm.c b/net/core/scm.c
91241 index b4da80b..98d6bdb 100644
91242 --- a/net/core/scm.c
91243 +++ b/net/core/scm.c
91244 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
91245 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91246 {
91247 struct cmsghdr __user *cm
91248 - = (__force struct cmsghdr __user *)msg->msg_control;
91249 + = (struct cmsghdr __force_user *)msg->msg_control;
91250 struct cmsghdr cmhdr;
91251 int cmlen = CMSG_LEN(len);
91252 int err;
91253 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91254 err = -EFAULT;
91255 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
91256 goto out;
91257 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
91258 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
91259 goto out;
91260 cmlen = CMSG_SPACE(len);
91261 if (msg->msg_controllen < cmlen)
91262 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
91263 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91264 {
91265 struct cmsghdr __user *cm
91266 - = (__force struct cmsghdr __user*)msg->msg_control;
91267 + = (struct cmsghdr __force_user *)msg->msg_control;
91268
91269 int fdmax = 0;
91270 int fdnum = scm->fp->count;
91271 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91272 if (fdnum < fdmax)
91273 fdmax = fdnum;
91274
91275 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
91276 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
91277 i++, cmfptr++)
91278 {
91279 struct socket *sock;
91280 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
91281 index 2c3d0f5..f5a326f 100644
91282 --- a/net/core/skbuff.c
91283 +++ b/net/core/skbuff.c
91284 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
91285 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
91286 sizeof(struct sk_buff),
91287 0,
91288 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91289 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91290 + SLAB_NO_SANITIZE,
91291 NULL);
91292 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
91293 (2*sizeof(struct sk_buff)) +
91294 sizeof(atomic_t),
91295 0,
91296 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91297 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91298 + SLAB_NO_SANITIZE,
91299 NULL);
91300 }
91301
91302 diff --git a/net/core/sock.c b/net/core/sock.c
91303 index 2c097c5..bf72858 100644
91304 --- a/net/core/sock.c
91305 +++ b/net/core/sock.c
91306 @@ -392,7 +392,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91307 struct sk_buff_head *list = &sk->sk_receive_queue;
91308
91309 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
91310 - atomic_inc(&sk->sk_drops);
91311 + atomic_inc_unchecked(&sk->sk_drops);
91312 trace_sock_rcvqueue_full(sk, skb);
91313 return -ENOMEM;
91314 }
91315 @@ -402,7 +402,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91316 return err;
91317
91318 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
91319 - atomic_inc(&sk->sk_drops);
91320 + atomic_inc_unchecked(&sk->sk_drops);
91321 return -ENOBUFS;
91322 }
91323
91324 @@ -422,7 +422,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91325 skb_dst_force(skb);
91326
91327 spin_lock_irqsave(&list->lock, flags);
91328 - skb->dropcount = atomic_read(&sk->sk_drops);
91329 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
91330 __skb_queue_tail(list, skb);
91331 spin_unlock_irqrestore(&list->lock, flags);
91332
91333 @@ -442,7 +442,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91334 skb->dev = NULL;
91335
91336 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
91337 - atomic_inc(&sk->sk_drops);
91338 + atomic_inc_unchecked(&sk->sk_drops);
91339 goto discard_and_relse;
91340 }
91341 if (nested)
91342 @@ -460,7 +460,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91343 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
91344 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
91345 bh_unlock_sock(sk);
91346 - atomic_inc(&sk->sk_drops);
91347 + atomic_inc_unchecked(&sk->sk_drops);
91348 goto discard_and_relse;
91349 }
91350
91351 @@ -948,12 +948,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91352 struct timeval tm;
91353 } v;
91354
91355 - int lv = sizeof(int);
91356 - int len;
91357 + unsigned int lv = sizeof(int);
91358 + unsigned int len;
91359
91360 if (get_user(len, optlen))
91361 return -EFAULT;
91362 - if (len < 0)
91363 + if (len > INT_MAX)
91364 return -EINVAL;
91365
91366 memset(&v, 0, sizeof(v));
91367 @@ -1105,11 +1105,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91368
91369 case SO_PEERNAME:
91370 {
91371 - char address[128];
91372 + char address[_K_SS_MAXSIZE];
91373
91374 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
91375 return -ENOTCONN;
91376 - if (lv < len)
91377 + if (lv < len || sizeof address < len)
91378 return -EINVAL;
91379 if (copy_to_user(optval, address, len))
91380 return -EFAULT;
91381 @@ -1182,7 +1182,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
91382
91383 if (len > lv)
91384 len = lv;
91385 - if (copy_to_user(optval, &v, len))
91386 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
91387 return -EFAULT;
91388 lenout:
91389 if (put_user(len, optlen))
91390 @@ -2303,7 +2303,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
91391 */
91392 smp_wmb();
91393 atomic_set(&sk->sk_refcnt, 1);
91394 - atomic_set(&sk->sk_drops, 0);
91395 + atomic_set_unchecked(&sk->sk_drops, 0);
91396 }
91397 EXPORT_SYMBOL(sock_init_data);
91398
91399 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
91400 index a0e9cf6..ef7f9ed 100644
91401 --- a/net/core/sock_diag.c
91402 +++ b/net/core/sock_diag.c
91403 @@ -9,26 +9,33 @@
91404 #include <linux/inet_diag.h>
91405 #include <linux/sock_diag.h>
91406
91407 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
91408 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
91409 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
91410 static DEFINE_MUTEX(sock_diag_table_mutex);
91411
91412 int sock_diag_check_cookie(void *sk, __u32 *cookie)
91413 {
91414 +#ifndef CONFIG_GRKERNSEC_HIDESYM
91415 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
91416 cookie[1] != INET_DIAG_NOCOOKIE) &&
91417 ((u32)(unsigned long)sk != cookie[0] ||
91418 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
91419 return -ESTALE;
91420 else
91421 +#endif
91422 return 0;
91423 }
91424 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
91425
91426 void sock_diag_save_cookie(void *sk, __u32 *cookie)
91427 {
91428 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91429 + cookie[0] = 0;
91430 + cookie[1] = 0;
91431 +#else
91432 cookie[0] = (u32)(unsigned long)sk;
91433 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
91434 +#endif
91435 }
91436 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
91437
91438 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
91439 mutex_lock(&sock_diag_table_mutex);
91440 if (sock_diag_handlers[hndl->family])
91441 err = -EBUSY;
91442 - else
91443 + else {
91444 + pax_open_kernel();
91445 sock_diag_handlers[hndl->family] = hndl;
91446 + pax_close_kernel();
91447 + }
91448 mutex_unlock(&sock_diag_table_mutex);
91449
91450 return err;
91451 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
91452
91453 mutex_lock(&sock_diag_table_mutex);
91454 BUG_ON(sock_diag_handlers[family] != hnld);
91455 + pax_open_kernel();
91456 sock_diag_handlers[family] = NULL;
91457 + pax_close_kernel();
91458 mutex_unlock(&sock_diag_table_mutex);
91459 }
91460 EXPORT_SYMBOL_GPL(sock_diag_unregister);
91461 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
91462 index 31107ab..ae03d5a 100644
91463 --- a/net/core/sysctl_net_core.c
91464 +++ b/net/core/sysctl_net_core.c
91465 @@ -31,7 +31,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
91466 {
91467 unsigned int orig_size, size;
91468 int ret, i;
91469 - struct ctl_table tmp = {
91470 + ctl_table_no_const tmp = {
91471 .data = &size,
91472 .maxlen = sizeof(size),
91473 .mode = table->mode
91474 @@ -350,13 +350,12 @@ static struct ctl_table netns_core_table[] = {
91475
91476 static __net_init int sysctl_core_net_init(struct net *net)
91477 {
91478 - struct ctl_table *tbl;
91479 + ctl_table_no_const *tbl = NULL;
91480
91481 net->core.sysctl_somaxconn = SOMAXCONN;
91482
91483 - tbl = netns_core_table;
91484 if (!net_eq(net, &init_net)) {
91485 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
91486 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
91487 if (tbl == NULL)
91488 goto err_dup;
91489
91490 @@ -366,17 +365,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
91491 if (net->user_ns != &init_user_ns) {
91492 tbl[0].procname = NULL;
91493 }
91494 - }
91495 -
91496 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
91497 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
91498 + } else
91499 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
91500 if (net->core.sysctl_hdr == NULL)
91501 goto err_reg;
91502
91503 return 0;
91504
91505 err_reg:
91506 - if (tbl != netns_core_table)
91507 - kfree(tbl);
91508 + kfree(tbl);
91509 err_dup:
91510 return -ENOMEM;
91511 }
91512 @@ -391,7 +389,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
91513 kfree(tbl);
91514 }
91515
91516 -static __net_initdata struct pernet_operations sysctl_core_ops = {
91517 +static __net_initconst struct pernet_operations sysctl_core_ops = {
91518 .init = sysctl_core_net_init,
91519 .exit = sysctl_core_net_exit,
91520 };
91521 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
91522 index dd4d506..fb2fb87 100644
91523 --- a/net/decnet/af_decnet.c
91524 +++ b/net/decnet/af_decnet.c
91525 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
91526 .sysctl_rmem = sysctl_decnet_rmem,
91527 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
91528 .obj_size = sizeof(struct dn_sock),
91529 + .slab_flags = SLAB_USERCOPY,
91530 };
91531
91532 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
91533 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
91534 index 5325b54..a0d4d69 100644
91535 --- a/net/decnet/sysctl_net_decnet.c
91536 +++ b/net/decnet/sysctl_net_decnet.c
91537 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
91538
91539 if (len > *lenp) len = *lenp;
91540
91541 - if (copy_to_user(buffer, addr, len))
91542 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
91543 return -EFAULT;
91544
91545 *lenp = len;
91546 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
91547
91548 if (len > *lenp) len = *lenp;
91549
91550 - if (copy_to_user(buffer, devname, len))
91551 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
91552 return -EFAULT;
91553
91554 *lenp = len;
91555 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
91556 index 3b9d5f2..d7015c6 100644
91557 --- a/net/ieee802154/6lowpan.c
91558 +++ b/net/ieee802154/6lowpan.c
91559 @@ -459,7 +459,7 @@ static int lowpan_header_create(struct sk_buff *skb,
91560 hc06_ptr += 3;
91561 } else {
91562 /* compress nothing */
91563 - memcpy(hc06_ptr, &hdr, 4);
91564 + memcpy(hc06_ptr, hdr, 4);
91565 /* replace the top byte with new ECN | DSCP format */
91566 *hc06_ptr = tmp;
91567 hc06_ptr += 4;
91568 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
91569 index b4d0be2..443d0f0 100644
91570 --- a/net/ipv4/af_inet.c
91571 +++ b/net/ipv4/af_inet.c
91572 @@ -1689,13 +1689,9 @@ static int __init inet_init(void)
91573
91574 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
91575
91576 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
91577 - if (!sysctl_local_reserved_ports)
91578 - goto out;
91579 -
91580 rc = proto_register(&tcp_prot, 1);
91581 if (rc)
91582 - goto out_free_reserved_ports;
91583 + goto out;
91584
91585 rc = proto_register(&udp_prot, 1);
91586 if (rc)
91587 @@ -1804,8 +1800,6 @@ out_unregister_udp_proto:
91588 proto_unregister(&udp_prot);
91589 out_unregister_tcp_proto:
91590 proto_unregister(&tcp_prot);
91591 -out_free_reserved_ports:
91592 - kfree(sysctl_local_reserved_ports);
91593 goto out;
91594 }
91595
91596 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
91597 index 34ca6d5..b6421e8 100644
91598 --- a/net/ipv4/devinet.c
91599 +++ b/net/ipv4/devinet.c
91600 @@ -1532,7 +1532,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
91601 idx = 0;
91602 head = &net->dev_index_head[h];
91603 rcu_read_lock();
91604 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
91605 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
91606 net->dev_base_seq;
91607 hlist_for_each_entry_rcu(dev, head, index_hlist) {
91608 if (idx < s_idx)
91609 @@ -1843,7 +1843,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
91610 idx = 0;
91611 head = &net->dev_index_head[h];
91612 rcu_read_lock();
91613 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
91614 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
91615 net->dev_base_seq;
91616 hlist_for_each_entry_rcu(dev, head, index_hlist) {
91617 if (idx < s_idx)
91618 @@ -2068,7 +2068,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
91619 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
91620 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
91621
91622 -static struct devinet_sysctl_table {
91623 +static const struct devinet_sysctl_table {
91624 struct ctl_table_header *sysctl_header;
91625 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
91626 } devinet_sysctl = {
91627 @@ -2186,7 +2186,7 @@ static __net_init int devinet_init_net(struct net *net)
91628 int err;
91629 struct ipv4_devconf *all, *dflt;
91630 #ifdef CONFIG_SYSCTL
91631 - struct ctl_table *tbl = ctl_forward_entry;
91632 + ctl_table_no_const *tbl = NULL;
91633 struct ctl_table_header *forw_hdr;
91634 #endif
91635
91636 @@ -2204,7 +2204,7 @@ static __net_init int devinet_init_net(struct net *net)
91637 goto err_alloc_dflt;
91638
91639 #ifdef CONFIG_SYSCTL
91640 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
91641 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
91642 if (tbl == NULL)
91643 goto err_alloc_ctl;
91644
91645 @@ -2224,7 +2224,10 @@ static __net_init int devinet_init_net(struct net *net)
91646 goto err_reg_dflt;
91647
91648 err = -ENOMEM;
91649 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
91650 + if (!net_eq(net, &init_net))
91651 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
91652 + else
91653 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
91654 if (forw_hdr == NULL)
91655 goto err_reg_ctl;
91656 net->ipv4.forw_hdr = forw_hdr;
91657 @@ -2240,8 +2243,7 @@ err_reg_ctl:
91658 err_reg_dflt:
91659 __devinet_sysctl_unregister(all);
91660 err_reg_all:
91661 - if (tbl != ctl_forward_entry)
91662 - kfree(tbl);
91663 + kfree(tbl);
91664 err_alloc_ctl:
91665 #endif
91666 if (dflt != &ipv4_devconf_dflt)
91667 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
91668 index b3f627a..b0f3e99 100644
91669 --- a/net/ipv4/fib_frontend.c
91670 +++ b/net/ipv4/fib_frontend.c
91671 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
91672 #ifdef CONFIG_IP_ROUTE_MULTIPATH
91673 fib_sync_up(dev);
91674 #endif
91675 - atomic_inc(&net->ipv4.dev_addr_genid);
91676 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
91677 rt_cache_flush(dev_net(dev));
91678 break;
91679 case NETDEV_DOWN:
91680 fib_del_ifaddr(ifa, NULL);
91681 - atomic_inc(&net->ipv4.dev_addr_genid);
91682 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
91683 if (ifa->ifa_dev->ifa_list == NULL) {
91684 /* Last address was deleted from this interface.
91685 * Disable IP.
91686 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
91687 #ifdef CONFIG_IP_ROUTE_MULTIPATH
91688 fib_sync_up(dev);
91689 #endif
91690 - atomic_inc(&net->ipv4.dev_addr_genid);
91691 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
91692 rt_cache_flush(net);
91693 break;
91694 case NETDEV_DOWN:
91695 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
91696 index d5dbca5..6251d5f 100644
91697 --- a/net/ipv4/fib_semantics.c
91698 +++ b/net/ipv4/fib_semantics.c
91699 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
91700 nh->nh_saddr = inet_select_addr(nh->nh_dev,
91701 nh->nh_gw,
91702 nh->nh_parent->fib_scope);
91703 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
91704 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
91705
91706 return nh->nh_saddr;
91707 }
91708 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
91709 index 6acb541..9ea617d 100644
91710 --- a/net/ipv4/inet_connection_sock.c
91711 +++ b/net/ipv4/inet_connection_sock.c
91712 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
91713 .range = { 32768, 61000 },
91714 };
91715
91716 -unsigned long *sysctl_local_reserved_ports;
91717 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
91718 EXPORT_SYMBOL(sysctl_local_reserved_ports);
91719
91720 void inet_get_local_port_range(int *low, int *high)
91721 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
91722 index 7bd8983..3abdcf6 100644
91723 --- a/net/ipv4/inet_hashtables.c
91724 +++ b/net/ipv4/inet_hashtables.c
91725 @@ -18,12 +18,15 @@
91726 #include <linux/sched.h>
91727 #include <linux/slab.h>
91728 #include <linux/wait.h>
91729 +#include <linux/security.h>
91730
91731 #include <net/inet_connection_sock.h>
91732 #include <net/inet_hashtables.h>
91733 #include <net/secure_seq.h>
91734 #include <net/ip.h>
91735
91736 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
91737 +
91738 /*
91739 * Allocate and initialize a new local port bind bucket.
91740 * The bindhash mutex for snum's hash chain must be held here.
91741 @@ -554,6 +557,8 @@ ok:
91742 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
91743 spin_unlock(&head->lock);
91744
91745 + gr_update_task_in_ip_table(current, inet_sk(sk));
91746 +
91747 if (tw) {
91748 inet_twsk_deschedule(tw, death_row);
91749 while (twrefcnt) {
91750 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
91751 index 000e3d2..5472da3 100644
91752 --- a/net/ipv4/inetpeer.c
91753 +++ b/net/ipv4/inetpeer.c
91754 @@ -503,8 +503,8 @@ relookup:
91755 if (p) {
91756 p->daddr = *daddr;
91757 atomic_set(&p->refcnt, 1);
91758 - atomic_set(&p->rid, 0);
91759 - atomic_set(&p->ip_id_count,
91760 + atomic_set_unchecked(&p->rid, 0);
91761 + atomic_set_unchecked(&p->ip_id_count,
91762 (daddr->family == AF_INET) ?
91763 secure_ip_id(daddr->addr.a4) :
91764 secure_ipv6_id(daddr->addr.a6));
91765 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
91766 index b66910a..cfe416e 100644
91767 --- a/net/ipv4/ip_fragment.c
91768 +++ b/net/ipv4/ip_fragment.c
91769 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
91770 return 0;
91771
91772 start = qp->rid;
91773 - end = atomic_inc_return(&peer->rid);
91774 + end = atomic_inc_return_unchecked(&peer->rid);
91775 qp->rid = end;
91776
91777 rc = qp->q.fragments && (end - start) > max;
91778 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
91779
91780 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
91781 {
91782 - struct ctl_table *table;
91783 + ctl_table_no_const *table = NULL;
91784 struct ctl_table_header *hdr;
91785
91786 - table = ip4_frags_ns_ctl_table;
91787 if (!net_eq(net, &init_net)) {
91788 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
91789 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
91790 if (table == NULL)
91791 goto err_alloc;
91792
91793 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
91794 /* Don't export sysctls to unprivileged users */
91795 if (net->user_ns != &init_user_ns)
91796 table[0].procname = NULL;
91797 - }
91798 + hdr = register_net_sysctl(net, "net/ipv4", table);
91799 + } else
91800 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
91801
91802 - hdr = register_net_sysctl(net, "net/ipv4", table);
91803 if (hdr == NULL)
91804 goto err_reg;
91805
91806 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
91807 return 0;
91808
91809 err_reg:
91810 - if (!net_eq(net, &init_net))
91811 - kfree(table);
91812 + kfree(table);
91813 err_alloc:
91814 return -ENOMEM;
91815 }
91816 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
91817 index 8d6939e..19d0a95 100644
91818 --- a/net/ipv4/ip_gre.c
91819 +++ b/net/ipv4/ip_gre.c
91820 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
91821 module_param(log_ecn_error, bool, 0644);
91822 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
91823
91824 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
91825 +static struct rtnl_link_ops ipgre_link_ops;
91826 static int ipgre_tunnel_init(struct net_device *dev);
91827
91828 static int ipgre_net_id __read_mostly;
91829 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
91830 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
91831 };
91832
91833 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
91834 +static struct rtnl_link_ops ipgre_link_ops = {
91835 .kind = "gre",
91836 .maxtype = IFLA_GRE_MAX,
91837 .policy = ipgre_policy,
91838 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
91839 .fill_info = ipgre_fill_info,
91840 };
91841
91842 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
91843 +static struct rtnl_link_ops ipgre_tap_ops = {
91844 .kind = "gretap",
91845 .maxtype = IFLA_GRE_MAX,
91846 .policy = ipgre_policy,
91847 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
91848 index d9c4f11..02b82dbc 100644
91849 --- a/net/ipv4/ip_sockglue.c
91850 +++ b/net/ipv4/ip_sockglue.c
91851 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
91852 len = min_t(unsigned int, len, opt->optlen);
91853 if (put_user(len, optlen))
91854 return -EFAULT;
91855 - if (copy_to_user(optval, opt->__data, len))
91856 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
91857 + copy_to_user(optval, opt->__data, len))
91858 return -EFAULT;
91859 return 0;
91860 }
91861 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
91862 if (sk->sk_type != SOCK_STREAM)
91863 return -ENOPROTOOPT;
91864
91865 - msg.msg_control = optval;
91866 + msg.msg_control = (void __force_kernel *)optval;
91867 msg.msg_controllen = len;
91868 msg.msg_flags = flags;
91869
91870 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
91871 index 17cc0ff..63856c4 100644
91872 --- a/net/ipv4/ip_vti.c
91873 +++ b/net/ipv4/ip_vti.c
91874 @@ -47,7 +47,7 @@
91875 #define HASH_SIZE 16
91876 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
91877
91878 -static struct rtnl_link_ops vti_link_ops __read_mostly;
91879 +static struct rtnl_link_ops vti_link_ops;
91880
91881 static int vti_net_id __read_mostly;
91882 struct vti_net {
91883 @@ -840,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
91884 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
91885 };
91886
91887 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
91888 +static struct rtnl_link_ops vti_link_ops = {
91889 .kind = "vti",
91890 .maxtype = IFLA_VTI_MAX,
91891 .policy = vti_policy,
91892 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
91893 index efa1138..20dbba0 100644
91894 --- a/net/ipv4/ipconfig.c
91895 +++ b/net/ipv4/ipconfig.c
91896 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
91897
91898 mm_segment_t oldfs = get_fs();
91899 set_fs(get_ds());
91900 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
91901 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
91902 set_fs(oldfs);
91903 return res;
91904 }
91905 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
91906
91907 mm_segment_t oldfs = get_fs();
91908 set_fs(get_ds());
91909 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
91910 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
91911 set_fs(oldfs);
91912 return res;
91913 }
91914 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
91915
91916 mm_segment_t oldfs = get_fs();
91917 set_fs(get_ds());
91918 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
91919 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
91920 set_fs(oldfs);
91921 return res;
91922 }
91923 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
91924 index b3ac3c3..ec6bd95 100644
91925 --- a/net/ipv4/ipip.c
91926 +++ b/net/ipv4/ipip.c
91927 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
91928 static int ipip_net_id __read_mostly;
91929
91930 static int ipip_tunnel_init(struct net_device *dev);
91931 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
91932 +static struct rtnl_link_ops ipip_link_ops;
91933
91934 static int ipip_err(struct sk_buff *skb, u32 info)
91935 {
91936 @@ -409,7 +409,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
91937 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
91938 };
91939
91940 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
91941 +static struct rtnl_link_ops ipip_link_ops = {
91942 .kind = "ipip",
91943 .maxtype = IFLA_IPTUN_MAX,
91944 .policy = ipip_policy,
91945 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
91946 index 85a4f21..1beb1f5 100644
91947 --- a/net/ipv4/netfilter/arp_tables.c
91948 +++ b/net/ipv4/netfilter/arp_tables.c
91949 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
91950 #endif
91951
91952 static int get_info(struct net *net, void __user *user,
91953 - const int *len, int compat)
91954 + int len, int compat)
91955 {
91956 char name[XT_TABLE_MAXNAMELEN];
91957 struct xt_table *t;
91958 int ret;
91959
91960 - if (*len != sizeof(struct arpt_getinfo)) {
91961 - duprintf("length %u != %Zu\n", *len,
91962 + if (len != sizeof(struct arpt_getinfo)) {
91963 + duprintf("length %u != %Zu\n", len,
91964 sizeof(struct arpt_getinfo));
91965 return -EINVAL;
91966 }
91967 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
91968 info.size = private->size;
91969 strcpy(info.name, name);
91970
91971 - if (copy_to_user(user, &info, *len) != 0)
91972 + if (copy_to_user(user, &info, len) != 0)
91973 ret = -EFAULT;
91974 else
91975 ret = 0;
91976 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
91977
91978 switch (cmd) {
91979 case ARPT_SO_GET_INFO:
91980 - ret = get_info(sock_net(sk), user, len, 1);
91981 + ret = get_info(sock_net(sk), user, *len, 1);
91982 break;
91983 case ARPT_SO_GET_ENTRIES:
91984 ret = compat_get_entries(sock_net(sk), user, len);
91985 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
91986
91987 switch (cmd) {
91988 case ARPT_SO_GET_INFO:
91989 - ret = get_info(sock_net(sk), user, len, 0);
91990 + ret = get_info(sock_net(sk), user, *len, 0);
91991 break;
91992
91993 case ARPT_SO_GET_ENTRIES:
91994 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
91995 index d23118d..6ad7277 100644
91996 --- a/net/ipv4/netfilter/ip_tables.c
91997 +++ b/net/ipv4/netfilter/ip_tables.c
91998 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
91999 #endif
92000
92001 static int get_info(struct net *net, void __user *user,
92002 - const int *len, int compat)
92003 + int len, int compat)
92004 {
92005 char name[XT_TABLE_MAXNAMELEN];
92006 struct xt_table *t;
92007 int ret;
92008
92009 - if (*len != sizeof(struct ipt_getinfo)) {
92010 - duprintf("length %u != %zu\n", *len,
92011 + if (len != sizeof(struct ipt_getinfo)) {
92012 + duprintf("length %u != %zu\n", len,
92013 sizeof(struct ipt_getinfo));
92014 return -EINVAL;
92015 }
92016 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
92017 info.size = private->size;
92018 strcpy(info.name, name);
92019
92020 - if (copy_to_user(user, &info, *len) != 0)
92021 + if (copy_to_user(user, &info, len) != 0)
92022 ret = -EFAULT;
92023 else
92024 ret = 0;
92025 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92026
92027 switch (cmd) {
92028 case IPT_SO_GET_INFO:
92029 - ret = get_info(sock_net(sk), user, len, 1);
92030 + ret = get_info(sock_net(sk), user, *len, 1);
92031 break;
92032 case IPT_SO_GET_ENTRIES:
92033 ret = compat_get_entries(sock_net(sk), user, len);
92034 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92035
92036 switch (cmd) {
92037 case IPT_SO_GET_INFO:
92038 - ret = get_info(sock_net(sk), user, len, 0);
92039 + ret = get_info(sock_net(sk), user, *len, 0);
92040 break;
92041
92042 case IPT_SO_GET_ENTRIES:
92043 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
92044 index 746427c..80eab72 100644
92045 --- a/net/ipv4/ping.c
92046 +++ b/net/ipv4/ping.c
92047 @@ -55,7 +55,7 @@
92048
92049
92050 struct ping_table ping_table;
92051 -struct pingv6_ops pingv6_ops;
92052 +struct pingv6_ops *pingv6_ops;
92053 EXPORT_SYMBOL_GPL(pingv6_ops);
92054
92055 static u16 ping_port_rover;
92056 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
92057 return -ENODEV;
92058 }
92059 }
92060 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
92061 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
92062 scoped);
92063 rcu_read_unlock();
92064
92065 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92066 }
92067 #if IS_ENABLED(CONFIG_IPV6)
92068 } else if (skb->protocol == htons(ETH_P_IPV6)) {
92069 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
92070 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
92071 #endif
92072 }
92073
92074 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92075 info, (u8 *)icmph);
92076 #if IS_ENABLED(CONFIG_IPV6)
92077 } else if (family == AF_INET6) {
92078 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
92079 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
92080 info, (u8 *)icmph);
92081 #endif
92082 }
92083 @@ -850,7 +850,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92084 return ip_recv_error(sk, msg, len);
92085 #if IS_ENABLED(CONFIG_IPV6)
92086 } else if (family == AF_INET6) {
92087 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
92088 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
92089 #endif
92090 }
92091 }
92092 @@ -900,7 +900,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92093 IP6CB(skb)->iif);
92094
92095 if (inet6_sk(sk)->rxopt.all)
92096 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
92097 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
92098 #endif
92099 } else {
92100 BUG();
92101 @@ -1090,7 +1090,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
92102 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
92103 0, sock_i_ino(sp),
92104 atomic_read(&sp->sk_refcnt), sp,
92105 - atomic_read(&sp->sk_drops), len);
92106 + atomic_read_unchecked(&sp->sk_drops), len);
92107 }
92108
92109 static int ping_v4_seq_show(struct seq_file *seq, void *v)
92110 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
92111 index 61e60d6..d6996cd 100644
92112 --- a/net/ipv4/raw.c
92113 +++ b/net/ipv4/raw.c
92114 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
92115 int raw_rcv(struct sock *sk, struct sk_buff *skb)
92116 {
92117 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
92118 - atomic_inc(&sk->sk_drops);
92119 + atomic_inc_unchecked(&sk->sk_drops);
92120 kfree_skb(skb);
92121 return NET_RX_DROP;
92122 }
92123 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
92124
92125 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
92126 {
92127 + struct icmp_filter filter;
92128 +
92129 if (optlen > sizeof(struct icmp_filter))
92130 optlen = sizeof(struct icmp_filter);
92131 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
92132 + if (copy_from_user(&filter, optval, optlen))
92133 return -EFAULT;
92134 + raw_sk(sk)->filter = filter;
92135 return 0;
92136 }
92137
92138 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
92139 {
92140 int len, ret = -EFAULT;
92141 + struct icmp_filter filter;
92142
92143 if (get_user(len, optlen))
92144 goto out;
92145 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
92146 if (len > sizeof(struct icmp_filter))
92147 len = sizeof(struct icmp_filter);
92148 ret = -EFAULT;
92149 - if (put_user(len, optlen) ||
92150 - copy_to_user(optval, &raw_sk(sk)->filter, len))
92151 + filter = raw_sk(sk)->filter;
92152 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
92153 goto out;
92154 ret = 0;
92155 out: return ret;
92156 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
92157 0, 0L, 0,
92158 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
92159 0, sock_i_ino(sp),
92160 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
92161 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
92162 }
92163
92164 static int raw_seq_show(struct seq_file *seq, void *v)
92165 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
92166 index a9a54a2..647316e 100644
92167 --- a/net/ipv4/route.c
92168 +++ b/net/ipv4/route.c
92169 @@ -2615,34 +2615,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
92170 .maxlen = sizeof(int),
92171 .mode = 0200,
92172 .proc_handler = ipv4_sysctl_rtcache_flush,
92173 + .extra1 = &init_net,
92174 },
92175 { },
92176 };
92177
92178 static __net_init int sysctl_route_net_init(struct net *net)
92179 {
92180 - struct ctl_table *tbl;
92181 + ctl_table_no_const *tbl = NULL;
92182
92183 - tbl = ipv4_route_flush_table;
92184 if (!net_eq(net, &init_net)) {
92185 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92186 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92187 if (tbl == NULL)
92188 goto err_dup;
92189
92190 /* Don't export sysctls to unprivileged users */
92191 if (net->user_ns != &init_user_ns)
92192 tbl[0].procname = NULL;
92193 - }
92194 - tbl[0].extra1 = net;
92195 + tbl[0].extra1 = net;
92196 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92197 + } else
92198 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
92199
92200 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92201 if (net->ipv4.route_hdr == NULL)
92202 goto err_reg;
92203 return 0;
92204
92205 err_reg:
92206 - if (tbl != ipv4_route_flush_table)
92207 - kfree(tbl);
92208 + kfree(tbl);
92209 err_dup:
92210 return -ENOMEM;
92211 }
92212 @@ -2665,8 +2665,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
92213
92214 static __net_init int rt_genid_init(struct net *net)
92215 {
92216 - atomic_set(&net->rt_genid, 0);
92217 - atomic_set(&net->fnhe_genid, 0);
92218 + atomic_set_unchecked(&net->rt_genid, 0);
92219 + atomic_set_unchecked(&net->fnhe_genid, 0);
92220 get_random_bytes(&net->ipv4.dev_addr_genid,
92221 sizeof(net->ipv4.dev_addr_genid));
92222 return 0;
92223 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
92224 index 610e324..fd42e75 100644
92225 --- a/net/ipv4/sysctl_net_ipv4.c
92226 +++ b/net/ipv4/sysctl_net_ipv4.c
92227 @@ -57,7 +57,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
92228 {
92229 int ret;
92230 int range[2];
92231 - struct ctl_table tmp = {
92232 + ctl_table_no_const tmp = {
92233 .data = &range,
92234 .maxlen = sizeof(range),
92235 .mode = table->mode,
92236 @@ -110,7 +110,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
92237 int ret;
92238 gid_t urange[2];
92239 kgid_t low, high;
92240 - struct ctl_table tmp = {
92241 + ctl_table_no_const tmp = {
92242 .data = &urange,
92243 .maxlen = sizeof(urange),
92244 .mode = table->mode,
92245 @@ -141,7 +141,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
92246 void __user *buffer, size_t *lenp, loff_t *ppos)
92247 {
92248 char val[TCP_CA_NAME_MAX];
92249 - struct ctl_table tbl = {
92250 + ctl_table_no_const tbl = {
92251 .data = val,
92252 .maxlen = TCP_CA_NAME_MAX,
92253 };
92254 @@ -160,7 +160,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
92255 void __user *buffer, size_t *lenp,
92256 loff_t *ppos)
92257 {
92258 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
92259 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
92260 int ret;
92261
92262 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92263 @@ -177,7 +177,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
92264 void __user *buffer, size_t *lenp,
92265 loff_t *ppos)
92266 {
92267 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
92268 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
92269 int ret;
92270
92271 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92272 @@ -203,15 +203,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
92273 struct mem_cgroup *memcg;
92274 #endif
92275
92276 - struct ctl_table tmp = {
92277 + ctl_table_no_const tmp = {
92278 .data = &vec,
92279 .maxlen = sizeof(vec),
92280 .mode = ctl->mode,
92281 };
92282
92283 if (!write) {
92284 - ctl->data = &net->ipv4.sysctl_tcp_mem;
92285 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
92286 + ctl_table_no_const tcp_mem = *ctl;
92287 +
92288 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
92289 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
92290 }
92291
92292 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
92293 @@ -239,7 +241,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
92294 void __user *buffer, size_t *lenp,
92295 loff_t *ppos)
92296 {
92297 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92298 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
92299 struct tcp_fastopen_context *ctxt;
92300 int ret;
92301 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
92302 @@ -482,7 +484,7 @@ static struct ctl_table ipv4_table[] = {
92303 },
92304 {
92305 .procname = "ip_local_reserved_ports",
92306 - .data = NULL, /* initialized in sysctl_ipv4_init */
92307 + .data = sysctl_local_reserved_ports,
92308 .maxlen = 65536,
92309 .mode = 0644,
92310 .proc_handler = proc_do_large_bitmap,
92311 @@ -847,11 +849,10 @@ static struct ctl_table ipv4_net_table[] = {
92312
92313 static __net_init int ipv4_sysctl_init_net(struct net *net)
92314 {
92315 - struct ctl_table *table;
92316 + ctl_table_no_const *table = NULL;
92317
92318 - table = ipv4_net_table;
92319 if (!net_eq(net, &init_net)) {
92320 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
92321 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
92322 if (table == NULL)
92323 goto err_alloc;
92324
92325 @@ -886,15 +887,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
92326
92327 tcp_init_mem(net);
92328
92329 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92330 + if (!net_eq(net, &init_net))
92331 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
92332 + else
92333 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
92334 if (net->ipv4.ipv4_hdr == NULL)
92335 goto err_reg;
92336
92337 return 0;
92338
92339 err_reg:
92340 - if (!net_eq(net, &init_net))
92341 - kfree(table);
92342 + kfree(table);
92343 err_alloc:
92344 return -ENOMEM;
92345 }
92346 @@ -916,16 +919,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
92347 static __init int sysctl_ipv4_init(void)
92348 {
92349 struct ctl_table_header *hdr;
92350 - struct ctl_table *i;
92351 -
92352 - for (i = ipv4_table; i->procname; i++) {
92353 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
92354 - i->data = sysctl_local_reserved_ports;
92355 - break;
92356 - }
92357 - }
92358 - if (!i->procname)
92359 - return -EINVAL;
92360
92361 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
92362 if (hdr == NULL)
92363 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
92364 index 3ca2139..c4cc060 100644
92365 --- a/net/ipv4/tcp_input.c
92366 +++ b/net/ipv4/tcp_input.c
92367 @@ -4379,7 +4379,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
92368 * simplifies code)
92369 */
92370 static void
92371 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
92372 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
92373 struct sk_buff *head, struct sk_buff *tail,
92374 u32 start, u32 end)
92375 {
92376 @@ -5465,6 +5465,7 @@ discard:
92377 tcp_paws_reject(&tp->rx_opt, 0))
92378 goto discard_and_undo;
92379
92380 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
92381 if (th->syn) {
92382 /* We see SYN without ACK. It is attempt of
92383 * simultaneous connect with crossed SYNs.
92384 @@ -5515,6 +5516,7 @@ discard:
92385 goto discard;
92386 #endif
92387 }
92388 +#endif
92389 /* "fifth, if neither of the SYN or RST bits is set then
92390 * drop the segment and return."
92391 */
92392 @@ -5560,7 +5562,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
92393 goto discard;
92394
92395 if (th->syn) {
92396 - if (th->fin)
92397 + if (th->fin || th->urg || th->psh)
92398 goto discard;
92399 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
92400 return 1;
92401 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
92402 index b299da5..097db06 100644
92403 --- a/net/ipv4/tcp_ipv4.c
92404 +++ b/net/ipv4/tcp_ipv4.c
92405 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
92406 EXPORT_SYMBOL(sysctl_tcp_low_latency);
92407
92408
92409 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92410 +extern int grsec_enable_blackhole;
92411 +#endif
92412 +
92413 #ifdef CONFIG_TCP_MD5SIG
92414 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
92415 __be32 daddr, __be32 saddr, const struct tcphdr *th);
92416 @@ -1830,6 +1834,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
92417 return 0;
92418
92419 reset:
92420 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92421 + if (!grsec_enable_blackhole)
92422 +#endif
92423 tcp_v4_send_reset(rsk, skb);
92424 discard:
92425 kfree_skb(skb);
92426 @@ -1975,12 +1982,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
92427 TCP_SKB_CB(skb)->sacked = 0;
92428
92429 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
92430 - if (!sk)
92431 + if (!sk) {
92432 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92433 + ret = 1;
92434 +#endif
92435 goto no_tcp_socket;
92436 -
92437 + }
92438 process:
92439 - if (sk->sk_state == TCP_TIME_WAIT)
92440 + if (sk->sk_state == TCP_TIME_WAIT) {
92441 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92442 + ret = 2;
92443 +#endif
92444 goto do_time_wait;
92445 + }
92446
92447 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
92448 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
92449 @@ -2034,6 +2048,10 @@ csum_error:
92450 bad_packet:
92451 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
92452 } else {
92453 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92454 + if (!grsec_enable_blackhole || (ret == 1 &&
92455 + (skb->dev->flags & IFF_LOOPBACK)))
92456 +#endif
92457 tcp_v4_send_reset(NULL, skb);
92458 }
92459
92460 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
92461 index ab1c086..2a8d76b 100644
92462 --- a/net/ipv4/tcp_minisocks.c
92463 +++ b/net/ipv4/tcp_minisocks.c
92464 @@ -27,6 +27,10 @@
92465 #include <net/inet_common.h>
92466 #include <net/xfrm.h>
92467
92468 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92469 +extern int grsec_enable_blackhole;
92470 +#endif
92471 +
92472 int sysctl_tcp_syncookies __read_mostly = 1;
92473 EXPORT_SYMBOL(sysctl_tcp_syncookies);
92474
92475 @@ -715,7 +719,10 @@ embryonic_reset:
92476 * avoid becoming vulnerable to outside attack aiming at
92477 * resetting legit local connections.
92478 */
92479 - req->rsk_ops->send_reset(sk, skb);
92480 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92481 + if (!grsec_enable_blackhole)
92482 +#endif
92483 + req->rsk_ops->send_reset(sk, skb);
92484 } else if (fastopen) { /* received a valid RST pkt */
92485 reqsk_fastopen_remove(sk, req, true);
92486 tcp_reset(sk);
92487 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
92488 index d4943f6..e7a74a5 100644
92489 --- a/net/ipv4/tcp_probe.c
92490 +++ b/net/ipv4/tcp_probe.c
92491 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
92492 if (cnt + width >= len)
92493 break;
92494
92495 - if (copy_to_user(buf + cnt, tbuf, width))
92496 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
92497 return -EFAULT;
92498 cnt += width;
92499 }
92500 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
92501 index 4b85e6f..22f9ac9 100644
92502 --- a/net/ipv4/tcp_timer.c
92503 +++ b/net/ipv4/tcp_timer.c
92504 @@ -22,6 +22,10 @@
92505 #include <linux/gfp.h>
92506 #include <net/tcp.h>
92507
92508 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92509 +extern int grsec_lastack_retries;
92510 +#endif
92511 +
92512 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
92513 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
92514 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
92515 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
92516 }
92517 }
92518
92519 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92520 + if ((sk->sk_state == TCP_LAST_ACK) &&
92521 + (grsec_lastack_retries > 0) &&
92522 + (grsec_lastack_retries < retry_until))
92523 + retry_until = grsec_lastack_retries;
92524 +#endif
92525 +
92526 if (retransmits_timed_out(sk, retry_until,
92527 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
92528 /* Has it gone just too far? */
92529 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
92530 index 766e6ba..aff2f8d 100644
92531 --- a/net/ipv4/udp.c
92532 +++ b/net/ipv4/udp.c
92533 @@ -87,6 +87,7 @@
92534 #include <linux/types.h>
92535 #include <linux/fcntl.h>
92536 #include <linux/module.h>
92537 +#include <linux/security.h>
92538 #include <linux/socket.h>
92539 #include <linux/sockios.h>
92540 #include <linux/igmp.h>
92541 @@ -112,6 +113,10 @@
92542 #include <net/busy_poll.h>
92543 #include "udp_impl.h"
92544
92545 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92546 +extern int grsec_enable_blackhole;
92547 +#endif
92548 +
92549 struct udp_table udp_table __read_mostly;
92550 EXPORT_SYMBOL(udp_table);
92551
92552 @@ -595,6 +600,9 @@ found:
92553 return s;
92554 }
92555
92556 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
92557 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
92558 +
92559 /*
92560 * This routine is called by the ICMP module when it gets some
92561 * sort of error condition. If err < 0 then the socket should
92562 @@ -891,9 +899,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92563 dport = usin->sin_port;
92564 if (dport == 0)
92565 return -EINVAL;
92566 +
92567 + err = gr_search_udp_sendmsg(sk, usin);
92568 + if (err)
92569 + return err;
92570 } else {
92571 if (sk->sk_state != TCP_ESTABLISHED)
92572 return -EDESTADDRREQ;
92573 +
92574 + err = gr_search_udp_sendmsg(sk, NULL);
92575 + if (err)
92576 + return err;
92577 +
92578 daddr = inet->inet_daddr;
92579 dport = inet->inet_dport;
92580 /* Open fast path for connected socket.
92581 @@ -1137,7 +1154,7 @@ static unsigned int first_packet_length(struct sock *sk)
92582 IS_UDPLITE(sk));
92583 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
92584 IS_UDPLITE(sk));
92585 - atomic_inc(&sk->sk_drops);
92586 + atomic_inc_unchecked(&sk->sk_drops);
92587 __skb_unlink(skb, rcvq);
92588 __skb_queue_tail(&list_kill, skb);
92589 }
92590 @@ -1223,6 +1240,10 @@ try_again:
92591 if (!skb)
92592 goto out;
92593
92594 + err = gr_search_udp_recvmsg(sk, skb);
92595 + if (err)
92596 + goto out_free;
92597 +
92598 ulen = skb->len - sizeof(struct udphdr);
92599 copied = len;
92600 if (copied > ulen)
92601 @@ -1256,7 +1277,7 @@ try_again:
92602 if (unlikely(err)) {
92603 trace_kfree_skb(skb, udp_recvmsg);
92604 if (!peeked) {
92605 - atomic_inc(&sk->sk_drops);
92606 + atomic_inc_unchecked(&sk->sk_drops);
92607 UDP_INC_STATS_USER(sock_net(sk),
92608 UDP_MIB_INERRORS, is_udplite);
92609 }
92610 @@ -1543,7 +1564,7 @@ csum_error:
92611 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
92612 drop:
92613 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
92614 - atomic_inc(&sk->sk_drops);
92615 + atomic_inc_unchecked(&sk->sk_drops);
92616 kfree_skb(skb);
92617 return -1;
92618 }
92619 @@ -1562,7 +1583,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
92620 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
92621
92622 if (!skb1) {
92623 - atomic_inc(&sk->sk_drops);
92624 + atomic_inc_unchecked(&sk->sk_drops);
92625 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
92626 IS_UDPLITE(sk));
92627 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
92628 @@ -1734,6 +1755,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
92629 goto csum_error;
92630
92631 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
92632 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92633 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
92634 +#endif
92635 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
92636
92637 /*
92638 @@ -2166,7 +2190,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
92639 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
92640 0, sock_i_ino(sp),
92641 atomic_read(&sp->sk_refcnt), sp,
92642 - atomic_read(&sp->sk_drops), len);
92643 + atomic_read_unchecked(&sp->sk_drops), len);
92644 }
92645
92646 int udp4_seq_show(struct seq_file *seq, void *v)
92647 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
92648 index 9a459be..c7bc04c 100644
92649 --- a/net/ipv4/xfrm4_policy.c
92650 +++ b/net/ipv4/xfrm4_policy.c
92651 @@ -181,11 +181,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
92652 fl4->flowi4_tos = iph->tos;
92653 }
92654
92655 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
92656 +static int xfrm4_garbage_collect(struct dst_ops *ops)
92657 {
92658 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
92659
92660 - xfrm4_policy_afinfo.garbage_collect(net);
92661 + xfrm_garbage_collect_deferred(net);
92662 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
92663 }
92664
92665 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
92666
92667 static int __net_init xfrm4_net_init(struct net *net)
92668 {
92669 - struct ctl_table *table;
92670 + ctl_table_no_const *table = NULL;
92671 struct ctl_table_header *hdr;
92672
92673 - table = xfrm4_policy_table;
92674 if (!net_eq(net, &init_net)) {
92675 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
92676 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
92677 if (!table)
92678 goto err_alloc;
92679
92680 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
92681 - }
92682 -
92683 - hdr = register_net_sysctl(net, "net/ipv4", table);
92684 + hdr = register_net_sysctl(net, "net/ipv4", table);
92685 + } else
92686 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
92687 if (!hdr)
92688 goto err_reg;
92689
92690 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
92691 return 0;
92692
92693 err_reg:
92694 - if (!net_eq(net, &init_net))
92695 - kfree(table);
92696 + kfree(table);
92697 err_alloc:
92698 return -ENOMEM;
92699 }
92700 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
92701 index 498ea99..42501bc 100644
92702 --- a/net/ipv6/addrconf.c
92703 +++ b/net/ipv6/addrconf.c
92704 @@ -618,7 +618,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
92705 idx = 0;
92706 head = &net->dev_index_head[h];
92707 rcu_read_lock();
92708 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
92709 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
92710 net->dev_base_seq;
92711 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92712 if (idx < s_idx)
92713 @@ -2381,7 +2381,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
92714 p.iph.ihl = 5;
92715 p.iph.protocol = IPPROTO_IPV6;
92716 p.iph.ttl = 64;
92717 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
92718 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
92719
92720 if (ops->ndo_do_ioctl) {
92721 mm_segment_t oldfs = get_fs();
92722 @@ -4030,7 +4030,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
92723 s_ip_idx = ip_idx = cb->args[2];
92724
92725 rcu_read_lock();
92726 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
92727 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
92728 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
92729 idx = 0;
92730 head = &net->dev_index_head[h];
92731 @@ -4651,7 +4651,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
92732 dst_free(&ifp->rt->dst);
92733 break;
92734 }
92735 - atomic_inc(&net->ipv6.dev_addr_genid);
92736 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
92737 }
92738
92739 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
92740 @@ -4671,7 +4671,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
92741 int *valp = ctl->data;
92742 int val = *valp;
92743 loff_t pos = *ppos;
92744 - struct ctl_table lctl;
92745 + ctl_table_no_const lctl;
92746 int ret;
92747
92748 /*
92749 @@ -4756,7 +4756,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
92750 int *valp = ctl->data;
92751 int val = *valp;
92752 loff_t pos = *ppos;
92753 - struct ctl_table lctl;
92754 + ctl_table_no_const lctl;
92755 int ret;
92756
92757 /*
92758 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
92759 index 197e6f4..16d8396 100644
92760 --- a/net/ipv6/datagram.c
92761 +++ b/net/ipv6/datagram.c
92762 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
92763 0,
92764 sock_i_ino(sp),
92765 atomic_read(&sp->sk_refcnt), sp,
92766 - atomic_read(&sp->sk_drops));
92767 + atomic_read_unchecked(&sp->sk_drops));
92768 }
92769 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
92770 index 7cfc8d2..c5394b6 100644
92771 --- a/net/ipv6/icmp.c
92772 +++ b/net/ipv6/icmp.c
92773 @@ -989,7 +989,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
92774
92775 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
92776 {
92777 - struct ctl_table *table;
92778 + ctl_table_no_const *table;
92779
92780 table = kmemdup(ipv6_icmp_table_template,
92781 sizeof(ipv6_icmp_table_template),
92782 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
92783 index 90747f1..76fbb5d 100644
92784 --- a/net/ipv6/ip6_gre.c
92785 +++ b/net/ipv6/ip6_gre.c
92786 @@ -74,7 +74,7 @@ struct ip6gre_net {
92787 struct net_device *fb_tunnel_dev;
92788 };
92789
92790 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
92791 +static struct rtnl_link_ops ip6gre_link_ops;
92792 static int ip6gre_tunnel_init(struct net_device *dev);
92793 static void ip6gre_tunnel_setup(struct net_device *dev);
92794 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
92795 @@ -620,7 +620,7 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb,
92796 struct ip6_tnl *tunnel = netdev_priv(dev);
92797 struct net_device *tdev; /* Device to other host */
92798 struct ipv6hdr *ipv6h; /* Our new IP header */
92799 - unsigned int max_headroom; /* The extra header space needed */
92800 + unsigned int max_headroom = 0; /* The extra header space needed */
92801 int gre_hlen;
92802 struct ipv6_tel_txoption opt;
92803 int mtu;
92804 @@ -693,7 +693,7 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb,
92805 tunnel->err_count = 0;
92806 }
92807
92808 - max_headroom = LL_RESERVED_SPACE(tdev) + gre_hlen + dst->header_len;
92809 + max_headroom += LL_RESERVED_SPACE(tdev) + gre_hlen + dst->header_len;
92810
92811 if (skb_headroom(skb) < max_headroom || skb_shared(skb) ||
92812 (skb_cloned(skb) && !skb_clone_writable(skb, 0))) {
92813 @@ -1288,7 +1288,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
92814 }
92815
92816
92817 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
92818 +static struct inet6_protocol ip6gre_protocol = {
92819 .handler = ip6gre_rcv,
92820 .err_handler = ip6gre_err,
92821 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
92822 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
92823 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
92824 };
92825
92826 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
92827 +static struct rtnl_link_ops ip6gre_link_ops = {
92828 .kind = "ip6gre",
92829 .maxtype = IFLA_GRE_MAX,
92830 .policy = ip6gre_policy,
92831 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
92832 .fill_info = ip6gre_fill_info,
92833 };
92834
92835 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
92836 +static struct rtnl_link_ops ip6gre_tap_ops = {
92837 .kind = "ip6gretap",
92838 .maxtype = IFLA_GRE_MAX,
92839 .policy = ip6gre_policy,
92840 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
92841 index e7ceb6c..44df1c9 100644
92842 --- a/net/ipv6/ip6_output.c
92843 +++ b/net/ipv6/ip6_output.c
92844 @@ -1040,6 +1040,8 @@ static inline int ip6_ufo_append_data(struct sock *sk,
92845 * udp datagram
92846 */
92847 if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) {
92848 + struct frag_hdr fhdr;
92849 +
92850 skb = sock_alloc_send_skb(sk,
92851 hh_len + fragheaderlen + transhdrlen + 20,
92852 (flags & MSG_DONTWAIT), &err);
92853 @@ -1061,12 +1063,6 @@ static inline int ip6_ufo_append_data(struct sock *sk,
92854 skb->protocol = htons(ETH_P_IPV6);
92855 skb->ip_summed = CHECKSUM_PARTIAL;
92856 skb->csum = 0;
92857 - }
92858 -
92859 - err = skb_append_datato_frags(sk,skb, getfrag, from,
92860 - (length - transhdrlen));
92861 - if (!err) {
92862 - struct frag_hdr fhdr;
92863
92864 /* Specify the length of each IPv6 datagram fragment.
92865 * It has to be a multiple of 8.
92866 @@ -1077,15 +1073,10 @@ static inline int ip6_ufo_append_data(struct sock *sk,
92867 ipv6_select_ident(&fhdr, rt);
92868 skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
92869 __skb_queue_tail(&sk->sk_write_queue, skb);
92870 -
92871 - return 0;
92872 }
92873 - /* There is not enough support do UPD LSO,
92874 - * so follow normal path
92875 - */
92876 - kfree_skb(skb);
92877
92878 - return err;
92879 + return skb_append_datato_frags(sk, skb, getfrag, from,
92880 + (length - transhdrlen));
92881 }
92882
92883 static inline struct ipv6_opt_hdr *ip6_opt_dup(struct ipv6_opt_hdr *src,
92884 @@ -1252,27 +1243,27 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
92885 * --yoshfuji
92886 */
92887
92888 + if ((length > mtu) && dontfrag && (sk->sk_protocol == IPPROTO_UDP ||
92889 + sk->sk_protocol == IPPROTO_RAW)) {
92890 + ipv6_local_rxpmtu(sk, fl6, mtu-exthdrlen);
92891 + return -EMSGSIZE;
92892 + }
92893 +
92894 + skb = skb_peek_tail(&sk->sk_write_queue);
92895 cork->length += length;
92896 - if (length > mtu) {
92897 - int proto = sk->sk_protocol;
92898 - if (dontfrag && (proto == IPPROTO_UDP || proto == IPPROTO_RAW)){
92899 - ipv6_local_rxpmtu(sk, fl6, mtu-exthdrlen);
92900 - return -EMSGSIZE;
92901 - }
92902 -
92903 - if (proto == IPPROTO_UDP &&
92904 - (rt->dst.dev->features & NETIF_F_UFO)) {
92905 -
92906 - err = ip6_ufo_append_data(sk, getfrag, from, length,
92907 - hh_len, fragheaderlen,
92908 - transhdrlen, mtu, flags, rt);
92909 - if (err)
92910 - goto error;
92911 - return 0;
92912 - }
92913 + if (((length > mtu) ||
92914 + (skb && skb_is_gso(skb))) &&
92915 + (sk->sk_protocol == IPPROTO_UDP) &&
92916 + (rt->dst.dev->features & NETIF_F_UFO)) {
92917 + err = ip6_ufo_append_data(sk, getfrag, from, length,
92918 + hh_len, fragheaderlen,
92919 + transhdrlen, mtu, flags, rt);
92920 + if (err)
92921 + goto error;
92922 + return 0;
92923 }
92924
92925 - if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL)
92926 + if (!skb)
92927 goto alloc_new_skb;
92928
92929 while (length > 0) {
92930 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
92931 index 46ba243..576f50e 100644
92932 --- a/net/ipv6/ip6_tunnel.c
92933 +++ b/net/ipv6/ip6_tunnel.c
92934 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
92935
92936 static int ip6_tnl_dev_init(struct net_device *dev);
92937 static void ip6_tnl_dev_setup(struct net_device *dev);
92938 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
92939 +static struct rtnl_link_ops ip6_link_ops;
92940
92941 static int ip6_tnl_net_id __read_mostly;
92942 struct ip6_tnl_net {
92943 @@ -1678,7 +1678,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
92944 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
92945 };
92946
92947 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
92948 +static struct rtnl_link_ops ip6_link_ops = {
92949 .kind = "ip6tnl",
92950 .maxtype = IFLA_IPTUN_MAX,
92951 .policy = ip6_tnl_policy,
92952 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
92953 index d1e2e8e..51c19ae 100644
92954 --- a/net/ipv6/ipv6_sockglue.c
92955 +++ b/net/ipv6/ipv6_sockglue.c
92956 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
92957 if (sk->sk_type != SOCK_STREAM)
92958 return -ENOPROTOOPT;
92959
92960 - msg.msg_control = optval;
92961 + msg.msg_control = (void __force_kernel *)optval;
92962 msg.msg_controllen = len;
92963 msg.msg_flags = flags;
92964
92965 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
92966 index 44400c2..8e11f52 100644
92967 --- a/net/ipv6/netfilter/ip6_tables.c
92968 +++ b/net/ipv6/netfilter/ip6_tables.c
92969 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
92970 #endif
92971
92972 static int get_info(struct net *net, void __user *user,
92973 - const int *len, int compat)
92974 + int len, int compat)
92975 {
92976 char name[XT_TABLE_MAXNAMELEN];
92977 struct xt_table *t;
92978 int ret;
92979
92980 - if (*len != sizeof(struct ip6t_getinfo)) {
92981 - duprintf("length %u != %zu\n", *len,
92982 + if (len != sizeof(struct ip6t_getinfo)) {
92983 + duprintf("length %u != %zu\n", len,
92984 sizeof(struct ip6t_getinfo));
92985 return -EINVAL;
92986 }
92987 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
92988 info.size = private->size;
92989 strcpy(info.name, name);
92990
92991 - if (copy_to_user(user, &info, *len) != 0)
92992 + if (copy_to_user(user, &info, len) != 0)
92993 ret = -EFAULT;
92994 else
92995 ret = 0;
92996 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92997
92998 switch (cmd) {
92999 case IP6T_SO_GET_INFO:
93000 - ret = get_info(sock_net(sk), user, len, 1);
93001 + ret = get_info(sock_net(sk), user, *len, 1);
93002 break;
93003 case IP6T_SO_GET_ENTRIES:
93004 ret = compat_get_entries(sock_net(sk), user, len);
93005 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93006
93007 switch (cmd) {
93008 case IP6T_SO_GET_INFO:
93009 - ret = get_info(sock_net(sk), user, len, 0);
93010 + ret = get_info(sock_net(sk), user, *len, 0);
93011 break;
93012
93013 case IP6T_SO_GET_ENTRIES:
93014 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
93015 index dffdc1a..ccc6678 100644
93016 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
93017 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
93018 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
93019
93020 static int nf_ct_frag6_sysctl_register(struct net *net)
93021 {
93022 - struct ctl_table *table;
93023 + ctl_table_no_const *table = NULL;
93024 struct ctl_table_header *hdr;
93025
93026 - table = nf_ct_frag6_sysctl_table;
93027 if (!net_eq(net, &init_net)) {
93028 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
93029 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
93030 GFP_KERNEL);
93031 if (table == NULL)
93032 goto err_alloc;
93033 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93034 table[0].data = &net->nf_frag.frags.timeout;
93035 table[1].data = &net->nf_frag.frags.low_thresh;
93036 table[2].data = &net->nf_frag.frags.high_thresh;
93037 - }
93038 -
93039 - hdr = register_net_sysctl(net, "net/netfilter", table);
93040 + hdr = register_net_sysctl(net, "net/netfilter", table);
93041 + } else
93042 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
93043 if (hdr == NULL)
93044 goto err_reg;
93045
93046 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93047 return 0;
93048
93049 err_reg:
93050 - if (!net_eq(net, &init_net))
93051 - kfree(table);
93052 + kfree(table);
93053 err_alloc:
93054 return -ENOMEM;
93055 }
93056 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
93057 index ab92a36..bb4a528 100644
93058 --- a/net/ipv6/output_core.c
93059 +++ b/net/ipv6/output_core.c
93060 @@ -8,8 +8,8 @@
93061
93062 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93063 {
93064 - static atomic_t ipv6_fragmentation_id;
93065 - int old, new;
93066 + static atomic_unchecked_t ipv6_fragmentation_id;
93067 + int id;
93068
93069 #if IS_ENABLED(CONFIG_IPV6)
93070 if (rt && !(rt->dst.flags & DST_NOPEER)) {
93071 @@ -25,13 +25,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93072 }
93073 }
93074 #endif
93075 - do {
93076 - old = atomic_read(&ipv6_fragmentation_id);
93077 - new = old + 1;
93078 - if (!new)
93079 - new = 1;
93080 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
93081 - fhdr->identification = htonl(new);
93082 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93083 + if (!id)
93084 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93085 + fhdr->identification = htonl(id);
93086 }
93087 EXPORT_SYMBOL(ipv6_select_ident);
93088
93089 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
93090 index 18f19df..b46ada1 100644
93091 --- a/net/ipv6/ping.c
93092 +++ b/net/ipv6/ping.c
93093 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
93094 };
93095 #endif
93096
93097 +static struct pingv6_ops real_pingv6_ops = {
93098 + .ipv6_recv_error = ipv6_recv_error,
93099 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
93100 + .icmpv6_err_convert = icmpv6_err_convert,
93101 + .ipv6_icmp_error = ipv6_icmp_error,
93102 + .ipv6_chk_addr = ipv6_chk_addr,
93103 +};
93104 +
93105 +static struct pingv6_ops dummy_pingv6_ops = {
93106 + .ipv6_recv_error = dummy_ipv6_recv_error,
93107 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
93108 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
93109 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
93110 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
93111 +};
93112 +
93113 int __init pingv6_init(void)
93114 {
93115 #ifdef CONFIG_PROC_FS
93116 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
93117 if (ret)
93118 return ret;
93119 #endif
93120 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
93121 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
93122 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
93123 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
93124 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
93125 + pingv6_ops = &real_pingv6_ops;
93126 return inet6_register_protosw(&pingv6_protosw);
93127 }
93128
93129 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
93130 */
93131 void pingv6_exit(void)
93132 {
93133 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
93134 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
93135 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
93136 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
93137 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
93138 + pingv6_ops = &dummy_pingv6_ops;
93139 #ifdef CONFIG_PROC_FS
93140 unregister_pernet_subsys(&ping_v6_net_ops);
93141 #endif
93142 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
93143 index cdaed47..515edde9 100644
93144 --- a/net/ipv6/raw.c
93145 +++ b/net/ipv6/raw.c
93146 @@ -108,7 +108,7 @@ found:
93147 */
93148 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
93149 {
93150 - struct icmp6hdr *_hdr;
93151 + struct icmp6hdr _hdr;
93152 const struct icmp6hdr *hdr;
93153
93154 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
93155 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
93156 {
93157 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
93158 skb_checksum_complete(skb)) {
93159 - atomic_inc(&sk->sk_drops);
93160 + atomic_inc_unchecked(&sk->sk_drops);
93161 kfree_skb(skb);
93162 return NET_RX_DROP;
93163 }
93164 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93165 struct raw6_sock *rp = raw6_sk(sk);
93166
93167 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
93168 - atomic_inc(&sk->sk_drops);
93169 + atomic_inc_unchecked(&sk->sk_drops);
93170 kfree_skb(skb);
93171 return NET_RX_DROP;
93172 }
93173 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93174
93175 if (inet->hdrincl) {
93176 if (skb_checksum_complete(skb)) {
93177 - atomic_inc(&sk->sk_drops);
93178 + atomic_inc_unchecked(&sk->sk_drops);
93179 kfree_skb(skb);
93180 return NET_RX_DROP;
93181 }
93182 @@ -602,7 +602,7 @@ out:
93183 return err;
93184 }
93185
93186 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
93187 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
93188 struct flowi6 *fl6, struct dst_entry **dstp,
93189 unsigned int flags)
93190 {
93191 @@ -915,12 +915,15 @@ do_confirm:
93192 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
93193 char __user *optval, int optlen)
93194 {
93195 + struct icmp6_filter filter;
93196 +
93197 switch (optname) {
93198 case ICMPV6_FILTER:
93199 if (optlen > sizeof(struct icmp6_filter))
93200 optlen = sizeof(struct icmp6_filter);
93201 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
93202 + if (copy_from_user(&filter, optval, optlen))
93203 return -EFAULT;
93204 + raw6_sk(sk)->filter = filter;
93205 return 0;
93206 default:
93207 return -ENOPROTOOPT;
93208 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93209 char __user *optval, int __user *optlen)
93210 {
93211 int len;
93212 + struct icmp6_filter filter;
93213
93214 switch (optname) {
93215 case ICMPV6_FILTER:
93216 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93217 len = sizeof(struct icmp6_filter);
93218 if (put_user(len, optlen))
93219 return -EFAULT;
93220 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
93221 + filter = raw6_sk(sk)->filter;
93222 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
93223 return -EFAULT;
93224 return 0;
93225 default:
93226 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
93227 index 1aeb473..bea761c 100644
93228 --- a/net/ipv6/reassembly.c
93229 +++ b/net/ipv6/reassembly.c
93230 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
93231
93232 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93233 {
93234 - struct ctl_table *table;
93235 + ctl_table_no_const *table = NULL;
93236 struct ctl_table_header *hdr;
93237
93238 - table = ip6_frags_ns_ctl_table;
93239 if (!net_eq(net, &init_net)) {
93240 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93241 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93242 if (table == NULL)
93243 goto err_alloc;
93244
93245 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93246 /* Don't export sysctls to unprivileged users */
93247 if (net->user_ns != &init_user_ns)
93248 table[0].procname = NULL;
93249 - }
93250 + hdr = register_net_sysctl(net, "net/ipv6", table);
93251 + } else
93252 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
93253
93254 - hdr = register_net_sysctl(net, "net/ipv6", table);
93255 if (hdr == NULL)
93256 goto err_reg;
93257
93258 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93259 return 0;
93260
93261 err_reg:
93262 - if (!net_eq(net, &init_net))
93263 - kfree(table);
93264 + kfree(table);
93265 err_alloc:
93266 return -ENOMEM;
93267 }
93268 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
93269 index 8d9a93ed..cd89616 100644
93270 --- a/net/ipv6/route.c
93271 +++ b/net/ipv6/route.c
93272 @@ -2926,7 +2926,7 @@ struct ctl_table ipv6_route_table_template[] = {
93273
93274 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
93275 {
93276 - struct ctl_table *table;
93277 + ctl_table_no_const *table;
93278
93279 table = kmemdup(ipv6_route_table_template,
93280 sizeof(ipv6_route_table_template),
93281 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
93282 index 21b25dd..9a43e37 100644
93283 --- a/net/ipv6/sit.c
93284 +++ b/net/ipv6/sit.c
93285 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
93286 static void ipip6_dev_free(struct net_device *dev);
93287 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
93288 __be32 *v4dst);
93289 -static struct rtnl_link_ops sit_link_ops __read_mostly;
93290 +static struct rtnl_link_ops sit_link_ops;
93291
93292 static int sit_net_id __read_mostly;
93293 struct sit_net {
93294 @@ -1547,7 +1547,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
93295 #endif
93296 };
93297
93298 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
93299 +static struct rtnl_link_ops sit_link_ops = {
93300 .kind = "sit",
93301 .maxtype = IFLA_IPTUN_MAX,
93302 .policy = ipip6_policy,
93303 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
93304 index 107b2f1..72741a9 100644
93305 --- a/net/ipv6/sysctl_net_ipv6.c
93306 +++ b/net/ipv6/sysctl_net_ipv6.c
93307 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
93308
93309 static int __net_init ipv6_sysctl_net_init(struct net *net)
93310 {
93311 - struct ctl_table *ipv6_table;
93312 + ctl_table_no_const *ipv6_table;
93313 struct ctl_table *ipv6_route_table;
93314 struct ctl_table *ipv6_icmp_table;
93315 int err;
93316 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
93317 index 6e1649d..75ddb4c 100644
93318 --- a/net/ipv6/tcp_ipv6.c
93319 +++ b/net/ipv6/tcp_ipv6.c
93320 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
93321 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
93322 }
93323
93324 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93325 +extern int grsec_enable_blackhole;
93326 +#endif
93327 +
93328 static void tcp_v6_hash(struct sock *sk)
93329 {
93330 if (sk->sk_state != TCP_CLOSE) {
93331 @@ -1399,6 +1403,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
93332 return 0;
93333
93334 reset:
93335 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93336 + if (!grsec_enable_blackhole)
93337 +#endif
93338 tcp_v6_send_reset(sk, skb);
93339 discard:
93340 if (opt_skb)
93341 @@ -1427,7 +1434,7 @@ ipv6_pktoptions:
93342 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
93343 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
93344 if (np->rxopt.bits.rxtclass)
93345 - np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
93346 + np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
93347 if (ipv6_opt_accepted(sk, opt_skb)) {
93348 skb_set_owner_r(opt_skb, sk);
93349 opt_skb = xchg(&np->pktoptions, opt_skb);
93350 @@ -1481,12 +1488,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
93351 TCP_SKB_CB(skb)->sacked = 0;
93352
93353 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93354 - if (!sk)
93355 + if (!sk) {
93356 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93357 + ret = 1;
93358 +#endif
93359 goto no_tcp_socket;
93360 + }
93361
93362 process:
93363 - if (sk->sk_state == TCP_TIME_WAIT)
93364 + if (sk->sk_state == TCP_TIME_WAIT) {
93365 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93366 + ret = 2;
93367 +#endif
93368 goto do_time_wait;
93369 + }
93370
93371 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
93372 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93373 @@ -1538,6 +1553,10 @@ csum_error:
93374 bad_packet:
93375 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93376 } else {
93377 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93378 + if (!grsec_enable_blackhole || (ret == 1 &&
93379 + (skb->dev->flags & IFF_LOOPBACK)))
93380 +#endif
93381 tcp_v6_send_reset(NULL, skb);
93382 }
93383
93384 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
93385 index f405815..45a68a6 100644
93386 --- a/net/ipv6/udp.c
93387 +++ b/net/ipv6/udp.c
93388 @@ -53,6 +53,10 @@
93389 #include <trace/events/skb.h>
93390 #include "udp_impl.h"
93391
93392 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93393 +extern int grsec_enable_blackhole;
93394 +#endif
93395 +
93396 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
93397 {
93398 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
93399 @@ -420,7 +424,7 @@ try_again:
93400 if (unlikely(err)) {
93401 trace_kfree_skb(skb, udpv6_recvmsg);
93402 if (!peeked) {
93403 - atomic_inc(&sk->sk_drops);
93404 + atomic_inc_unchecked(&sk->sk_drops);
93405 if (is_udp4)
93406 UDP_INC_STATS_USER(sock_net(sk),
93407 UDP_MIB_INERRORS,
93408 @@ -666,7 +670,7 @@ csum_error:
93409 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93410 drop:
93411 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93412 - atomic_inc(&sk->sk_drops);
93413 + atomic_inc_unchecked(&sk->sk_drops);
93414 kfree_skb(skb);
93415 return -1;
93416 }
93417 @@ -724,7 +728,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93418 if (likely(skb1 == NULL))
93419 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93420 if (!skb1) {
93421 - atomic_inc(&sk->sk_drops);
93422 + atomic_inc_unchecked(&sk->sk_drops);
93423 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93424 IS_UDPLITE(sk));
93425 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93426 @@ -864,6 +868,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93427 goto csum_error;
93428
93429 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93430 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93431 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93432 +#endif
93433 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
93434
93435 kfree_skb(skb);
93436 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
93437 index 23ed03d..6532e67 100644
93438 --- a/net/ipv6/xfrm6_policy.c
93439 +++ b/net/ipv6/xfrm6_policy.c
93440 @@ -207,11 +207,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
93441 }
93442 }
93443
93444 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
93445 +static int xfrm6_garbage_collect(struct dst_ops *ops)
93446 {
93447 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
93448
93449 - xfrm6_policy_afinfo.garbage_collect(net);
93450 + xfrm_garbage_collect_deferred(net);
93451 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
93452 }
93453
93454 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
93455
93456 static int __net_init xfrm6_net_init(struct net *net)
93457 {
93458 - struct ctl_table *table;
93459 + ctl_table_no_const *table = NULL;
93460 struct ctl_table_header *hdr;
93461
93462 - table = xfrm6_policy_table;
93463 if (!net_eq(net, &init_net)) {
93464 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
93465 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
93466 if (!table)
93467 goto err_alloc;
93468
93469 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
93470 - }
93471 + hdr = register_net_sysctl(net, "net/ipv6", table);
93472 + } else
93473 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
93474
93475 - hdr = register_net_sysctl(net, "net/ipv6", table);
93476 if (!hdr)
93477 goto err_reg;
93478
93479 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
93480 return 0;
93481
93482 err_reg:
93483 - if (!net_eq(net, &init_net))
93484 - kfree(table);
93485 + kfree(table);
93486 err_alloc:
93487 return -ENOMEM;
93488 }
93489 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
93490 index 41ac7938..75e3bb1 100644
93491 --- a/net/irda/ircomm/ircomm_tty.c
93492 +++ b/net/irda/ircomm/ircomm_tty.c
93493 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93494 add_wait_queue(&port->open_wait, &wait);
93495
93496 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
93497 - __FILE__, __LINE__, tty->driver->name, port->count);
93498 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93499
93500 spin_lock_irqsave(&port->lock, flags);
93501 if (!tty_hung_up_p(filp))
93502 - port->count--;
93503 + atomic_dec(&port->count);
93504 port->blocked_open++;
93505 spin_unlock_irqrestore(&port->lock, flags);
93506
93507 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93508 }
93509
93510 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
93511 - __FILE__, __LINE__, tty->driver->name, port->count);
93512 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93513
93514 schedule();
93515 }
93516 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
93517
93518 spin_lock_irqsave(&port->lock, flags);
93519 if (!tty_hung_up_p(filp))
93520 - port->count++;
93521 + atomic_inc(&port->count);
93522 port->blocked_open--;
93523 spin_unlock_irqrestore(&port->lock, flags);
93524
93525 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
93526 - __FILE__, __LINE__, tty->driver->name, port->count);
93527 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
93528
93529 if (!retval)
93530 port->flags |= ASYNC_NORMAL_ACTIVE;
93531 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
93532
93533 /* ++ is not atomic, so this should be protected - Jean II */
93534 spin_lock_irqsave(&self->port.lock, flags);
93535 - self->port.count++;
93536 + atomic_inc(&self->port.count);
93537 spin_unlock_irqrestore(&self->port.lock, flags);
93538 tty_port_tty_set(&self->port, tty);
93539
93540 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
93541 - self->line, self->port.count);
93542 + self->line, atomic_read(&self->port.count));
93543
93544 /* Not really used by us, but lets do it anyway */
93545 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
93546 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
93547 tty_kref_put(port->tty);
93548 }
93549 port->tty = NULL;
93550 - port->count = 0;
93551 + atomic_set(&port->count, 0);
93552 spin_unlock_irqrestore(&port->lock, flags);
93553
93554 wake_up_interruptible(&port->open_wait);
93555 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
93556 seq_putc(m, '\n');
93557
93558 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
93559 - seq_printf(m, "Open count: %d\n", self->port.count);
93560 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
93561 seq_printf(m, "Max data size: %d\n", self->max_data_size);
93562 seq_printf(m, "Max header size: %d\n", self->max_header_size);
93563
93564 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
93565 index 168aff5..9d43132 100644
93566 --- a/net/iucv/af_iucv.c
93567 +++ b/net/iucv/af_iucv.c
93568 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
93569
93570 write_lock_bh(&iucv_sk_list.lock);
93571
93572 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
93573 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
93574 while (__iucv_get_sock_by_name(name)) {
93575 sprintf(name, "%08x",
93576 - atomic_inc_return(&iucv_sk_list.autobind_name));
93577 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
93578 }
93579
93580 write_unlock_bh(&iucv_sk_list.lock);
93581 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
93582 index cd5b8ec..f205e6b 100644
93583 --- a/net/iucv/iucv.c
93584 +++ b/net/iucv/iucv.c
93585 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
93586 return NOTIFY_OK;
93587 }
93588
93589 -static struct notifier_block __refdata iucv_cpu_notifier = {
93590 +static struct notifier_block iucv_cpu_notifier = {
93591 .notifier_call = iucv_cpu_notify,
93592 };
93593
93594 diff --git a/net/key/af_key.c b/net/key/af_key.c
93595 index ab8bd2c..cd2d641 100644
93596 --- a/net/key/af_key.c
93597 +++ b/net/key/af_key.c
93598 @@ -3048,10 +3048,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
93599 static u32 get_acqseq(void)
93600 {
93601 u32 res;
93602 - static atomic_t acqseq;
93603 + static atomic_unchecked_t acqseq;
93604
93605 do {
93606 - res = atomic_inc_return(&acqseq);
93607 + res = atomic_inc_return_unchecked(&acqseq);
93608 } while (!res);
93609 return res;
93610 }
93611 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
93612 index 43dd752..63a23bc 100644
93613 --- a/net/mac80211/cfg.c
93614 +++ b/net/mac80211/cfg.c
93615 @@ -820,7 +820,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
93616 ret = ieee80211_vif_use_channel(sdata, chandef,
93617 IEEE80211_CHANCTX_EXCLUSIVE);
93618 }
93619 - } else if (local->open_count == local->monitors) {
93620 + } else if (local_read(&local->open_count) == local->monitors) {
93621 local->_oper_chandef = *chandef;
93622 ieee80211_hw_config(local, 0);
93623 }
93624 @@ -2941,7 +2941,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
93625 else
93626 local->probe_req_reg--;
93627
93628 - if (!local->open_count)
93629 + if (!local_read(&local->open_count))
93630 break;
93631
93632 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
93633 @@ -3404,8 +3404,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
93634 if (chanctx_conf) {
93635 *chandef = chanctx_conf->def;
93636 ret = 0;
93637 - } else if (local->open_count > 0 &&
93638 - local->open_count == local->monitors &&
93639 + } else if (local_read(&local->open_count) > 0 &&
93640 + local_read(&local->open_count) == local->monitors &&
93641 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
93642 if (local->use_chanctx)
93643 *chandef = local->monitor_chandef;
93644 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
93645 index 8412a30..6e00181 100644
93646 --- a/net/mac80211/ieee80211_i.h
93647 +++ b/net/mac80211/ieee80211_i.h
93648 @@ -28,6 +28,7 @@
93649 #include <net/ieee80211_radiotap.h>
93650 #include <net/cfg80211.h>
93651 #include <net/mac80211.h>
93652 +#include <asm/local.h>
93653 #include "key.h"
93654 #include "sta_info.h"
93655 #include "debug.h"
93656 @@ -907,7 +908,7 @@ struct ieee80211_local {
93657 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
93658 spinlock_t queue_stop_reason_lock;
93659
93660 - int open_count;
93661 + local_t open_count;
93662 int monitors, cooked_mntrs;
93663 /* number of interfaces with corresponding FIF_ flags */
93664 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
93665 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
93666 index cc11759..11d5541 100644
93667 --- a/net/mac80211/iface.c
93668 +++ b/net/mac80211/iface.c
93669 @@ -511,7 +511,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
93670 break;
93671 }
93672
93673 - if (local->open_count == 0) {
93674 + if (local_read(&local->open_count) == 0) {
93675 res = drv_start(local);
93676 if (res)
93677 goto err_del_bss;
93678 @@ -558,7 +558,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
93679 res = drv_add_interface(local, sdata);
93680 if (res)
93681 goto err_stop;
93682 - } else if (local->monitors == 0 && local->open_count == 0) {
93683 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
93684 res = ieee80211_add_virtual_monitor(local);
93685 if (res)
93686 goto err_stop;
93687 @@ -666,7 +666,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
93688 atomic_inc(&local->iff_promiscs);
93689
93690 if (coming_up)
93691 - local->open_count++;
93692 + local_inc(&local->open_count);
93693
93694 if (hw_reconf_flags)
93695 ieee80211_hw_config(local, hw_reconf_flags);
93696 @@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
93697 err_del_interface:
93698 drv_remove_interface(local, sdata);
93699 err_stop:
93700 - if (!local->open_count)
93701 + if (!local_read(&local->open_count))
93702 drv_stop(local);
93703 err_del_bss:
93704 sdata->bss = NULL;
93705 @@ -841,7 +841,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
93706 }
93707
93708 if (going_down)
93709 - local->open_count--;
93710 + local_dec(&local->open_count);
93711
93712 switch (sdata->vif.type) {
93713 case NL80211_IFTYPE_AP_VLAN:
93714 @@ -908,7 +908,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
93715 }
93716 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
93717
93718 - if (local->open_count == 0)
93719 + if (local_read(&local->open_count) == 0)
93720 ieee80211_clear_tx_pending(local);
93721
93722 /*
93723 @@ -948,7 +948,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
93724
93725 ieee80211_recalc_ps(local, -1);
93726
93727 - if (local->open_count == 0) {
93728 + if (local_read(&local->open_count) == 0) {
93729 ieee80211_stop_device(local);
93730
93731 /* no reconfiguring after stop! */
93732 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
93733 ieee80211_configure_filter(local);
93734 ieee80211_hw_config(local, hw_reconf_flags);
93735
93736 - if (local->monitors == local->open_count)
93737 + if (local->monitors == local_read(&local->open_count))
93738 ieee80211_add_virtual_monitor(local);
93739 }
93740
93741 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
93742 index 091088a..daf43c7 100644
93743 --- a/net/mac80211/main.c
93744 +++ b/net/mac80211/main.c
93745 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
93746 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
93747 IEEE80211_CONF_CHANGE_POWER);
93748
93749 - if (changed && local->open_count) {
93750 + if (changed && local_read(&local->open_count)) {
93751 ret = drv_config(local, changed);
93752 /*
93753 * Goal:
93754 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
93755 index 3401262..d5cd68d 100644
93756 --- a/net/mac80211/pm.c
93757 +++ b/net/mac80211/pm.c
93758 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
93759 struct ieee80211_sub_if_data *sdata;
93760 struct sta_info *sta;
93761
93762 - if (!local->open_count)
93763 + if (!local_read(&local->open_count))
93764 goto suspend;
93765
93766 ieee80211_scan_cancel(local);
93767 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
93768 cancel_work_sync(&local->dynamic_ps_enable_work);
93769 del_timer_sync(&local->dynamic_ps_timer);
93770
93771 - local->wowlan = wowlan && local->open_count;
93772 + local->wowlan = wowlan && local_read(&local->open_count);
93773 if (local->wowlan) {
93774 int err = drv_suspend(local, wowlan);
93775 if (err < 0) {
93776 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
93777 WARN_ON(!list_empty(&local->chanctx_list));
93778
93779 /* stop hardware - this must stop RX */
93780 - if (local->open_count)
93781 + if (local_read(&local->open_count))
93782 ieee80211_stop_device(local);
93783
93784 suspend:
93785 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
93786 index 30d58d2..449ac8e 100644
93787 --- a/net/mac80211/rate.c
93788 +++ b/net/mac80211/rate.c
93789 @@ -718,7 +718,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
93790
93791 ASSERT_RTNL();
93792
93793 - if (local->open_count)
93794 + if (local_read(&local->open_count))
93795 return -EBUSY;
93796
93797 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
93798 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
93799 index c97a065..ff61928 100644
93800 --- a/net/mac80211/rc80211_pid_debugfs.c
93801 +++ b/net/mac80211/rc80211_pid_debugfs.c
93802 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
93803
93804 spin_unlock_irqrestore(&events->lock, status);
93805
93806 - if (copy_to_user(buf, pb, p))
93807 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
93808 return -EFAULT;
93809
93810 return p;
93811 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
93812 index 2265445..ba14971 100644
93813 --- a/net/mac80211/util.c
93814 +++ b/net/mac80211/util.c
93815 @@ -1452,7 +1452,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
93816 }
93817 #endif
93818 /* everything else happens only if HW was up & running */
93819 - if (!local->open_count)
93820 + if (!local_read(&local->open_count))
93821 goto wake_up;
93822
93823 /*
93824 @@ -1677,7 +1677,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
93825 local->in_reconfig = false;
93826 barrier();
93827
93828 - if (local->monitors == local->open_count && local->monitors > 0)
93829 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
93830 ieee80211_add_virtual_monitor(local);
93831
93832 /*
93833 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
93834 index 56d22ca..87c778f 100644
93835 --- a/net/netfilter/Kconfig
93836 +++ b/net/netfilter/Kconfig
93837 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
93838
93839 To compile it as a module, choose M here. If unsure, say N.
93840
93841 +config NETFILTER_XT_MATCH_GRADM
93842 + tristate '"gradm" match support'
93843 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
93844 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
93845 + ---help---
93846 + The gradm match allows to match on grsecurity RBAC being enabled.
93847 + It is useful when iptables rules are applied early on bootup to
93848 + prevent connections to the machine (except from a trusted host)
93849 + while the RBAC system is disabled.
93850 +
93851 config NETFILTER_XT_MATCH_HASHLIMIT
93852 tristate '"hashlimit" match support'
93853 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
93854 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
93855 index a1abf87..dbcb7ee 100644
93856 --- a/net/netfilter/Makefile
93857 +++ b/net/netfilter/Makefile
93858 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
93859 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
93860 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
93861 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
93862 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
93863 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
93864 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
93865 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
93866 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
93867 index f771390..145b765 100644
93868 --- a/net/netfilter/ipset/ip_set_core.c
93869 +++ b/net/netfilter/ipset/ip_set_core.c
93870 @@ -1820,7 +1820,7 @@ done:
93871 return ret;
93872 }
93873
93874 -static struct nf_sockopt_ops so_set __read_mostly = {
93875 +static struct nf_sockopt_ops so_set = {
93876 .pf = PF_INET,
93877 .get_optmin = SO_IP_SET,
93878 .get_optmax = SO_IP_SET + 1,
93879 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
93880 index 4c8e5c0..5a79b4d 100644
93881 --- a/net/netfilter/ipvs/ip_vs_conn.c
93882 +++ b/net/netfilter/ipvs/ip_vs_conn.c
93883 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
93884 /* Increase the refcnt counter of the dest */
93885 ip_vs_dest_hold(dest);
93886
93887 - conn_flags = atomic_read(&dest->conn_flags);
93888 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
93889 if (cp->protocol != IPPROTO_UDP)
93890 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
93891 flags = cp->flags;
93892 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
93893
93894 cp->control = NULL;
93895 atomic_set(&cp->n_control, 0);
93896 - atomic_set(&cp->in_pkts, 0);
93897 + atomic_set_unchecked(&cp->in_pkts, 0);
93898
93899 cp->packet_xmit = NULL;
93900 cp->app = NULL;
93901 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
93902
93903 /* Don't drop the entry if its number of incoming packets is not
93904 located in [0, 8] */
93905 - i = atomic_read(&cp->in_pkts);
93906 + i = atomic_read_unchecked(&cp->in_pkts);
93907 if (i > 8 || i < 0) return 0;
93908
93909 if (!todrop_rate[i]) return 0;
93910 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
93911 index 4f69e83..da2d8bf 100644
93912 --- a/net/netfilter/ipvs/ip_vs_core.c
93913 +++ b/net/netfilter/ipvs/ip_vs_core.c
93914 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
93915 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
93916 /* do not touch skb anymore */
93917
93918 - atomic_inc(&cp->in_pkts);
93919 + atomic_inc_unchecked(&cp->in_pkts);
93920 ip_vs_conn_put(cp);
93921 return ret;
93922 }
93923 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
93924 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
93925 pkts = sysctl_sync_threshold(ipvs);
93926 else
93927 - pkts = atomic_add_return(1, &cp->in_pkts);
93928 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
93929
93930 if (ipvs->sync_state & IP_VS_STATE_MASTER)
93931 ip_vs_sync_conn(net, cp, pkts);
93932 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
93933 index c8148e4..eff604f 100644
93934 --- a/net/netfilter/ipvs/ip_vs_ctl.c
93935 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
93936 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
93937 */
93938 ip_vs_rs_hash(ipvs, dest);
93939 }
93940 - atomic_set(&dest->conn_flags, conn_flags);
93941 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
93942
93943 /* bind the service */
93944 if (!dest->svc) {
93945 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
93946 * align with netns init in ip_vs_control_net_init()
93947 */
93948
93949 -static struct ctl_table vs_vars[] = {
93950 +static ctl_table_no_const vs_vars[] __read_only = {
93951 {
93952 .procname = "amemthresh",
93953 .maxlen = sizeof(int),
93954 @@ -2078,7 +2078,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
93955 " %-7s %-6d %-10d %-10d\n",
93956 &dest->addr.in6,
93957 ntohs(dest->port),
93958 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
93959 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
93960 atomic_read(&dest->weight),
93961 atomic_read(&dest->activeconns),
93962 atomic_read(&dest->inactconns));
93963 @@ -2089,7 +2089,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
93964 "%-7s %-6d %-10d %-10d\n",
93965 ntohl(dest->addr.ip),
93966 ntohs(dest->port),
93967 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
93968 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
93969 atomic_read(&dest->weight),
93970 atomic_read(&dest->activeconns),
93971 atomic_read(&dest->inactconns));
93972 @@ -2567,7 +2567,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
93973
93974 entry.addr = dest->addr.ip;
93975 entry.port = dest->port;
93976 - entry.conn_flags = atomic_read(&dest->conn_flags);
93977 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
93978 entry.weight = atomic_read(&dest->weight);
93979 entry.u_threshold = dest->u_threshold;
93980 entry.l_threshold = dest->l_threshold;
93981 @@ -3110,7 +3110,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
93982 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
93983 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
93984 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
93985 - (atomic_read(&dest->conn_flags) &
93986 + (atomic_read_unchecked(&dest->conn_flags) &
93987 IP_VS_CONN_F_FWD_MASK)) ||
93988 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
93989 atomic_read(&dest->weight)) ||
93990 @@ -3700,7 +3700,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
93991 {
93992 int idx;
93993 struct netns_ipvs *ipvs = net_ipvs(net);
93994 - struct ctl_table *tbl;
93995 + ctl_table_no_const *tbl;
93996
93997 atomic_set(&ipvs->dropentry, 0);
93998 spin_lock_init(&ipvs->dropentry_lock);
93999 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
94000 index 1383b0e..a486da1 100644
94001 --- a/net/netfilter/ipvs/ip_vs_lblc.c
94002 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
94003 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
94004 * IPVS LBLC sysctl table
94005 */
94006 #ifdef CONFIG_SYSCTL
94007 -static struct ctl_table vs_vars_table[] = {
94008 +static ctl_table_no_const vs_vars_table[] __read_only = {
94009 {
94010 .procname = "lblc_expiration",
94011 .data = NULL,
94012 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
94013 index 3cd85b2..dfab2b8 100644
94014 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
94015 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
94016 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
94017 * IPVS LBLCR sysctl table
94018 */
94019
94020 -static struct ctl_table vs_vars_table[] = {
94021 +static ctl_table_no_const vs_vars_table[] __read_only = {
94022 {
94023 .procname = "lblcr_expiration",
94024 .data = NULL,
94025 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
94026 index f448471..995f131 100644
94027 --- a/net/netfilter/ipvs/ip_vs_sync.c
94028 +++ b/net/netfilter/ipvs/ip_vs_sync.c
94029 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
94030 cp = cp->control;
94031 if (cp) {
94032 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94033 - pkts = atomic_add_return(1, &cp->in_pkts);
94034 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94035 else
94036 pkts = sysctl_sync_threshold(ipvs);
94037 ip_vs_sync_conn(net, cp->control, pkts);
94038 @@ -771,7 +771,7 @@ control:
94039 if (!cp)
94040 return;
94041 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94042 - pkts = atomic_add_return(1, &cp->in_pkts);
94043 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94044 else
94045 pkts = sysctl_sync_threshold(ipvs);
94046 goto sloop;
94047 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
94048
94049 if (opt)
94050 memcpy(&cp->in_seq, opt, sizeof(*opt));
94051 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94052 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94053 cp->state = state;
94054 cp->old_state = cp->state;
94055 /*
94056 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
94057 index b75ff64..0c51bbe 100644
94058 --- a/net/netfilter/ipvs/ip_vs_xmit.c
94059 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
94060 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
94061 else
94062 rc = NF_ACCEPT;
94063 /* do not touch skb anymore */
94064 - atomic_inc(&cp->in_pkts);
94065 + atomic_inc_unchecked(&cp->in_pkts);
94066 goto out;
94067 }
94068
94069 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
94070 else
94071 rc = NF_ACCEPT;
94072 /* do not touch skb anymore */
94073 - atomic_inc(&cp->in_pkts);
94074 + atomic_inc_unchecked(&cp->in_pkts);
94075 goto out;
94076 }
94077
94078 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
94079 index 2d3030a..7ba1c0a 100644
94080 --- a/net/netfilter/nf_conntrack_acct.c
94081 +++ b/net/netfilter/nf_conntrack_acct.c
94082 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
94083 #ifdef CONFIG_SYSCTL
94084 static int nf_conntrack_acct_init_sysctl(struct net *net)
94085 {
94086 - struct ctl_table *table;
94087 + ctl_table_no_const *table;
94088
94089 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
94090 GFP_KERNEL);
94091 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
94092 index 0283bae..5febcb0 100644
94093 --- a/net/netfilter/nf_conntrack_core.c
94094 +++ b/net/netfilter/nf_conntrack_core.c
94095 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
94096 #define DYING_NULLS_VAL ((1<<30)+1)
94097 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
94098
94099 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94100 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
94101 +#endif
94102 +
94103 int nf_conntrack_init_net(struct net *net)
94104 {
94105 int ret;
94106 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
94107 goto err_stat;
94108 }
94109
94110 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94111 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
94112 +#else
94113 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
94114 +#endif
94115 if (!net->ct.slabname) {
94116 ret = -ENOMEM;
94117 goto err_slabname;
94118 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
94119 index 1df1761..ce8b88a 100644
94120 --- a/net/netfilter/nf_conntrack_ecache.c
94121 +++ b/net/netfilter/nf_conntrack_ecache.c
94122 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
94123 #ifdef CONFIG_SYSCTL
94124 static int nf_conntrack_event_init_sysctl(struct net *net)
94125 {
94126 - struct ctl_table *table;
94127 + ctl_table_no_const *table;
94128
94129 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
94130 GFP_KERNEL);
94131 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
94132 index 974a2a4..52cc6ff 100644
94133 --- a/net/netfilter/nf_conntrack_helper.c
94134 +++ b/net/netfilter/nf_conntrack_helper.c
94135 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
94136
94137 static int nf_conntrack_helper_init_sysctl(struct net *net)
94138 {
94139 - struct ctl_table *table;
94140 + ctl_table_no_const *table;
94141
94142 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
94143 GFP_KERNEL);
94144 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
94145 index 0ab9636..cea3c6a 100644
94146 --- a/net/netfilter/nf_conntrack_proto.c
94147 +++ b/net/netfilter/nf_conntrack_proto.c
94148 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
94149
94150 static void
94151 nf_ct_unregister_sysctl(struct ctl_table_header **header,
94152 - struct ctl_table **table,
94153 + ctl_table_no_const **table,
94154 unsigned int users)
94155 {
94156 if (users > 0)
94157 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
94158 index a99b6c3..cb372f9 100644
94159 --- a/net/netfilter/nf_conntrack_proto_dccp.c
94160 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
94161 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94162 const char *msg;
94163 u_int8_t state;
94164
94165 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94166 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94167 BUG_ON(dh == NULL);
94168
94169 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
94170 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94171 out_invalid:
94172 if (LOG_INVALID(net, IPPROTO_DCCP))
94173 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
94174 - NULL, msg);
94175 + NULL, "%s", msg);
94176 return false;
94177 }
94178
94179 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
94180 u_int8_t type, old_state, new_state;
94181 enum ct_dccp_roles role;
94182
94183 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94184 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94185 BUG_ON(dh == NULL);
94186 type = dh->dccph_type;
94187
94188 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94189 unsigned int cscov;
94190 const char *msg;
94191
94192 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94193 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94194 if (dh == NULL) {
94195 msg = "nf_ct_dccp: short packet ";
94196 goto out_invalid;
94197 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94198
94199 out_invalid:
94200 if (LOG_INVALID(net, IPPROTO_DCCP))
94201 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
94202 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
94203 return -NF_ACCEPT;
94204 }
94205
94206 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
94207 index f641751..d3c5b51 100644
94208 --- a/net/netfilter/nf_conntrack_standalone.c
94209 +++ b/net/netfilter/nf_conntrack_standalone.c
94210 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
94211
94212 static int nf_conntrack_standalone_init_sysctl(struct net *net)
94213 {
94214 - struct ctl_table *table;
94215 + ctl_table_no_const *table;
94216
94217 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
94218 GFP_KERNEL);
94219 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
94220 index 902fb0a..87f7fdb 100644
94221 --- a/net/netfilter/nf_conntrack_timestamp.c
94222 +++ b/net/netfilter/nf_conntrack_timestamp.c
94223 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
94224 #ifdef CONFIG_SYSCTL
94225 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
94226 {
94227 - struct ctl_table *table;
94228 + ctl_table_no_const *table;
94229
94230 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
94231 GFP_KERNEL);
94232 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
94233 index 85296d4..8becdec 100644
94234 --- a/net/netfilter/nf_log.c
94235 +++ b/net/netfilter/nf_log.c
94236 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
94237
94238 #ifdef CONFIG_SYSCTL
94239 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
94240 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
94241 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
94242
94243 static int nf_log_proc_dostring(struct ctl_table *table, int write,
94244 void __user *buffer, size_t *lenp, loff_t *ppos)
94245 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
94246 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
94247 mutex_unlock(&nf_log_mutex);
94248 } else {
94249 + ctl_table_no_const nf_log_table = *table;
94250 +
94251 mutex_lock(&nf_log_mutex);
94252 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
94253 lockdep_is_held(&nf_log_mutex));
94254 if (!logger)
94255 - table->data = "NONE";
94256 + nf_log_table.data = "NONE";
94257 else
94258 - table->data = logger->name;
94259 - r = proc_dostring(table, write, buffer, lenp, ppos);
94260 + nf_log_table.data = logger->name;
94261 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
94262 mutex_unlock(&nf_log_mutex);
94263 }
94264
94265 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
94266 index f042ae5..30ea486 100644
94267 --- a/net/netfilter/nf_sockopt.c
94268 +++ b/net/netfilter/nf_sockopt.c
94269 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
94270 }
94271 }
94272
94273 - list_add(&reg->list, &nf_sockopts);
94274 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
94275 out:
94276 mutex_unlock(&nf_sockopt_mutex);
94277 return ret;
94278 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
94279 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
94280 {
94281 mutex_lock(&nf_sockopt_mutex);
94282 - list_del(&reg->list);
94283 + pax_list_del((struct list_head *)&reg->list);
94284 mutex_unlock(&nf_sockopt_mutex);
94285 }
94286 EXPORT_SYMBOL(nf_unregister_sockopt);
94287 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
94288 index d92cc31..e46f350 100644
94289 --- a/net/netfilter/nfnetlink_log.c
94290 +++ b/net/netfilter/nfnetlink_log.c
94291 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
94292 struct nfnl_log_net {
94293 spinlock_t instances_lock;
94294 struct hlist_head instance_table[INSTANCE_BUCKETS];
94295 - atomic_t global_seq;
94296 + atomic_unchecked_t global_seq;
94297 };
94298
94299 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
94300 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
94301 /* global sequence number */
94302 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
94303 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
94304 - htonl(atomic_inc_return(&log->global_seq))))
94305 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
94306 goto nla_put_failure;
94307
94308 if (data_len) {
94309 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
94310 new file mode 100644
94311 index 0000000..c566332
94312 --- /dev/null
94313 +++ b/net/netfilter/xt_gradm.c
94314 @@ -0,0 +1,51 @@
94315 +/*
94316 + * gradm match for netfilter
94317 + * Copyright © Zbigniew Krzystolik, 2010
94318 + *
94319 + * This program is free software; you can redistribute it and/or modify
94320 + * it under the terms of the GNU General Public License; either version
94321 + * 2 or 3 as published by the Free Software Foundation.
94322 + */
94323 +#include <linux/module.h>
94324 +#include <linux/moduleparam.h>
94325 +#include <linux/skbuff.h>
94326 +#include <linux/netfilter/x_tables.h>
94327 +#include <linux/grsecurity.h>
94328 +#include <linux/netfilter/xt_gradm.h>
94329 +
94330 +static bool
94331 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
94332 +{
94333 + const struct xt_gradm_mtinfo *info = par->matchinfo;
94334 + bool retval = false;
94335 + if (gr_acl_is_enabled())
94336 + retval = true;
94337 + return retval ^ info->invflags;
94338 +}
94339 +
94340 +static struct xt_match gradm_mt_reg __read_mostly = {
94341 + .name = "gradm",
94342 + .revision = 0,
94343 + .family = NFPROTO_UNSPEC,
94344 + .match = gradm_mt,
94345 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
94346 + .me = THIS_MODULE,
94347 +};
94348 +
94349 +static int __init gradm_mt_init(void)
94350 +{
94351 + return xt_register_match(&gradm_mt_reg);
94352 +}
94353 +
94354 +static void __exit gradm_mt_exit(void)
94355 +{
94356 + xt_unregister_match(&gradm_mt_reg);
94357 +}
94358 +
94359 +module_init(gradm_mt_init);
94360 +module_exit(gradm_mt_exit);
94361 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
94362 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
94363 +MODULE_LICENSE("GPL");
94364 +MODULE_ALIAS("ipt_gradm");
94365 +MODULE_ALIAS("ip6t_gradm");
94366 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
94367 index 4fe4fb4..87a89e5 100644
94368 --- a/net/netfilter/xt_statistic.c
94369 +++ b/net/netfilter/xt_statistic.c
94370 @@ -19,7 +19,7 @@
94371 #include <linux/module.h>
94372
94373 struct xt_statistic_priv {
94374 - atomic_t count;
94375 + atomic_unchecked_t count;
94376 } ____cacheline_aligned_in_smp;
94377
94378 MODULE_LICENSE("GPL");
94379 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
94380 break;
94381 case XT_STATISTIC_MODE_NTH:
94382 do {
94383 - oval = atomic_read(&info->master->count);
94384 + oval = atomic_read_unchecked(&info->master->count);
94385 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
94386 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
94387 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
94388 if (nval == 0)
94389 ret = !ret;
94390 break;
94391 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
94392 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
94393 if (info->master == NULL)
94394 return -ENOMEM;
94395 - atomic_set(&info->master->count, info->u.nth.count);
94396 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
94397
94398 return 0;
94399 }
94400 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
94401 index 0c61b59..941bddd 100644
94402 --- a/net/netlink/af_netlink.c
94403 +++ b/net/netlink/af_netlink.c
94404 @@ -219,7 +219,7 @@ static void netlink_overrun(struct sock *sk)
94405 sk->sk_error_report(sk);
94406 }
94407 }
94408 - atomic_inc(&sk->sk_drops);
94409 + atomic_inc_unchecked(&sk->sk_drops);
94410 }
94411
94412 static void netlink_rcv_wake(struct sock *sk)
94413 @@ -2925,7 +2925,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
94414 sk_wmem_alloc_get(s),
94415 nlk->cb,
94416 atomic_read(&s->sk_refcnt),
94417 - atomic_read(&s->sk_drops),
94418 + atomic_read_unchecked(&s->sk_drops),
94419 sock_i_ino(s)
94420 );
94421
94422 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
94423 index 0c741ce..f8c8ca7 100644
94424 --- a/net/netlink/genetlink.c
94425 +++ b/net/netlink/genetlink.c
94426 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
94427 goto errout;
94428 }
94429
94430 + pax_open_kernel();
94431 if (ops->dumpit)
94432 - ops->flags |= GENL_CMD_CAP_DUMP;
94433 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
94434 if (ops->doit)
94435 - ops->flags |= GENL_CMD_CAP_DO;
94436 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
94437 if (ops->policy)
94438 - ops->flags |= GENL_CMD_CAP_HASPOL;
94439 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
94440 + pax_close_kernel();
94441
94442 genl_lock_all();
94443 - list_add_tail(&ops->ops_list, &family->ops_list);
94444 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
94445 genl_unlock_all();
94446
94447 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
94448 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
94449 err = 0;
94450 errout:
94451 return err;
94452 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
94453 genl_lock_all();
94454 list_for_each_entry(rc, &family->ops_list, ops_list) {
94455 if (rc == ops) {
94456 - list_del(&ops->ops_list);
94457 + pax_list_del((struct list_head *)&ops->ops_list);
94458 genl_unlock_all();
94459 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
94460 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
94461 return 0;
94462 }
94463 }
94464 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
94465 index 698814b..7cfde4e 100644
94466 --- a/net/netrom/af_netrom.c
94467 +++ b/net/netrom/af_netrom.c
94468 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
94469 *uaddr_len = sizeof(struct full_sockaddr_ax25);
94470 } else {
94471 sax->fsa_ax25.sax25_family = AF_NETROM;
94472 - sax->fsa_ax25.sax25_ndigis = 0;
94473 sax->fsa_ax25.sax25_call = nr->source_addr;
94474 *uaddr_len = sizeof(struct sockaddr_ax25);
94475 }
94476 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
94477 index 75c8bbf..ee9be59 100644
94478 --- a/net/packet/af_packet.c
94479 +++ b/net/packet/af_packet.c
94480 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
94481
94482 spin_lock(&sk->sk_receive_queue.lock);
94483 po->stats.stats1.tp_packets++;
94484 - skb->dropcount = atomic_read(&sk->sk_drops);
94485 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
94486 __skb_queue_tail(&sk->sk_receive_queue, skb);
94487 spin_unlock(&sk->sk_receive_queue.lock);
94488 sk->sk_data_ready(sk, skb->len);
94489 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
94490 drop_n_acct:
94491 spin_lock(&sk->sk_receive_queue.lock);
94492 po->stats.stats1.tp_drops++;
94493 - atomic_inc(&sk->sk_drops);
94494 + atomic_inc_unchecked(&sk->sk_drops);
94495 spin_unlock(&sk->sk_receive_queue.lock);
94496
94497 drop_n_restore:
94498 @@ -2640,6 +2640,7 @@ out:
94499
94500 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
94501 {
94502 + struct sock_extended_err ee;
94503 struct sock_exterr_skb *serr;
94504 struct sk_buff *skb, *skb2;
94505 int copied, err;
94506 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
94507 sock_recv_timestamp(msg, sk, skb);
94508
94509 serr = SKB_EXT_ERR(skb);
94510 + ee = serr->ee;
94511 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
94512 - sizeof(serr->ee), &serr->ee);
94513 + sizeof ee, &ee);
94514
94515 msg->msg_flags |= MSG_ERRQUEUE;
94516 err = copied;
94517 @@ -3283,7 +3285,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
94518 case PACKET_HDRLEN:
94519 if (len > sizeof(int))
94520 len = sizeof(int);
94521 - if (copy_from_user(&val, optval, len))
94522 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
94523 return -EFAULT;
94524 switch (val) {
94525 case TPACKET_V1:
94526 @@ -3326,7 +3328,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
94527 len = lv;
94528 if (put_user(len, optlen))
94529 return -EFAULT;
94530 - if (copy_to_user(optval, data, len))
94531 + if (len > sizeof(st) || copy_to_user(optval, data, len))
94532 return -EFAULT;
94533 return 0;
94534 }
94535 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
94536 index e774117..900b8b7 100644
94537 --- a/net/phonet/pep.c
94538 +++ b/net/phonet/pep.c
94539 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
94540
94541 case PNS_PEP_CTRL_REQ:
94542 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
94543 - atomic_inc(&sk->sk_drops);
94544 + atomic_inc_unchecked(&sk->sk_drops);
94545 break;
94546 }
94547 __skb_pull(skb, 4);
94548 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
94549 }
94550
94551 if (pn->rx_credits == 0) {
94552 - atomic_inc(&sk->sk_drops);
94553 + atomic_inc_unchecked(&sk->sk_drops);
94554 err = -ENOBUFS;
94555 break;
94556 }
94557 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
94558 }
94559
94560 if (pn->rx_credits == 0) {
94561 - atomic_inc(&sk->sk_drops);
94562 + atomic_inc_unchecked(&sk->sk_drops);
94563 err = NET_RX_DROP;
94564 break;
94565 }
94566 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
94567 index 1afd138..0b42453 100644
94568 --- a/net/phonet/socket.c
94569 +++ b/net/phonet/socket.c
94570 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
94571 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
94572 sock_i_ino(sk),
94573 atomic_read(&sk->sk_refcnt), sk,
94574 - atomic_read(&sk->sk_drops), &len);
94575 + atomic_read_unchecked(&sk->sk_drops), &len);
94576 }
94577 seq_printf(seq, "%*s\n", 127 - len, "");
94578 return 0;
94579 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
94580 index c02a8c4..3c5b600 100644
94581 --- a/net/phonet/sysctl.c
94582 +++ b/net/phonet/sysctl.c
94583 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
94584 {
94585 int ret;
94586 int range[2] = {local_port_range[0], local_port_range[1]};
94587 - struct ctl_table tmp = {
94588 + ctl_table_no_const tmp = {
94589 .data = &range,
94590 .maxlen = sizeof(range),
94591 .mode = table->mode,
94592 diff --git a/net/rds/cong.c b/net/rds/cong.c
94593 index e5b65ac..f3b6fb7 100644
94594 --- a/net/rds/cong.c
94595 +++ b/net/rds/cong.c
94596 @@ -78,7 +78,7 @@
94597 * finds that the saved generation number is smaller than the global generation
94598 * number, it wakes up the process.
94599 */
94600 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
94601 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
94602
94603 /*
94604 * Congestion monitoring
94605 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
94606 rdsdebug("waking map %p for %pI4\n",
94607 map, &map->m_addr);
94608 rds_stats_inc(s_cong_update_received);
94609 - atomic_inc(&rds_cong_generation);
94610 + atomic_inc_unchecked(&rds_cong_generation);
94611 if (waitqueue_active(&map->m_waitq))
94612 wake_up(&map->m_waitq);
94613 if (waitqueue_active(&rds_poll_waitq))
94614 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
94615
94616 int rds_cong_updated_since(unsigned long *recent)
94617 {
94618 - unsigned long gen = atomic_read(&rds_cong_generation);
94619 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
94620
94621 if (likely(*recent == gen))
94622 return 0;
94623 diff --git a/net/rds/ib.h b/net/rds/ib.h
94624 index 7280ab8..e04f4ea 100644
94625 --- a/net/rds/ib.h
94626 +++ b/net/rds/ib.h
94627 @@ -128,7 +128,7 @@ struct rds_ib_connection {
94628 /* sending acks */
94629 unsigned long i_ack_flags;
94630 #ifdef KERNEL_HAS_ATOMIC64
94631 - atomic64_t i_ack_next; /* next ACK to send */
94632 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
94633 #else
94634 spinlock_t i_ack_lock; /* protect i_ack_next */
94635 u64 i_ack_next; /* next ACK to send */
94636 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
94637 index 31b74f5..dc1fbfa 100644
94638 --- a/net/rds/ib_cm.c
94639 +++ b/net/rds/ib_cm.c
94640 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
94641 /* Clear the ACK state */
94642 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
94643 #ifdef KERNEL_HAS_ATOMIC64
94644 - atomic64_set(&ic->i_ack_next, 0);
94645 + atomic64_set_unchecked(&ic->i_ack_next, 0);
94646 #else
94647 ic->i_ack_next = 0;
94648 #endif
94649 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
94650 index 8eb9501..0c386ff 100644
94651 --- a/net/rds/ib_recv.c
94652 +++ b/net/rds/ib_recv.c
94653 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
94654 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
94655 int ack_required)
94656 {
94657 - atomic64_set(&ic->i_ack_next, seq);
94658 + atomic64_set_unchecked(&ic->i_ack_next, seq);
94659 if (ack_required) {
94660 smp_mb__before_clear_bit();
94661 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
94662 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
94663 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
94664 smp_mb__after_clear_bit();
94665
94666 - return atomic64_read(&ic->i_ack_next);
94667 + return atomic64_read_unchecked(&ic->i_ack_next);
94668 }
94669 #endif
94670
94671 diff --git a/net/rds/iw.h b/net/rds/iw.h
94672 index 04ce3b1..48119a6 100644
94673 --- a/net/rds/iw.h
94674 +++ b/net/rds/iw.h
94675 @@ -134,7 +134,7 @@ struct rds_iw_connection {
94676 /* sending acks */
94677 unsigned long i_ack_flags;
94678 #ifdef KERNEL_HAS_ATOMIC64
94679 - atomic64_t i_ack_next; /* next ACK to send */
94680 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
94681 #else
94682 spinlock_t i_ack_lock; /* protect i_ack_next */
94683 u64 i_ack_next; /* next ACK to send */
94684 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
94685 index a91e1db..cf3053f 100644
94686 --- a/net/rds/iw_cm.c
94687 +++ b/net/rds/iw_cm.c
94688 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
94689 /* Clear the ACK state */
94690 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
94691 #ifdef KERNEL_HAS_ATOMIC64
94692 - atomic64_set(&ic->i_ack_next, 0);
94693 + atomic64_set_unchecked(&ic->i_ack_next, 0);
94694 #else
94695 ic->i_ack_next = 0;
94696 #endif
94697 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
94698 index 4503335..db566b4 100644
94699 --- a/net/rds/iw_recv.c
94700 +++ b/net/rds/iw_recv.c
94701 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
94702 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
94703 int ack_required)
94704 {
94705 - atomic64_set(&ic->i_ack_next, seq);
94706 + atomic64_set_unchecked(&ic->i_ack_next, seq);
94707 if (ack_required) {
94708 smp_mb__before_clear_bit();
94709 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
94710 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
94711 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
94712 smp_mb__after_clear_bit();
94713
94714 - return atomic64_read(&ic->i_ack_next);
94715 + return atomic64_read_unchecked(&ic->i_ack_next);
94716 }
94717 #endif
94718
94719 diff --git a/net/rds/rds.h b/net/rds/rds.h
94720 index ec1d731..90a3a8d 100644
94721 --- a/net/rds/rds.h
94722 +++ b/net/rds/rds.h
94723 @@ -449,7 +449,7 @@ struct rds_transport {
94724 void (*sync_mr)(void *trans_private, int direction);
94725 void (*free_mr)(void *trans_private, int invalidate);
94726 void (*flush_mrs)(void);
94727 -};
94728 +} __do_const;
94729
94730 struct rds_sock {
94731 struct sock rs_sk;
94732 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
94733 index edac9ef..16bcb98 100644
94734 --- a/net/rds/tcp.c
94735 +++ b/net/rds/tcp.c
94736 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
94737 int val = 1;
94738
94739 set_fs(KERNEL_DS);
94740 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
94741 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
94742 sizeof(val));
94743 set_fs(oldfs);
94744 }
94745 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
94746 index 81cf5a4..b5826ff 100644
94747 --- a/net/rds/tcp_send.c
94748 +++ b/net/rds/tcp_send.c
94749 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
94750
94751 oldfs = get_fs();
94752 set_fs(KERNEL_DS);
94753 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
94754 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
94755 sizeof(val));
94756 set_fs(oldfs);
94757 }
94758 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
94759 index e61aa60..f07cc89 100644
94760 --- a/net/rxrpc/af_rxrpc.c
94761 +++ b/net/rxrpc/af_rxrpc.c
94762 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
94763 __be32 rxrpc_epoch;
94764
94765 /* current debugging ID */
94766 -atomic_t rxrpc_debug_id;
94767 +atomic_unchecked_t rxrpc_debug_id;
94768
94769 /* count of skbs currently in use */
94770 atomic_t rxrpc_n_skbs;
94771 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
94772 index e4d9cbc..b229649 100644
94773 --- a/net/rxrpc/ar-ack.c
94774 +++ b/net/rxrpc/ar-ack.c
94775 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
94776
94777 _enter("{%d,%d,%d,%d},",
94778 call->acks_hard, call->acks_unacked,
94779 - atomic_read(&call->sequence),
94780 + atomic_read_unchecked(&call->sequence),
94781 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
94782
94783 stop = 0;
94784 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
94785
94786 /* each Tx packet has a new serial number */
94787 sp->hdr.serial =
94788 - htonl(atomic_inc_return(&call->conn->serial));
94789 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
94790
94791 hdr = (struct rxrpc_header *) txb->head;
94792 hdr->serial = sp->hdr.serial;
94793 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
94794 */
94795 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
94796 {
94797 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
94798 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
94799 }
94800
94801 /*
94802 @@ -629,7 +629,7 @@ process_further:
94803
94804 latest = ntohl(sp->hdr.serial);
94805 hard = ntohl(ack.firstPacket);
94806 - tx = atomic_read(&call->sequence);
94807 + tx = atomic_read_unchecked(&call->sequence);
94808
94809 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
94810 latest,
94811 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
94812 goto maybe_reschedule;
94813
94814 send_ACK_with_skew:
94815 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
94816 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
94817 ntohl(ack.serial));
94818 send_ACK:
94819 mtu = call->conn->trans->peer->if_mtu;
94820 @@ -1173,7 +1173,7 @@ send_ACK:
94821 ackinfo.rxMTU = htonl(5692);
94822 ackinfo.jumbo_max = htonl(4);
94823
94824 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
94825 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
94826 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
94827 ntohl(hdr.serial),
94828 ntohs(ack.maxSkew),
94829 @@ -1191,7 +1191,7 @@ send_ACK:
94830 send_message:
94831 _debug("send message");
94832
94833 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
94834 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
94835 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
94836 send_message_2:
94837
94838 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
94839 index a3bbb36..3341fb9 100644
94840 --- a/net/rxrpc/ar-call.c
94841 +++ b/net/rxrpc/ar-call.c
94842 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
94843 spin_lock_init(&call->lock);
94844 rwlock_init(&call->state_lock);
94845 atomic_set(&call->usage, 1);
94846 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
94847 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
94848 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
94849
94850 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
94851 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
94852 index 4106ca9..a338d7a 100644
94853 --- a/net/rxrpc/ar-connection.c
94854 +++ b/net/rxrpc/ar-connection.c
94855 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
94856 rwlock_init(&conn->lock);
94857 spin_lock_init(&conn->state_lock);
94858 atomic_set(&conn->usage, 1);
94859 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
94860 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
94861 conn->avail_calls = RXRPC_MAXCALLS;
94862 conn->size_align = 4;
94863 conn->header_size = sizeof(struct rxrpc_header);
94864 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
94865 index e7ed43a..6afa140 100644
94866 --- a/net/rxrpc/ar-connevent.c
94867 +++ b/net/rxrpc/ar-connevent.c
94868 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
94869
94870 len = iov[0].iov_len + iov[1].iov_len;
94871
94872 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
94873 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
94874 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
94875
94876 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
94877 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
94878 index 529572f..c758ca7 100644
94879 --- a/net/rxrpc/ar-input.c
94880 +++ b/net/rxrpc/ar-input.c
94881 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
94882 /* track the latest serial number on this connection for ACK packet
94883 * information */
94884 serial = ntohl(sp->hdr.serial);
94885 - hi_serial = atomic_read(&call->conn->hi_serial);
94886 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
94887 while (serial > hi_serial)
94888 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
94889 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
94890 serial);
94891
94892 /* request ACK generation for any ACK or DATA packet that requests
94893 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
94894 index a693aca..81e7293 100644
94895 --- a/net/rxrpc/ar-internal.h
94896 +++ b/net/rxrpc/ar-internal.h
94897 @@ -272,8 +272,8 @@ struct rxrpc_connection {
94898 int error; /* error code for local abort */
94899 int debug_id; /* debug ID for printks */
94900 unsigned int call_counter; /* call ID counter */
94901 - atomic_t serial; /* packet serial number counter */
94902 - atomic_t hi_serial; /* highest serial number received */
94903 + atomic_unchecked_t serial; /* packet serial number counter */
94904 + atomic_unchecked_t hi_serial; /* highest serial number received */
94905 u8 avail_calls; /* number of calls available */
94906 u8 size_align; /* data size alignment (for security) */
94907 u8 header_size; /* rxrpc + security header size */
94908 @@ -346,7 +346,7 @@ struct rxrpc_call {
94909 spinlock_t lock;
94910 rwlock_t state_lock; /* lock for state transition */
94911 atomic_t usage;
94912 - atomic_t sequence; /* Tx data packet sequence counter */
94913 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
94914 u32 abort_code; /* local/remote abort code */
94915 enum { /* current state of call */
94916 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
94917 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
94918 */
94919 extern atomic_t rxrpc_n_skbs;
94920 extern __be32 rxrpc_epoch;
94921 -extern atomic_t rxrpc_debug_id;
94922 +extern atomic_unchecked_t rxrpc_debug_id;
94923 extern struct workqueue_struct *rxrpc_workqueue;
94924
94925 /*
94926 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
94927 index 87f7135..74d3703 100644
94928 --- a/net/rxrpc/ar-local.c
94929 +++ b/net/rxrpc/ar-local.c
94930 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
94931 spin_lock_init(&local->lock);
94932 rwlock_init(&local->services_lock);
94933 atomic_set(&local->usage, 1);
94934 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
94935 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
94936 memcpy(&local->srx, srx, sizeof(*srx));
94937 }
94938
94939 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
94940 index e1ac183..b43e10e 100644
94941 --- a/net/rxrpc/ar-output.c
94942 +++ b/net/rxrpc/ar-output.c
94943 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
94944 sp->hdr.cid = call->cid;
94945 sp->hdr.callNumber = call->call_id;
94946 sp->hdr.seq =
94947 - htonl(atomic_inc_return(&call->sequence));
94948 + htonl(atomic_inc_return_unchecked(&call->sequence));
94949 sp->hdr.serial =
94950 - htonl(atomic_inc_return(&conn->serial));
94951 + htonl(atomic_inc_return_unchecked(&conn->serial));
94952 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
94953 sp->hdr.userStatus = 0;
94954 sp->hdr.securityIndex = conn->security_ix;
94955 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
94956 index bebaa43..2644591 100644
94957 --- a/net/rxrpc/ar-peer.c
94958 +++ b/net/rxrpc/ar-peer.c
94959 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
94960 INIT_LIST_HEAD(&peer->error_targets);
94961 spin_lock_init(&peer->lock);
94962 atomic_set(&peer->usage, 1);
94963 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
94964 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
94965 memcpy(&peer->srx, srx, sizeof(*srx));
94966
94967 rxrpc_assess_MTU_size(peer);
94968 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
94969 index 38047f7..9f48511 100644
94970 --- a/net/rxrpc/ar-proc.c
94971 +++ b/net/rxrpc/ar-proc.c
94972 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
94973 atomic_read(&conn->usage),
94974 rxrpc_conn_states[conn->state],
94975 key_serial(conn->key),
94976 - atomic_read(&conn->serial),
94977 - atomic_read(&conn->hi_serial));
94978 + atomic_read_unchecked(&conn->serial),
94979 + atomic_read_unchecked(&conn->hi_serial));
94980
94981 return 0;
94982 }
94983 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
94984 index 92df566..87ec1bf 100644
94985 --- a/net/rxrpc/ar-transport.c
94986 +++ b/net/rxrpc/ar-transport.c
94987 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
94988 spin_lock_init(&trans->client_lock);
94989 rwlock_init(&trans->conn_lock);
94990 atomic_set(&trans->usage, 1);
94991 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
94992 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
94993
94994 if (peer->srx.transport.family == AF_INET) {
94995 switch (peer->srx.transport_type) {
94996 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
94997 index f226709..0e735a8 100644
94998 --- a/net/rxrpc/rxkad.c
94999 +++ b/net/rxrpc/rxkad.c
95000 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
95001
95002 len = iov[0].iov_len + iov[1].iov_len;
95003
95004 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95005 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95006 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
95007
95008 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95009 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
95010
95011 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
95012
95013 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
95014 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95015 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
95016
95017 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
95018 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
95019 index 09ffcc9..3eff2c2 100644
95020 --- a/net/sctp/ipv6.c
95021 +++ b/net/sctp/ipv6.c
95022 @@ -210,44 +210,23 @@ out:
95023 in6_dev_put(idev);
95024 }
95025
95026 -/* Based on tcp_v6_xmit() in tcp_ipv6.c. */
95027 static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
95028 {
95029 struct sock *sk = skb->sk;
95030 struct ipv6_pinfo *np = inet6_sk(sk);
95031 - struct flowi6 fl6;
95032 -
95033 - memset(&fl6, 0, sizeof(fl6));
95034 -
95035 - fl6.flowi6_proto = sk->sk_protocol;
95036 -
95037 - /* Fill in the dest address from the route entry passed with the skb
95038 - * and the source address from the transport.
95039 - */
95040 - fl6.daddr = transport->ipaddr.v6.sin6_addr;
95041 - fl6.saddr = transport->saddr.v6.sin6_addr;
95042 -
95043 - fl6.flowlabel = np->flow_label;
95044 - IP6_ECN_flow_xmit(sk, fl6.flowlabel);
95045 - if (ipv6_addr_type(&fl6.saddr) & IPV6_ADDR_LINKLOCAL)
95046 - fl6.flowi6_oif = transport->saddr.v6.sin6_scope_id;
95047 - else
95048 - fl6.flowi6_oif = sk->sk_bound_dev_if;
95049 -
95050 - if (np->opt && np->opt->srcrt) {
95051 - struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
95052 - fl6.daddr = *rt0->addr;
95053 - }
95054 + struct flowi6 *fl6 = &transport->fl.u.ip6;
95055
95056 pr_debug("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n", __func__, skb,
95057 - skb->len, &fl6.saddr, &fl6.daddr);
95058 + skb->len, &fl6->saddr, &fl6->daddr);
95059
95060 - SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
95061 + IP6_ECN_flow_xmit(sk, fl6->flowlabel);
95062
95063 if (!(transport->param_flags & SPP_PMTUD_ENABLE))
95064 skb->local_df = 1;
95065
95066 - return ip6_xmit(sk, skb, &fl6, np->opt, np->tclass);
95067 + SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
95068 +
95069 + return ip6_xmit(sk, skb, fl6, np->opt, np->tclass);
95070 }
95071
95072 /* Returns the dst cache entry for the given source and destination ip
95073 @@ -260,10 +239,12 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
95074 struct dst_entry *dst = NULL;
95075 struct flowi6 *fl6 = &fl->u.ip6;
95076 struct sctp_bind_addr *bp;
95077 + struct ipv6_pinfo *np = inet6_sk(sk);
95078 struct sctp_sockaddr_entry *laddr;
95079 union sctp_addr *baddr = NULL;
95080 union sctp_addr *daddr = &t->ipaddr;
95081 union sctp_addr dst_saddr;
95082 + struct in6_addr *final_p, final;
95083 __u8 matchlen = 0;
95084 __u8 bmatchlen;
95085 sctp_scope_t scope;
95086 @@ -287,7 +268,8 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
95087 pr_debug("src=%pI6 - ", &fl6->saddr);
95088 }
95089
95090 - dst = ip6_dst_lookup_flow(sk, fl6, NULL, false);
95091 + final_p = fl6_update_dst(fl6, np->opt, &final);
95092 + dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
95093 if (!asoc || saddr)
95094 goto out;
95095
95096 @@ -339,10 +321,12 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
95097 }
95098 }
95099 rcu_read_unlock();
95100 +
95101 if (baddr) {
95102 fl6->saddr = baddr->v6.sin6_addr;
95103 fl6->fl6_sport = baddr->v6.sin6_port;
95104 - dst = ip6_dst_lookup_flow(sk, fl6, NULL, false);
95105 + final_p = fl6_update_dst(fl6, np->opt, &final);
95106 + dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
95107 }
95108
95109 out:
95110 @@ -984,7 +968,7 @@ static const struct inet6_protocol sctpv6_protocol = {
95111 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
95112 };
95113
95114 -static struct sctp_af sctp_af_inet6 = {
95115 +static struct sctp_af sctp_af_inet6 __read_only = {
95116 .sa_family = AF_INET6,
95117 .sctp_xmit = sctp_v6_xmit,
95118 .setsockopt = ipv6_setsockopt,
95119 @@ -1016,7 +1000,7 @@ static struct sctp_af sctp_af_inet6 = {
95120 #endif
95121 };
95122
95123 -static struct sctp_pf sctp_pf_inet6 = {
95124 +static struct sctp_pf sctp_pf_inet6 __read_only = {
95125 .event_msgname = sctp_inet6_event_msgname,
95126 .skb_msgname = sctp_inet6_skb_msgname,
95127 .af_supported = sctp_inet6_af_supported,
95128 @@ -1041,7 +1025,7 @@ void sctp_v6_pf_init(void)
95129
95130 void sctp_v6_pf_exit(void)
95131 {
95132 - list_del(&sctp_af_inet6.list);
95133 + pax_list_del(&sctp_af_inet6.list);
95134 }
95135
95136 /* Initialize IPv6 support and register with socket layer. */
95137 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
95138 index 62526c4..36a13c5 100644
95139 --- a/net/sctp/proc.c
95140 +++ b/net/sctp/proc.c
95141 @@ -343,7 +343,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
95142 seq_printf(seq,
95143 "%8pK %8pK %-3d %-3d %-2d %-4d "
95144 "%4d %8d %8d %7d %5lu %-5d %5d ",
95145 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
95146 + assoc, sk,
95147 + sctp_sk(sk)->type, sk->sk_state,
95148 assoc->state, hash,
95149 assoc->assoc_id,
95150 assoc->sndbuf_used,
95151 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
95152 index 4a17494d..f7e3fa0 100644
95153 --- a/net/sctp/protocol.c
95154 +++ b/net/sctp/protocol.c
95155 @@ -838,8 +838,10 @@ int sctp_register_af(struct sctp_af *af)
95156 return 0;
95157 }
95158
95159 + pax_open_kernel();
95160 INIT_LIST_HEAD(&af->list);
95161 - list_add_tail(&af->list, &sctp_address_families);
95162 + pax_close_kernel();
95163 + pax_list_add_tail(&af->list, &sctp_address_families);
95164 return 1;
95165 }
95166
95167 @@ -969,7 +971,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
95168
95169 static struct sctp_af sctp_af_inet;
95170
95171 -static struct sctp_pf sctp_pf_inet = {
95172 +static struct sctp_pf sctp_pf_inet __read_only = {
95173 .event_msgname = sctp_inet_event_msgname,
95174 .skb_msgname = sctp_inet_skb_msgname,
95175 .af_supported = sctp_inet_af_supported,
95176 @@ -1040,7 +1042,7 @@ static const struct net_protocol sctp_protocol = {
95177 };
95178
95179 /* IPv4 address related functions. */
95180 -static struct sctp_af sctp_af_inet = {
95181 +static struct sctp_af sctp_af_inet __read_only = {
95182 .sa_family = AF_INET,
95183 .sctp_xmit = sctp_v4_xmit,
95184 .setsockopt = ip_setsockopt,
95185 @@ -1125,7 +1127,7 @@ static void sctp_v4_pf_init(void)
95186
95187 static void sctp_v4_pf_exit(void)
95188 {
95189 - list_del(&sctp_af_inet.list);
95190 + pax_list_del(&sctp_af_inet.list);
95191 }
95192
95193 static int sctp_v4_protosw_init(void)
95194 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
95195 index 9da6885..7571898 100644
95196 --- a/net/sctp/sm_sideeffect.c
95197 +++ b/net/sctp/sm_sideeffect.c
95198 @@ -446,7 +446,7 @@ static void sctp_generate_sack_event(unsigned long data)
95199 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
95200 }
95201
95202 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95203 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95204 NULL,
95205 sctp_generate_t1_cookie_event,
95206 sctp_generate_t1_init_event,
95207 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
95208 index c6670d2..6313e65 100644
95209 --- a/net/sctp/socket.c
95210 +++ b/net/sctp/socket.c
95211 @@ -2156,11 +2156,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
95212 {
95213 struct sctp_association *asoc;
95214 struct sctp_ulpevent *event;
95215 + struct sctp_event_subscribe subscribe;
95216
95217 if (optlen > sizeof(struct sctp_event_subscribe))
95218 return -EINVAL;
95219 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
95220 + if (copy_from_user(&subscribe, optval, optlen))
95221 return -EFAULT;
95222 + sctp_sk(sk)->subscribe = subscribe;
95223
95224 /*
95225 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
95226 @@ -4216,13 +4218,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
95227 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95228 int __user *optlen)
95229 {
95230 + struct sctp_event_subscribe subscribe;
95231 +
95232 if (len <= 0)
95233 return -EINVAL;
95234 if (len > sizeof(struct sctp_event_subscribe))
95235 len = sizeof(struct sctp_event_subscribe);
95236 if (put_user(len, optlen))
95237 return -EFAULT;
95238 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
95239 + subscribe = sctp_sk(sk)->subscribe;
95240 + if (copy_to_user(optval, &subscribe, len))
95241 return -EFAULT;
95242 return 0;
95243 }
95244 @@ -4240,6 +4245,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95245 */
95246 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
95247 {
95248 + __u32 autoclose;
95249 +
95250 /* Applicable to UDP-style socket only */
95251 if (sctp_style(sk, TCP))
95252 return -EOPNOTSUPP;
95253 @@ -4248,7 +4255,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
95254 len = sizeof(int);
95255 if (put_user(len, optlen))
95256 return -EFAULT;
95257 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
95258 + autoclose = sctp_sk(sk)->autoclose;
95259 + if (copy_to_user(optval, &autoclose, sizeof(int)))
95260 return -EFAULT;
95261 return 0;
95262 }
95263 @@ -4620,12 +4628,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
95264 */
95265 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
95266 {
95267 + struct sctp_initmsg initmsg;
95268 +
95269 if (len < sizeof(struct sctp_initmsg))
95270 return -EINVAL;
95271 len = sizeof(struct sctp_initmsg);
95272 if (put_user(len, optlen))
95273 return -EFAULT;
95274 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
95275 + initmsg = sctp_sk(sk)->initmsg;
95276 + if (copy_to_user(optval, &initmsg, len))
95277 return -EFAULT;
95278 return 0;
95279 }
95280 @@ -4666,6 +4677,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
95281 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
95282 if (space_left < addrlen)
95283 return -ENOMEM;
95284 + if (addrlen > sizeof(temp) || addrlen < 0)
95285 + return -EFAULT;
95286 if (copy_to_user(to, &temp, addrlen))
95287 return -EFAULT;
95288 to += addrlen;
95289 @@ -6182,7 +6195,7 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
95290 /* Is there any exceptional events? */
95291 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
95292 mask |= POLLERR |
95293 - sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
95294 + (sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);
95295 if (sk->sk_shutdown & RCV_SHUTDOWN)
95296 mask |= POLLRDHUP | POLLIN | POLLRDNORM;
95297 if (sk->sk_shutdown == SHUTDOWN_MASK)
95298 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
95299 index 9a5c4c9..46e4b29 100644
95300 --- a/net/sctp/sysctl.c
95301 +++ b/net/sctp/sysctl.c
95302 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95303 {
95304 struct net *net = current->nsproxy->net_ns;
95305 char tmp[8];
95306 - struct ctl_table tbl;
95307 + ctl_table_no_const tbl;
95308 int ret;
95309 int changed = 0;
95310 char *none = "none";
95311 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95312
95313 int sctp_sysctl_net_register(struct net *net)
95314 {
95315 - struct ctl_table *table;
95316 + ctl_table_no_const *table;
95317 int i;
95318
95319 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
95320 diff --git a/net/socket.c b/net/socket.c
95321 index b2d7c62..441a7ef 100644
95322 --- a/net/socket.c
95323 +++ b/net/socket.c
95324 @@ -88,6 +88,7 @@
95325 #include <linux/magic.h>
95326 #include <linux/slab.h>
95327 #include <linux/xattr.h>
95328 +#include <linux/in.h>
95329
95330 #include <asm/uaccess.h>
95331 #include <asm/unistd.h>
95332 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
95333 unsigned int sysctl_net_busy_poll __read_mostly;
95334 #endif
95335
95336 +#include <linux/grsock.h>
95337 +
95338 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
95339 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
95340 unsigned long nr_segs, loff_t pos);
95341 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
95342 */
95343
95344 static DEFINE_SPINLOCK(net_family_lock);
95345 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
95346 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
95347
95348 /*
95349 * Statistics counters of the socket lists
95350 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
95351 &sockfs_dentry_operations, SOCKFS_MAGIC);
95352 }
95353
95354 -static struct vfsmount *sock_mnt __read_mostly;
95355 +struct vfsmount *sock_mnt __read_mostly;
95356
95357 static struct file_system_type sock_fs_type = {
95358 .name = "sockfs",
95359 @@ -1263,6 +1266,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95360 return -EAFNOSUPPORT;
95361 if (type < 0 || type >= SOCK_MAX)
95362 return -EINVAL;
95363 + if (protocol < 0)
95364 + return -EINVAL;
95365
95366 /* Compatibility.
95367
95368 @@ -1283,6 +1288,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
95369 if (err)
95370 return err;
95371
95372 + if(!kern && !gr_search_socket(family, type, protocol)) {
95373 + if (rcu_access_pointer(net_families[family]) == NULL)
95374 + return -EAFNOSUPPORT;
95375 + else
95376 + return -EACCES;
95377 + }
95378 +
95379 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
95380 + if (rcu_access_pointer(net_families[family]) == NULL)
95381 + return -EAFNOSUPPORT;
95382 + else
95383 + return -EACCES;
95384 + }
95385 +
95386 /*
95387 * Allocate the socket and allow the family to set things up. if
95388 * the protocol is 0, the family is instructed to select an appropriate
95389 @@ -1521,6 +1540,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95390 if (sock) {
95391 err = move_addr_to_kernel(umyaddr, addrlen, &address);
95392 if (err >= 0) {
95393 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
95394 + err = -EACCES;
95395 + goto error;
95396 + }
95397 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
95398 + if (err)
95399 + goto error;
95400 +
95401 err = security_socket_bind(sock,
95402 (struct sockaddr *)&address,
95403 addrlen);
95404 @@ -1529,6 +1556,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
95405 (struct sockaddr *)
95406 &address, addrlen);
95407 }
95408 +error:
95409 fput_light(sock->file, fput_needed);
95410 }
95411 return err;
95412 @@ -1552,10 +1580,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
95413 if ((unsigned int)backlog > somaxconn)
95414 backlog = somaxconn;
95415
95416 + if (gr_handle_sock_server_other(sock->sk)) {
95417 + err = -EPERM;
95418 + goto error;
95419 + }
95420 +
95421 + err = gr_search_listen(sock);
95422 + if (err)
95423 + goto error;
95424 +
95425 err = security_socket_listen(sock, backlog);
95426 if (!err)
95427 err = sock->ops->listen(sock, backlog);
95428
95429 +error:
95430 fput_light(sock->file, fput_needed);
95431 }
95432 return err;
95433 @@ -1599,6 +1637,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95434 newsock->type = sock->type;
95435 newsock->ops = sock->ops;
95436
95437 + if (gr_handle_sock_server_other(sock->sk)) {
95438 + err = -EPERM;
95439 + sock_release(newsock);
95440 + goto out_put;
95441 + }
95442 +
95443 + err = gr_search_accept(sock);
95444 + if (err) {
95445 + sock_release(newsock);
95446 + goto out_put;
95447 + }
95448 +
95449 /*
95450 * We don't need try_module_get here, as the listening socket (sock)
95451 * has the protocol module (sock->ops->owner) held.
95452 @@ -1644,6 +1694,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
95453 fd_install(newfd, newfile);
95454 err = newfd;
95455
95456 + gr_attach_curr_ip(newsock->sk);
95457 +
95458 out_put:
95459 fput_light(sock->file, fput_needed);
95460 out:
95461 @@ -1676,6 +1728,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
95462 int, addrlen)
95463 {
95464 struct socket *sock;
95465 + struct sockaddr *sck;
95466 struct sockaddr_storage address;
95467 int err, fput_needed;
95468
95469 @@ -1686,6 +1739,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
95470 if (err < 0)
95471 goto out_put;
95472
95473 + sck = (struct sockaddr *)&address;
95474 +
95475 + if (gr_handle_sock_client(sck)) {
95476 + err = -EACCES;
95477 + goto out_put;
95478 + }
95479 +
95480 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
95481 + if (err)
95482 + goto out_put;
95483 +
95484 err =
95485 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
95486 if (err)
95487 @@ -1767,6 +1831,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
95488 * the protocol.
95489 */
95490
95491 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
95492 +
95493 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
95494 unsigned int, flags, struct sockaddr __user *, addr,
95495 int, addr_len)
95496 @@ -1833,7 +1899,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
95497 struct socket *sock;
95498 struct iovec iov;
95499 struct msghdr msg;
95500 - struct sockaddr_storage address;
95501 + struct sockaddr_storage address = { };
95502 int err, err2;
95503 int fput_needed;
95504
95505 @@ -2040,7 +2106,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
95506 * checking falls down on this.
95507 */
95508 if (copy_from_user(ctl_buf,
95509 - (void __user __force *)msg_sys->msg_control,
95510 + (void __force_user *)msg_sys->msg_control,
95511 ctl_len))
95512 goto out_freectl;
95513 msg_sys->msg_control = ctl_buf;
95514 @@ -2191,7 +2257,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
95515 int err, total_len, len;
95516
95517 /* kernel mode address */
95518 - struct sockaddr_storage addr;
95519 + struct sockaddr_storage addr = { };
95520
95521 /* user mode address pointers */
95522 struct sockaddr __user *uaddr;
95523 @@ -2219,7 +2285,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
95524 * kernel msghdr to use the kernel address space)
95525 */
95526
95527 - uaddr = (__force void __user *)msg_sys->msg_name;
95528 + uaddr = (void __force_user *)msg_sys->msg_name;
95529 uaddr_len = COMPAT_NAMELEN(msg);
95530 if (MSG_CMSG_COMPAT & flags) {
95531 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
95532 @@ -2974,7 +3040,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
95533 old_fs = get_fs();
95534 set_fs(KERNEL_DS);
95535 err = dev_ioctl(net, cmd,
95536 - (struct ifreq __user __force *) &kifr);
95537 + (struct ifreq __force_user *) &kifr);
95538 set_fs(old_fs);
95539
95540 return err;
95541 @@ -3083,7 +3149,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
95542
95543 old_fs = get_fs();
95544 set_fs(KERNEL_DS);
95545 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
95546 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
95547 set_fs(old_fs);
95548
95549 if (cmd == SIOCGIFMAP && !err) {
95550 @@ -3188,7 +3254,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
95551 ret |= __get_user(rtdev, &(ur4->rt_dev));
95552 if (rtdev) {
95553 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
95554 - r4.rt_dev = (char __user __force *)devname;
95555 + r4.rt_dev = (char __force_user *)devname;
95556 devname[15] = 0;
95557 } else
95558 r4.rt_dev = NULL;
95559 @@ -3414,8 +3480,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
95560 int __user *uoptlen;
95561 int err;
95562
95563 - uoptval = (char __user __force *) optval;
95564 - uoptlen = (int __user __force *) optlen;
95565 + uoptval = (char __force_user *) optval;
95566 + uoptlen = (int __force_user *) optlen;
95567
95568 set_fs(KERNEL_DS);
95569 if (level == SOL_SOCKET)
95570 @@ -3435,7 +3501,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
95571 char __user *uoptval;
95572 int err;
95573
95574 - uoptval = (char __user __force *) optval;
95575 + uoptval = (char __force_user *) optval;
95576
95577 set_fs(KERNEL_DS);
95578 if (level == SOL_SOCKET)
95579 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
95580 index 09fb638..2e6a5c5 100644
95581 --- a/net/sunrpc/auth_gss/svcauth_gss.c
95582 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
95583 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
95584 uint64_t *handle)
95585 {
95586 struct rsc rsci, *rscp = NULL;
95587 - static atomic64_t ctxhctr;
95588 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
95589 long long ctxh;
95590 struct gss_api_mech *gm = NULL;
95591 time_t expiry;
95592 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
95593 status = -ENOMEM;
95594 /* the handle needs to be just a unique id,
95595 * use a static counter */
95596 - ctxh = atomic64_inc_return(&ctxhctr);
95597 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
95598
95599 /* make a copy for the caller */
95600 *handle = ctxh;
95601 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
95602 index ecbc4e3..ad25df8 100644
95603 --- a/net/sunrpc/clnt.c
95604 +++ b/net/sunrpc/clnt.c
95605 @@ -1304,7 +1304,9 @@ call_start(struct rpc_task *task)
95606 (RPC_IS_ASYNC(task) ? "async" : "sync"));
95607
95608 /* Increment call count */
95609 - task->tk_msg.rpc_proc->p_count++;
95610 + pax_open_kernel();
95611 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
95612 + pax_close_kernel();
95613 clnt->cl_stats->rpccnt++;
95614 task->tk_action = call_reserve;
95615 }
95616 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
95617 index 93a7a4e..3b98b9f 100644
95618 --- a/net/sunrpc/sched.c
95619 +++ b/net/sunrpc/sched.c
95620 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
95621 #ifdef RPC_DEBUG
95622 static void rpc_task_set_debuginfo(struct rpc_task *task)
95623 {
95624 - static atomic_t rpc_pid;
95625 + static atomic_unchecked_t rpc_pid;
95626
95627 - task->tk_pid = atomic_inc_return(&rpc_pid);
95628 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
95629 }
95630 #else
95631 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
95632 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
95633 index b974571..678ed90 100644
95634 --- a/net/sunrpc/svc.c
95635 +++ b/net/sunrpc/svc.c
95636 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
95637 svc_putnl(resv, RPC_SUCCESS);
95638
95639 /* Bump per-procedure stats counter */
95640 - procp->pc_count++;
95641 + pax_open_kernel();
95642 + (*(unsigned int *)&procp->pc_count)++;
95643 + pax_close_kernel();
95644
95645 /* Initialize storage for argp and resp */
95646 memset(rqstp->rq_argp, 0, procp->pc_argsize);
95647 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
95648 index c1b6270..05089c1 100644
95649 --- a/net/sunrpc/xprtrdma/svc_rdma.c
95650 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
95651 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
95652 static unsigned int min_max_inline = 4096;
95653 static unsigned int max_max_inline = 65536;
95654
95655 -atomic_t rdma_stat_recv;
95656 -atomic_t rdma_stat_read;
95657 -atomic_t rdma_stat_write;
95658 -atomic_t rdma_stat_sq_starve;
95659 -atomic_t rdma_stat_rq_starve;
95660 -atomic_t rdma_stat_rq_poll;
95661 -atomic_t rdma_stat_rq_prod;
95662 -atomic_t rdma_stat_sq_poll;
95663 -atomic_t rdma_stat_sq_prod;
95664 +atomic_unchecked_t rdma_stat_recv;
95665 +atomic_unchecked_t rdma_stat_read;
95666 +atomic_unchecked_t rdma_stat_write;
95667 +atomic_unchecked_t rdma_stat_sq_starve;
95668 +atomic_unchecked_t rdma_stat_rq_starve;
95669 +atomic_unchecked_t rdma_stat_rq_poll;
95670 +atomic_unchecked_t rdma_stat_rq_prod;
95671 +atomic_unchecked_t rdma_stat_sq_poll;
95672 +atomic_unchecked_t rdma_stat_sq_prod;
95673
95674 /* Temporary NFS request map and context caches */
95675 struct kmem_cache *svc_rdma_map_cachep;
95676 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
95677 len -= *ppos;
95678 if (len > *lenp)
95679 len = *lenp;
95680 - if (len && copy_to_user(buffer, str_buf, len))
95681 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
95682 return -EFAULT;
95683 *lenp = len;
95684 *ppos += len;
95685 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
95686 {
95687 .procname = "rdma_stat_read",
95688 .data = &rdma_stat_read,
95689 - .maxlen = sizeof(atomic_t),
95690 + .maxlen = sizeof(atomic_unchecked_t),
95691 .mode = 0644,
95692 .proc_handler = read_reset_stat,
95693 },
95694 {
95695 .procname = "rdma_stat_recv",
95696 .data = &rdma_stat_recv,
95697 - .maxlen = sizeof(atomic_t),
95698 + .maxlen = sizeof(atomic_unchecked_t),
95699 .mode = 0644,
95700 .proc_handler = read_reset_stat,
95701 },
95702 {
95703 .procname = "rdma_stat_write",
95704 .data = &rdma_stat_write,
95705 - .maxlen = sizeof(atomic_t),
95706 + .maxlen = sizeof(atomic_unchecked_t),
95707 .mode = 0644,
95708 .proc_handler = read_reset_stat,
95709 },
95710 {
95711 .procname = "rdma_stat_sq_starve",
95712 .data = &rdma_stat_sq_starve,
95713 - .maxlen = sizeof(atomic_t),
95714 + .maxlen = sizeof(atomic_unchecked_t),
95715 .mode = 0644,
95716 .proc_handler = read_reset_stat,
95717 },
95718 {
95719 .procname = "rdma_stat_rq_starve",
95720 .data = &rdma_stat_rq_starve,
95721 - .maxlen = sizeof(atomic_t),
95722 + .maxlen = sizeof(atomic_unchecked_t),
95723 .mode = 0644,
95724 .proc_handler = read_reset_stat,
95725 },
95726 {
95727 .procname = "rdma_stat_rq_poll",
95728 .data = &rdma_stat_rq_poll,
95729 - .maxlen = sizeof(atomic_t),
95730 + .maxlen = sizeof(atomic_unchecked_t),
95731 .mode = 0644,
95732 .proc_handler = read_reset_stat,
95733 },
95734 {
95735 .procname = "rdma_stat_rq_prod",
95736 .data = &rdma_stat_rq_prod,
95737 - .maxlen = sizeof(atomic_t),
95738 + .maxlen = sizeof(atomic_unchecked_t),
95739 .mode = 0644,
95740 .proc_handler = read_reset_stat,
95741 },
95742 {
95743 .procname = "rdma_stat_sq_poll",
95744 .data = &rdma_stat_sq_poll,
95745 - .maxlen = sizeof(atomic_t),
95746 + .maxlen = sizeof(atomic_unchecked_t),
95747 .mode = 0644,
95748 .proc_handler = read_reset_stat,
95749 },
95750 {
95751 .procname = "rdma_stat_sq_prod",
95752 .data = &rdma_stat_sq_prod,
95753 - .maxlen = sizeof(atomic_t),
95754 + .maxlen = sizeof(atomic_unchecked_t),
95755 .mode = 0644,
95756 .proc_handler = read_reset_stat,
95757 },
95758 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
95759 index 0ce7552..d074459 100644
95760 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
95761 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
95762 @@ -501,7 +501,7 @@ next_sge:
95763 svc_rdma_put_context(ctxt, 0);
95764 goto out;
95765 }
95766 - atomic_inc(&rdma_stat_read);
95767 + atomic_inc_unchecked(&rdma_stat_read);
95768
95769 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
95770 chl_map->ch[ch_no].count -= read_wr.num_sge;
95771 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
95772 dto_q);
95773 list_del_init(&ctxt->dto_q);
95774 } else {
95775 - atomic_inc(&rdma_stat_rq_starve);
95776 + atomic_inc_unchecked(&rdma_stat_rq_starve);
95777 clear_bit(XPT_DATA, &xprt->xpt_flags);
95778 ctxt = NULL;
95779 }
95780 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
95781 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
95782 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
95783 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
95784 - atomic_inc(&rdma_stat_recv);
95785 + atomic_inc_unchecked(&rdma_stat_recv);
95786
95787 /* Build up the XDR from the receive buffers. */
95788 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
95789 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
95790 index c1d124d..acfc59e 100644
95791 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
95792 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
95793 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
95794 write_wr.wr.rdma.remote_addr = to;
95795
95796 /* Post It */
95797 - atomic_inc(&rdma_stat_write);
95798 + atomic_inc_unchecked(&rdma_stat_write);
95799 if (svc_rdma_send(xprt, &write_wr))
95800 goto err;
95801 return 0;
95802 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
95803 index 62e4f9b..dd3f2d7 100644
95804 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
95805 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
95806 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
95807 return;
95808
95809 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
95810 - atomic_inc(&rdma_stat_rq_poll);
95811 + atomic_inc_unchecked(&rdma_stat_rq_poll);
95812
95813 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
95814 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
95815 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
95816 }
95817
95818 if (ctxt)
95819 - atomic_inc(&rdma_stat_rq_prod);
95820 + atomic_inc_unchecked(&rdma_stat_rq_prod);
95821
95822 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
95823 /*
95824 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
95825 return;
95826
95827 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
95828 - atomic_inc(&rdma_stat_sq_poll);
95829 + atomic_inc_unchecked(&rdma_stat_sq_poll);
95830 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
95831 if (wc.status != IB_WC_SUCCESS)
95832 /* Close the transport */
95833 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
95834 }
95835
95836 if (ctxt)
95837 - atomic_inc(&rdma_stat_sq_prod);
95838 + atomic_inc_unchecked(&rdma_stat_sq_prod);
95839 }
95840
95841 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
95842 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
95843 spin_lock_bh(&xprt->sc_lock);
95844 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
95845 spin_unlock_bh(&xprt->sc_lock);
95846 - atomic_inc(&rdma_stat_sq_starve);
95847 + atomic_inc_unchecked(&rdma_stat_sq_starve);
95848
95849 /* See if we can opportunistically reap SQ WR to make room */
95850 sq_cq_reap(xprt);
95851 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
95852 index 9bc6db0..47ac8c0 100644
95853 --- a/net/sysctl_net.c
95854 +++ b/net/sysctl_net.c
95855 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
95856 kgid_t root_gid = make_kgid(net->user_ns, 0);
95857
95858 /* Allow network administrator to have same access as root. */
95859 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
95860 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
95861 uid_eq(root_uid, current_uid())) {
95862 int mode = (table->mode >> 6) & 7;
95863 return (mode << 6) | (mode << 3) | mode;
95864 diff --git a/net/tipc/link.c b/net/tipc/link.c
95865 index 0cc3d90..cc42021 100644
95866 --- a/net/tipc/link.c
95867 +++ b/net/tipc/link.c
95868 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
95869 struct tipc_msg fragm_hdr;
95870 struct sk_buff *buf, *buf_chain, *prev;
95871 u32 fragm_crs, fragm_rest, hsz, sect_rest;
95872 - const unchar *sect_crs;
95873 + const unchar __user *sect_crs;
95874 int curr_sect;
95875 u32 fragm_no;
95876 int res = 0;
95877 @@ -1207,7 +1207,7 @@ again:
95878
95879 if (!sect_rest) {
95880 sect_rest = msg_sect[++curr_sect].iov_len;
95881 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
95882 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
95883 }
95884
95885 if (sect_rest < fragm_rest)
95886 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
95887 index ced60e2..54eab6c 100644
95888 --- a/net/tipc/msg.c
95889 +++ b/net/tipc/msg.c
95890 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
95891 skb_copy_to_linear_data(*buf, hdr, hsz);
95892 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
95893 skb_copy_to_linear_data_offset(*buf, pos,
95894 - msg_sect[cnt].iov_base,
95895 + (const void __force_kernel *)msg_sect[cnt].iov_base,
95896 msg_sect[cnt].iov_len);
95897 pos += msg_sect[cnt].iov_len;
95898 }
95899 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
95900 index d38bb45..4fd6ac6 100644
95901 --- a/net/tipc/subscr.c
95902 +++ b/net/tipc/subscr.c
95903 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
95904 struct kvec msg_sect;
95905 int ret;
95906
95907 - msg_sect.iov_base = (void *)&sub->evt;
95908 + msg_sect.iov_base = (void __force_user *)&sub->evt;
95909 msg_sect.iov_len = sizeof(struct tipc_event);
95910
95911 sub->evt.event = htohl(event, sub->swap);
95912 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
95913 index c4ce243..2be7c59 100644
95914 --- a/net/unix/af_unix.c
95915 +++ b/net/unix/af_unix.c
95916 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
95917 err = -ECONNREFUSED;
95918 if (!S_ISSOCK(inode->i_mode))
95919 goto put_fail;
95920 +
95921 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
95922 + err = -EACCES;
95923 + goto put_fail;
95924 + }
95925 +
95926 u = unix_find_socket_byinode(inode);
95927 if (!u)
95928 goto put_fail;
95929 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
95930 if (u) {
95931 struct dentry *dentry;
95932 dentry = unix_sk(u)->path.dentry;
95933 +
95934 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
95935 + err = -EPERM;
95936 + sock_put(u);
95937 + goto fail;
95938 + }
95939 +
95940 if (dentry)
95941 touch_atime(&unix_sk(u)->path);
95942 } else
95943 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
95944 */
95945 err = security_path_mknod(&path, dentry, mode, 0);
95946 if (!err) {
95947 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
95948 + err = -EACCES;
95949 + goto out;
95950 + }
95951 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
95952 if (!err) {
95953 res->mnt = mntget(path.mnt);
95954 res->dentry = dget(dentry);
95955 + gr_handle_create(dentry, path.mnt);
95956 }
95957 }
95958 +out:
95959 done_path_create(&path, dentry);
95960 return err;
95961 }
95962 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
95963 seq_puts(seq, "Num RefCount Protocol Flags Type St "
95964 "Inode Path\n");
95965 else {
95966 - struct sock *s = v;
95967 + struct sock *s = v, *peer;
95968 struct unix_sock *u = unix_sk(s);
95969 unix_state_lock(s);
95970 + peer = unix_peer(s);
95971 + unix_state_unlock(s);
95972 +
95973 + unix_state_double_lock(s, peer);
95974
95975 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
95976 s,
95977 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
95978 }
95979 for ( ; i < len; i++)
95980 seq_putc(seq, u->addr->name->sun_path[i]);
95981 - }
95982 - unix_state_unlock(s);
95983 + } else if (peer)
95984 + seq_printf(seq, " P%lu", sock_i_ino(peer));
95985 +
95986 + unix_state_double_unlock(s, peer);
95987 seq_putc(seq, '\n');
95988 }
95989
95990 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
95991 index b3d5150..ff3a837 100644
95992 --- a/net/unix/sysctl_net_unix.c
95993 +++ b/net/unix/sysctl_net_unix.c
95994 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
95995
95996 int __net_init unix_sysctl_register(struct net *net)
95997 {
95998 - struct ctl_table *table;
95999 + ctl_table_no_const *table;
96000
96001 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
96002 if (table == NULL)
96003 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
96004 index c8717c1..08539f5 100644
96005 --- a/net/wireless/wext-core.c
96006 +++ b/net/wireless/wext-core.c
96007 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96008 */
96009
96010 /* Support for very large requests */
96011 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
96012 - (user_length > descr->max_tokens)) {
96013 + if (user_length > descr->max_tokens) {
96014 /* Allow userspace to GET more than max so
96015 * we can support any size GET requests.
96016 * There is still a limit : -ENOMEM.
96017 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96018 }
96019 }
96020
96021 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
96022 - /*
96023 - * If this is a GET, but not NOMAX, it means that the extra
96024 - * data is not bounded by userspace, but by max_tokens. Thus
96025 - * set the length to max_tokens. This matches the extra data
96026 - * allocation.
96027 - * The driver should fill it with the number of tokens it
96028 - * provided, and it may check iwp->length rather than having
96029 - * knowledge of max_tokens. If the driver doesn't change the
96030 - * iwp->length, this ioctl just copies back max_token tokens
96031 - * filled with zeroes. Hopefully the driver isn't claiming
96032 - * them to be valid data.
96033 - */
96034 - iwp->length = descr->max_tokens;
96035 - }
96036 -
96037 err = handler(dev, info, (union iwreq_data *) iwp, extra);
96038
96039 iwp->length += essid_compat;
96040 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
96041 index f77c371..e412fa6 100644
96042 --- a/net/xfrm/xfrm_policy.c
96043 +++ b/net/xfrm/xfrm_policy.c
96044 @@ -332,7 +332,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
96045 {
96046 policy->walk.dead = 1;
96047
96048 - atomic_inc(&policy->genid);
96049 + atomic_inc_unchecked(&policy->genid);
96050
96051 del_timer(&policy->polq.hold_timer);
96052 xfrm_queue_purge(&policy->polq.hold_queue);
96053 @@ -657,7 +657,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
96054 hlist_add_head(&policy->bydst, chain);
96055 xfrm_pol_hold(policy);
96056 net->xfrm.policy_count[dir]++;
96057 - atomic_inc(&flow_cache_genid);
96058 + atomic_inc_unchecked(&flow_cache_genid);
96059 rt_genid_bump(net);
96060 if (delpol) {
96061 xfrm_policy_requeue(delpol, policy);
96062 @@ -1627,7 +1627,7 @@ free_dst:
96063 goto out;
96064 }
96065
96066 -static int inline
96067 +static inline int
96068 xfrm_dst_alloc_copy(void **target, const void *src, int size)
96069 {
96070 if (!*target) {
96071 @@ -1639,7 +1639,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
96072 return 0;
96073 }
96074
96075 -static int inline
96076 +static inline int
96077 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96078 {
96079 #ifdef CONFIG_XFRM_SUB_POLICY
96080 @@ -1651,7 +1651,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96081 #endif
96082 }
96083
96084 -static int inline
96085 +static inline int
96086 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
96087 {
96088 #ifdef CONFIG_XFRM_SUB_POLICY
96089 @@ -1745,7 +1745,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
96090
96091 xdst->num_pols = num_pols;
96092 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
96093 - xdst->policy_genid = atomic_read(&pols[0]->genid);
96094 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
96095
96096 return xdst;
96097 }
96098 @@ -2557,11 +2557,12 @@ void xfrm_garbage_collect(struct net *net)
96099 }
96100 EXPORT_SYMBOL(xfrm_garbage_collect);
96101
96102 -static void xfrm_garbage_collect_deferred(struct net *net)
96103 +void xfrm_garbage_collect_deferred(struct net *net)
96104 {
96105 flow_cache_flush_deferred();
96106 __xfrm_garbage_collect(net);
96107 }
96108 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
96109
96110 static void xfrm_init_pmtu(struct dst_entry *dst)
96111 {
96112 @@ -2611,7 +2612,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
96113 if (xdst->xfrm_genid != dst->xfrm->genid)
96114 return 0;
96115 if (xdst->num_pols > 0 &&
96116 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
96117 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
96118 return 0;
96119
96120 mtu = dst_mtu(dst->child);
96121 @@ -2699,8 +2700,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
96122 dst_ops->link_failure = xfrm_link_failure;
96123 if (likely(dst_ops->neigh_lookup == NULL))
96124 dst_ops->neigh_lookup = xfrm_neigh_lookup;
96125 - if (likely(afinfo->garbage_collect == NULL))
96126 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
96127 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
96128 }
96129 spin_unlock(&xfrm_policy_afinfo_lock);
96130 @@ -2754,7 +2753,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
96131 dst_ops->check = NULL;
96132 dst_ops->negative_advice = NULL;
96133 dst_ops->link_failure = NULL;
96134 - afinfo->garbage_collect = NULL;
96135 }
96136 return err;
96137 }
96138 @@ -3137,7 +3135,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
96139 sizeof(pol->xfrm_vec[i].saddr));
96140 pol->xfrm_vec[i].encap_family = mp->new_family;
96141 /* flush bundles */
96142 - atomic_inc(&pol->genid);
96143 + atomic_inc_unchecked(&pol->genid);
96144 }
96145 }
96146
96147 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
96148 index 54c0acd..56814bd 100644
96149 --- a/net/xfrm/xfrm_state.c
96150 +++ b/net/xfrm/xfrm_state.c
96151 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
96152
96153 if (unlikely(afinfo == NULL))
96154 return -EAFNOSUPPORT;
96155 - typemap = afinfo->type_map;
96156 + typemap = (const struct xfrm_type **)afinfo->type_map;
96157 spin_lock_bh(&xfrm_type_lock);
96158
96159 - if (likely(typemap[type->proto] == NULL))
96160 + if (likely(typemap[type->proto] == NULL)) {
96161 + pax_open_kernel();
96162 typemap[type->proto] = type;
96163 - else
96164 + pax_close_kernel();
96165 + } else
96166 err = -EEXIST;
96167 spin_unlock_bh(&xfrm_type_lock);
96168 xfrm_state_put_afinfo(afinfo);
96169 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
96170
96171 if (unlikely(afinfo == NULL))
96172 return -EAFNOSUPPORT;
96173 - typemap = afinfo->type_map;
96174 + typemap = (const struct xfrm_type **)afinfo->type_map;
96175 spin_lock_bh(&xfrm_type_lock);
96176
96177 if (unlikely(typemap[type->proto] != type))
96178 err = -ENOENT;
96179 - else
96180 + else {
96181 + pax_open_kernel();
96182 typemap[type->proto] = NULL;
96183 + pax_close_kernel();
96184 + }
96185 spin_unlock_bh(&xfrm_type_lock);
96186 xfrm_state_put_afinfo(afinfo);
96187 return err;
96188 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
96189 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
96190 {
96191 struct xfrm_state_afinfo *afinfo;
96192 - const struct xfrm_type **typemap;
96193 const struct xfrm_type *type;
96194 int modload_attempted = 0;
96195
96196 @@ -219,9 +223,8 @@ retry:
96197 afinfo = xfrm_state_get_afinfo(family);
96198 if (unlikely(afinfo == NULL))
96199 return NULL;
96200 - typemap = afinfo->type_map;
96201
96202 - type = typemap[proto];
96203 + type = afinfo->type_map[proto];
96204 if (unlikely(type && !try_module_get(type->owner)))
96205 type = NULL;
96206 if (!type && !modload_attempted) {
96207 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
96208 return -EAFNOSUPPORT;
96209
96210 err = -EEXIST;
96211 - modemap = afinfo->mode_map;
96212 + modemap = (struct xfrm_mode **)afinfo->mode_map;
96213 spin_lock_bh(&xfrm_mode_lock);
96214 if (modemap[mode->encap])
96215 goto out;
96216 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
96217 if (!try_module_get(afinfo->owner))
96218 goto out;
96219
96220 - mode->afinfo = afinfo;
96221 + pax_open_kernel();
96222 + *(const void **)&mode->afinfo = afinfo;
96223 modemap[mode->encap] = mode;
96224 + pax_close_kernel();
96225 err = 0;
96226
96227 out:
96228 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
96229 return -EAFNOSUPPORT;
96230
96231 err = -ENOENT;
96232 - modemap = afinfo->mode_map;
96233 + modemap = (struct xfrm_mode **)afinfo->mode_map;
96234 spin_lock_bh(&xfrm_mode_lock);
96235 if (likely(modemap[mode->encap] == mode)) {
96236 + pax_open_kernel();
96237 modemap[mode->encap] = NULL;
96238 + pax_close_kernel();
96239 module_put(mode->afinfo->owner);
96240 err = 0;
96241 }
96242 @@ -1483,10 +1490,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
96243 u32 xfrm_get_acqseq(void)
96244 {
96245 u32 res;
96246 - static atomic_t acqseq;
96247 + static atomic_unchecked_t acqseq;
96248
96249 do {
96250 - res = atomic_inc_return(&acqseq);
96251 + res = atomic_inc_return_unchecked(&acqseq);
96252 } while (!res);
96253
96254 return res;
96255 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
96256 index 05a6e3d..6716ec9 100644
96257 --- a/net/xfrm/xfrm_sysctl.c
96258 +++ b/net/xfrm/xfrm_sysctl.c
96259 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
96260
96261 int __net_init xfrm_sysctl_init(struct net *net)
96262 {
96263 - struct ctl_table *table;
96264 + ctl_table_no_const *table;
96265
96266 __xfrm_sysctl_init(net);
96267
96268 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
96269 index 3f565e4..4b26cee 100644
96270 --- a/net/xfrm/xfrm_user.c
96271 +++ b/net/xfrm/xfrm_user.c
96272 @@ -1856,7 +1856,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
96273 if (x->km.state != XFRM_STATE_VALID)
96274 goto out;
96275
96276 - err = xfrm_replay_verify_len(x->replay_esn, rp);
96277 + err = xfrm_replay_verify_len(x->replay_esn, re);
96278 if (err)
96279 goto out;
96280
96281 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
96282 index d5d859c..781cbcb 100644
96283 --- a/scripts/Makefile.build
96284 +++ b/scripts/Makefile.build
96285 @@ -111,7 +111,7 @@ endif
96286 endif
96287
96288 # Do not include host rules unless needed
96289 -ifneq ($(hostprogs-y)$(hostprogs-m),)
96290 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
96291 include scripts/Makefile.host
96292 endif
96293
96294 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
96295 index 686cb0d..9d653bf 100644
96296 --- a/scripts/Makefile.clean
96297 +++ b/scripts/Makefile.clean
96298 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
96299 __clean-files := $(extra-y) $(always) \
96300 $(targets) $(clean-files) \
96301 $(host-progs) \
96302 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
96303 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
96304 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
96305
96306 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
96307
96308 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
96309 index 1ac414f..38575f7 100644
96310 --- a/scripts/Makefile.host
96311 +++ b/scripts/Makefile.host
96312 @@ -31,6 +31,8 @@
96313 # Note: Shared libraries consisting of C++ files are not supported
96314
96315 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
96316 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
96317 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
96318
96319 # C code
96320 # Executables compiled from a single .c file
96321 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
96322 # Shared libaries (only .c supported)
96323 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
96324 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
96325 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
96326 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
96327 # Remove .so files from "xxx-objs"
96328 host-cobjs := $(filter-out %.so,$(host-cobjs))
96329 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
96330
96331 -#Object (.o) files used by the shared libaries
96332 +# Object (.o) files used by the shared libaries
96333 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
96334 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
96335
96336 # output directory for programs/.o files
96337 # hostprogs-y := tools/build may have been specified. Retrieve directory
96338 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
96339 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
96340 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
96341 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
96342 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
96343 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
96344 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
96345 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
96346
96347 obj-dirs += $(host-objdirs)
96348 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
96349 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
96350 $(call if_changed_dep,host-cshobjs)
96351
96352 +# Compile .c file, create position independent .o file
96353 +# host-cxxshobjs -> .o
96354 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
96355 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
96356 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
96357 + $(call if_changed_dep,host-cxxshobjs)
96358 +
96359 # Link a shared library, based on position independent .o files
96360 # *.o -> .so shared library (host-cshlib)
96361 quiet_cmd_host-cshlib = HOSTLLD -shared $@
96362 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
96363 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
96364 $(call if_changed,host-cshlib)
96365
96366 +# Link a shared library, based on position independent .o files
96367 +# *.o -> .so shared library (host-cxxshlib)
96368 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
96369 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
96370 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
96371 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
96372 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
96373 + $(call if_changed,host-cxxshlib)
96374 +
96375 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
96376 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
96377 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
96378
96379 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
96380 index 078fe1d..fbdb363 100644
96381 --- a/scripts/basic/fixdep.c
96382 +++ b/scripts/basic/fixdep.c
96383 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
96384 /*
96385 * Lookup a value in the configuration string.
96386 */
96387 -static int is_defined_config(const char *name, int len, unsigned int hash)
96388 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
96389 {
96390 struct item *aux;
96391
96392 @@ -211,10 +211,10 @@ static void clear_config(void)
96393 /*
96394 * Record the use of a CONFIG_* word.
96395 */
96396 -static void use_config(const char *m, int slen)
96397 +static void use_config(const char *m, unsigned int slen)
96398 {
96399 unsigned int hash = strhash(m, slen);
96400 - int c, i;
96401 + unsigned int c, i;
96402
96403 if (is_defined_config(m, slen, hash))
96404 return;
96405 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
96406
96407 static void parse_config_file(const char *map, size_t len)
96408 {
96409 - const int *end = (const int *) (map + len);
96410 + const unsigned int *end = (const unsigned int *) (map + len);
96411 /* start at +1, so that p can never be < map */
96412 - const int *m = (const int *) map + 1;
96413 + const unsigned int *m = (const unsigned int *) map + 1;
96414 const char *p, *q;
96415
96416 for (; m < end; m++) {
96417 @@ -435,7 +435,7 @@ static void print_deps(void)
96418 static void traps(void)
96419 {
96420 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
96421 - int *p = (int *)test;
96422 + unsigned int *p = (unsigned int *)test;
96423
96424 if (*p != INT_CONF) {
96425 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
96426 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
96427 new file mode 100644
96428 index 0000000..5e0222d
96429 --- /dev/null
96430 +++ b/scripts/gcc-plugin.sh
96431 @@ -0,0 +1,17 @@
96432 +#!/bin/bash
96433 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
96434 +#include "gcc-plugin.h"
96435 +#include "tree.h"
96436 +#include "tm.h"
96437 +#include "rtl.h"
96438 +#ifdef ENABLE_BUILD_WITH_CXX
96439 +#warning $2
96440 +#else
96441 +#warning $1
96442 +#endif
96443 +EOF`
96444 +if [ $? -eq 0 ]
96445 +then
96446 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
96447 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
96448 +fi
96449 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
96450 index 5de5660..d3deb89 100644
96451 --- a/scripts/headers_install.sh
96452 +++ b/scripts/headers_install.sh
96453 @@ -32,6 +32,7 @@ do
96454 FILE="$(basename "$i")"
96455 sed -r \
96456 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
96457 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
96458 -e 's/__attribute_const__([ \t]|$)/\1/g' \
96459 -e 's@^#include <linux/compiler.h>@@' \
96460 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
96461 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
96462 index 0149949..d482a0d 100644
96463 --- a/scripts/link-vmlinux.sh
96464 +++ b/scripts/link-vmlinux.sh
96465 @@ -158,7 +158,7 @@ else
96466 fi;
96467
96468 # final build of init/
96469 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
96470 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
96471
96472 kallsymso=""
96473 kallsyms_vmlinux=""
96474 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
96475 index 2370863..212fbca 100644
96476 --- a/scripts/mod/file2alias.c
96477 +++ b/scripts/mod/file2alias.c
96478 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
96479 unsigned long size, unsigned long id_size,
96480 void *symval)
96481 {
96482 - int i;
96483 + unsigned int i;
96484
96485 if (size % id_size || size < id_size) {
96486 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
96487 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
96488 /* USB is special because the bcdDevice can be matched against a numeric range */
96489 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
96490 static void do_usb_entry(void *symval,
96491 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
96492 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
96493 unsigned char range_lo, unsigned char range_hi,
96494 unsigned char max, struct module *mod)
96495 {
96496 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
96497 {
96498 unsigned int devlo, devhi;
96499 unsigned char chi, clo, max;
96500 - int ndigits;
96501 + unsigned int ndigits;
96502
96503 DEF_FIELD(symval, usb_device_id, match_flags);
96504 DEF_FIELD(symval, usb_device_id, idVendor);
96505 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
96506 for (i = 0; i < count; i++) {
96507 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
96508 char acpi_id[sizeof(*id)];
96509 - int j;
96510 + unsigned int j;
96511
96512 buf_printf(&mod->dev_table_buf,
96513 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
96514 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
96515
96516 for (j = 0; j < PNP_MAX_DEVICES; j++) {
96517 const char *id = (char *)(*devs)[j].id;
96518 - int i2, j2;
96519 + unsigned int i2, j2;
96520 int dup = 0;
96521
96522 if (!id[0])
96523 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
96524 /* add an individual alias for every device entry */
96525 if (!dup) {
96526 char acpi_id[PNP_ID_LEN];
96527 - int k;
96528 + unsigned int k;
96529
96530 buf_printf(&mod->dev_table_buf,
96531 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
96532 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
96533 static int do_dmi_entry(const char *filename, void *symval,
96534 char *alias)
96535 {
96536 - int i, j;
96537 + unsigned int i, j;
96538 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
96539 sprintf(alias, "dmi*");
96540
96541 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
96542 index 6216434..050cf89 100644
96543 --- a/scripts/mod/modpost.c
96544 +++ b/scripts/mod/modpost.c
96545 @@ -930,6 +930,7 @@ enum mismatch {
96546 ANY_INIT_TO_ANY_EXIT,
96547 ANY_EXIT_TO_ANY_INIT,
96548 EXPORT_TO_INIT_EXIT,
96549 + DATA_TO_TEXT
96550 };
96551
96552 struct sectioncheck {
96553 @@ -1016,6 +1017,12 @@ const struct sectioncheck sectioncheck[] = {
96554 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
96555 .mismatch = EXPORT_TO_INIT_EXIT,
96556 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
96557 +},
96558 +/* Do not reference code from writable data */
96559 +{
96560 + .fromsec = { DATA_SECTIONS, NULL },
96561 + .tosec = { TEXT_SECTIONS, NULL },
96562 + .mismatch = DATA_TO_TEXT
96563 }
96564 };
96565
96566 @@ -1136,10 +1143,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
96567 continue;
96568 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
96569 continue;
96570 - if (sym->st_value == addr)
96571 - return sym;
96572 /* Find a symbol nearby - addr are maybe negative */
96573 d = sym->st_value - addr;
96574 + if (d == 0)
96575 + return sym;
96576 if (d < 0)
96577 d = addr - sym->st_value;
96578 if (d < distance) {
96579 @@ -1417,6 +1424,14 @@ static void report_sec_mismatch(const char *modname,
96580 tosym, prl_to, prl_to, tosym);
96581 free(prl_to);
96582 break;
96583 + case DATA_TO_TEXT:
96584 +#if 0
96585 + fprintf(stderr,
96586 + "The %s %s:%s references\n"
96587 + "the %s %s:%s%s\n",
96588 + from, fromsec, fromsym, to, tosec, tosym, to_p);
96589 +#endif
96590 + break;
96591 }
96592 fprintf(stderr, "\n");
96593 }
96594 @@ -1651,7 +1666,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
96595 static void check_sec_ref(struct module *mod, const char *modname,
96596 struct elf_info *elf)
96597 {
96598 - int i;
96599 + unsigned int i;
96600 Elf_Shdr *sechdrs = elf->sechdrs;
96601
96602 /* Walk through all sections */
96603 @@ -1770,7 +1785,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
96604 va_end(ap);
96605 }
96606
96607 -void buf_write(struct buffer *buf, const char *s, int len)
96608 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
96609 {
96610 if (buf->size - buf->pos < len) {
96611 buf->size += len + SZ;
96612 @@ -1989,7 +2004,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
96613 if (fstat(fileno(file), &st) < 0)
96614 goto close_write;
96615
96616 - if (st.st_size != b->pos)
96617 + if (st.st_size != (off_t)b->pos)
96618 goto close_write;
96619
96620 tmp = NOFAIL(malloc(b->pos));
96621 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
96622 index 51207e4..f7d603d 100644
96623 --- a/scripts/mod/modpost.h
96624 +++ b/scripts/mod/modpost.h
96625 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
96626
96627 struct buffer {
96628 char *p;
96629 - int pos;
96630 - int size;
96631 + unsigned int pos;
96632 + unsigned int size;
96633 };
96634
96635 void __attribute__((format(printf, 2, 3)))
96636 buf_printf(struct buffer *buf, const char *fmt, ...);
96637
96638 void
96639 -buf_write(struct buffer *buf, const char *s, int len);
96640 +buf_write(struct buffer *buf, const char *s, unsigned int len);
96641
96642 struct module {
96643 struct module *next;
96644 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
96645 index 9dfcd6d..099068e 100644
96646 --- a/scripts/mod/sumversion.c
96647 +++ b/scripts/mod/sumversion.c
96648 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
96649 goto out;
96650 }
96651
96652 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
96653 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
96654 warn("writing sum in %s failed: %s\n",
96655 filename, strerror(errno));
96656 goto out;
96657 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
96658 index 0865b3e..7235dd4 100644
96659 --- a/scripts/module-common.lds
96660 +++ b/scripts/module-common.lds
96661 @@ -6,6 +6,10 @@
96662 SECTIONS {
96663 /DISCARD/ : { *(.discard) }
96664
96665 + .rodata : {
96666 + *(.rodata) *(.rodata.*)
96667 + *(.data..read_only)
96668 + }
96669 __ksymtab : { *(SORT(___ksymtab+*)) }
96670 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
96671 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
96672 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
96673 index acb8650..b8c5f02 100644
96674 --- a/scripts/package/builddeb
96675 +++ b/scripts/package/builddeb
96676 @@ -246,6 +246,7 @@ fi
96677 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
96678 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
96679 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
96680 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
96681 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
96682 mkdir -p "$destdir"
96683 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
96684 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
96685 index 68bb4ef..2f419e1 100644
96686 --- a/scripts/pnmtologo.c
96687 +++ b/scripts/pnmtologo.c
96688 @@ -244,14 +244,14 @@ static void write_header(void)
96689 fprintf(out, " * Linux logo %s\n", logoname);
96690 fputs(" */\n\n", out);
96691 fputs("#include <linux/linux_logo.h>\n\n", out);
96692 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
96693 + fprintf(out, "static unsigned char %s_data[] = {\n",
96694 logoname);
96695 }
96696
96697 static void write_footer(void)
96698 {
96699 fputs("\n};\n\n", out);
96700 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
96701 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
96702 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
96703 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
96704 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
96705 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
96706 fputs("\n};\n\n", out);
96707
96708 /* write logo clut */
96709 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
96710 + fprintf(out, "static unsigned char %s_clut[] = {\n",
96711 logoname);
96712 write_hex_cnt = 0;
96713 for (i = 0; i < logo_clutsize; i++) {
96714 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
96715 index f5eb43d..1814de8 100644
96716 --- a/scripts/sortextable.h
96717 +++ b/scripts/sortextable.h
96718 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
96719 const char *secstrtab;
96720 const char *strtab;
96721 char *extab_image;
96722 - int extab_index = 0;
96723 - int i;
96724 - int idx;
96725 + unsigned int extab_index = 0;
96726 + unsigned int i;
96727 + unsigned int idx;
96728
96729 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
96730 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
96731 diff --git a/security/Kconfig b/security/Kconfig
96732 index e9c6ac7..c5d45c8 100644
96733 --- a/security/Kconfig
96734 +++ b/security/Kconfig
96735 @@ -4,6 +4,959 @@
96736
96737 menu "Security options"
96738
96739 +menu "Grsecurity"
96740 +
96741 + config ARCH_TRACK_EXEC_LIMIT
96742 + bool
96743 +
96744 + config PAX_KERNEXEC_PLUGIN
96745 + bool
96746 +
96747 + config PAX_PER_CPU_PGD
96748 + bool
96749 +
96750 + config TASK_SIZE_MAX_SHIFT
96751 + int
96752 + depends on X86_64
96753 + default 47 if !PAX_PER_CPU_PGD
96754 + default 42 if PAX_PER_CPU_PGD
96755 +
96756 + config PAX_ENABLE_PAE
96757 + bool
96758 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
96759 +
96760 + config PAX_USERCOPY_SLABS
96761 + bool
96762 +
96763 +config GRKERNSEC
96764 + bool "Grsecurity"
96765 + select CRYPTO
96766 + select CRYPTO_SHA256
96767 + select PROC_FS
96768 + select STOP_MACHINE
96769 + select TTY
96770 + help
96771 + If you say Y here, you will be able to configure many features
96772 + that will enhance the security of your system. It is highly
96773 + recommended that you say Y here and read through the help
96774 + for each option so that you fully understand the features and
96775 + can evaluate their usefulness for your machine.
96776 +
96777 +choice
96778 + prompt "Configuration Method"
96779 + depends on GRKERNSEC
96780 + default GRKERNSEC_CONFIG_CUSTOM
96781 + help
96782 +
96783 +config GRKERNSEC_CONFIG_AUTO
96784 + bool "Automatic"
96785 + help
96786 + If you choose this configuration method, you'll be able to answer a small
96787 + number of simple questions about how you plan to use this kernel.
96788 + The settings of grsecurity and PaX will be automatically configured for
96789 + the highest commonly-used settings within the provided constraints.
96790 +
96791 + If you require additional configuration, custom changes can still be made
96792 + from the "custom configuration" menu.
96793 +
96794 +config GRKERNSEC_CONFIG_CUSTOM
96795 + bool "Custom"
96796 + help
96797 + If you choose this configuration method, you'll be able to configure all
96798 + grsecurity and PaX settings manually. Via this method, no options are
96799 + automatically enabled.
96800 +
96801 +endchoice
96802 +
96803 +choice
96804 + prompt "Usage Type"
96805 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
96806 + default GRKERNSEC_CONFIG_SERVER
96807 + help
96808 +
96809 +config GRKERNSEC_CONFIG_SERVER
96810 + bool "Server"
96811 + help
96812 + Choose this option if you plan to use this kernel on a server.
96813 +
96814 +config GRKERNSEC_CONFIG_DESKTOP
96815 + bool "Desktop"
96816 + help
96817 + Choose this option if you plan to use this kernel on a desktop.
96818 +
96819 +endchoice
96820 +
96821 +choice
96822 + prompt "Virtualization Type"
96823 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
96824 + default GRKERNSEC_CONFIG_VIRT_NONE
96825 + help
96826 +
96827 +config GRKERNSEC_CONFIG_VIRT_NONE
96828 + bool "None"
96829 + help
96830 + Choose this option if this kernel will be run on bare metal.
96831 +
96832 +config GRKERNSEC_CONFIG_VIRT_GUEST
96833 + bool "Guest"
96834 + help
96835 + Choose this option if this kernel will be run as a VM guest.
96836 +
96837 +config GRKERNSEC_CONFIG_VIRT_HOST
96838 + bool "Host"
96839 + help
96840 + Choose this option if this kernel will be run as a VM host.
96841 +
96842 +endchoice
96843 +
96844 +choice
96845 + prompt "Virtualization Hardware"
96846 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
96847 + help
96848 +
96849 +config GRKERNSEC_CONFIG_VIRT_EPT
96850 + bool "EPT/RVI Processor Support"
96851 + depends on X86
96852 + help
96853 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
96854 + hardware virtualization. This allows for additional kernel hardening protections
96855 + to operate without additional performance impact.
96856 +
96857 + To see if your Intel processor supports EPT, see:
96858 + http://ark.intel.com/Products/VirtualizationTechnology
96859 + (Most Core i3/5/7 support EPT)
96860 +
96861 + To see if your AMD processor supports RVI, see:
96862 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
96863 +
96864 +config GRKERNSEC_CONFIG_VIRT_SOFT
96865 + bool "First-gen/No Hardware Virtualization"
96866 + help
96867 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
96868 + support hardware virtualization or doesn't support the EPT/RVI extensions.
96869 +
96870 +endchoice
96871 +
96872 +choice
96873 + prompt "Virtualization Software"
96874 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
96875 + help
96876 +
96877 +config GRKERNSEC_CONFIG_VIRT_XEN
96878 + bool "Xen"
96879 + help
96880 + Choose this option if this kernel is running as a Xen guest or host.
96881 +
96882 +config GRKERNSEC_CONFIG_VIRT_VMWARE
96883 + bool "VMWare"
96884 + help
96885 + Choose this option if this kernel is running as a VMWare guest or host.
96886 +
96887 +config GRKERNSEC_CONFIG_VIRT_KVM
96888 + bool "KVM"
96889 + help
96890 + Choose this option if this kernel is running as a KVM guest or host.
96891 +
96892 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
96893 + bool "VirtualBox"
96894 + help
96895 + Choose this option if this kernel is running as a VirtualBox guest or host.
96896 +
96897 +endchoice
96898 +
96899 +choice
96900 + prompt "Required Priorities"
96901 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
96902 + default GRKERNSEC_CONFIG_PRIORITY_PERF
96903 + help
96904 +
96905 +config GRKERNSEC_CONFIG_PRIORITY_PERF
96906 + bool "Performance"
96907 + help
96908 + Choose this option if performance is of highest priority for this deployment
96909 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
96910 + clearing of structures intended for userland, and freed memory sanitizing will
96911 + be disabled.
96912 +
96913 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
96914 + bool "Security"
96915 + help
96916 + Choose this option if security is of highest priority for this deployment of
96917 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
96918 + for userland, and freed memory sanitizing will be enabled for this kernel.
96919 + In a worst-case scenario, these features can introduce a 20% performance hit
96920 + (UDEREF on x64 contributing half of this hit).
96921 +
96922 +endchoice
96923 +
96924 +menu "Default Special Groups"
96925 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
96926 +
96927 +config GRKERNSEC_PROC_GID
96928 + int "GID exempted from /proc restrictions"
96929 + default 1001
96930 + help
96931 + Setting this GID determines which group will be exempted from
96932 + grsecurity's /proc restrictions, allowing users of the specified
96933 + group to view network statistics and the existence of other users'
96934 + processes on the system. This GID may also be chosen at boot time
96935 + via "grsec_proc_gid=" on the kernel commandline.
96936 +
96937 +config GRKERNSEC_TPE_UNTRUSTED_GID
96938 + int "GID for TPE-untrusted users"
96939 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
96940 + default 1005
96941 + help
96942 + Setting this GID determines which group untrusted users should
96943 + be added to. These users will be placed under grsecurity's Trusted Path
96944 + Execution mechanism, preventing them from executing their own binaries.
96945 + The users will only be able to execute binaries in directories owned and
96946 + writable only by the root user. If the sysctl option is enabled, a sysctl
96947 + option with name "tpe_gid" is created.
96948 +
96949 +config GRKERNSEC_TPE_TRUSTED_GID
96950 + int "GID for TPE-trusted users"
96951 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
96952 + default 1005
96953 + help
96954 + Setting this GID determines what group TPE restrictions will be
96955 + *disabled* for. If the sysctl option is enabled, a sysctl option
96956 + with name "tpe_gid" is created.
96957 +
96958 +config GRKERNSEC_SYMLINKOWN_GID
96959 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
96960 + depends on GRKERNSEC_CONFIG_SERVER
96961 + default 1006
96962 + help
96963 + Setting this GID determines what group kernel-enforced
96964 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
96965 + is enabled, a sysctl option with name "symlinkown_gid" is created.
96966 +
96967 +
96968 +endmenu
96969 +
96970 +menu "Customize Configuration"
96971 +depends on GRKERNSEC
96972 +
96973 +menu "PaX"
96974 +
96975 +config PAX
96976 + bool "Enable various PaX features"
96977 + default y if GRKERNSEC_CONFIG_AUTO
96978 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
96979 + help
96980 + This allows you to enable various PaX features. PaX adds
96981 + intrusion prevention mechanisms to the kernel that reduce
96982 + the risks posed by exploitable memory corruption bugs.
96983 +
96984 +menu "PaX Control"
96985 + depends on PAX
96986 +
96987 +config PAX_SOFTMODE
96988 + bool 'Support soft mode'
96989 + help
96990 + Enabling this option will allow you to run PaX in soft mode, that
96991 + is, PaX features will not be enforced by default, only on executables
96992 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
96993 + support as they are the only way to mark executables for soft mode use.
96994 +
96995 + Soft mode can be activated by using the "pax_softmode=1" kernel command
96996 + line option on boot. Furthermore you can control various PaX features
96997 + at runtime via the entries in /proc/sys/kernel/pax.
96998 +
96999 +config PAX_EI_PAX
97000 + bool 'Use legacy ELF header marking'
97001 + default y if GRKERNSEC_CONFIG_AUTO
97002 + help
97003 + Enabling this option will allow you to control PaX features on
97004 + a per executable basis via the 'chpax' utility available at
97005 + http://pax.grsecurity.net/. The control flags will be read from
97006 + an otherwise reserved part of the ELF header. This marking has
97007 + numerous drawbacks (no support for soft-mode, toolchain does not
97008 + know about the non-standard use of the ELF header) therefore it
97009 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
97010 + support.
97011 +
97012 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
97013 + support as well, they will override the legacy EI_PAX marks.
97014 +
97015 + If you enable none of the marking options then all applications
97016 + will run with PaX enabled on them by default.
97017 +
97018 +config PAX_PT_PAX_FLAGS
97019 + bool 'Use ELF program header marking'
97020 + default y if GRKERNSEC_CONFIG_AUTO
97021 + help
97022 + Enabling this option will allow you to control PaX features on
97023 + a per executable basis via the 'paxctl' utility available at
97024 + http://pax.grsecurity.net/. The control flags will be read from
97025 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
97026 + has the benefits of supporting both soft mode and being fully
97027 + integrated into the toolchain (the binutils patch is available
97028 + from http://pax.grsecurity.net).
97029 +
97030 + Note that if you enable the legacy EI_PAX marking support as well,
97031 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
97032 +
97033 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97034 + must make sure that the marks are the same if a binary has both marks.
97035 +
97036 + If you enable none of the marking options then all applications
97037 + will run with PaX enabled on them by default.
97038 +
97039 +config PAX_XATTR_PAX_FLAGS
97040 + bool 'Use filesystem extended attributes marking'
97041 + default y if GRKERNSEC_CONFIG_AUTO
97042 + select CIFS_XATTR if CIFS
97043 + select EXT2_FS_XATTR if EXT2_FS
97044 + select EXT3_FS_XATTR if EXT3_FS
97045 + select EXT4_FS_XATTR if EXT4_FS
97046 + select JFFS2_FS_XATTR if JFFS2_FS
97047 + select REISERFS_FS_XATTR if REISERFS_FS
97048 + select SQUASHFS_XATTR if SQUASHFS
97049 + select TMPFS_XATTR if TMPFS
97050 + select UBIFS_FS_XATTR if UBIFS_FS
97051 + help
97052 + Enabling this option will allow you to control PaX features on
97053 + a per executable basis via the 'setfattr' utility. The control
97054 + flags will be read from the user.pax.flags extended attribute of
97055 + the file. This marking has the benefit of supporting binary-only
97056 + applications that self-check themselves (e.g., skype) and would
97057 + not tolerate chpax/paxctl changes. The main drawback is that
97058 + extended attributes are not supported by some filesystems (e.g.,
97059 + isofs, udf, vfat) so copying files through such filesystems will
97060 + lose the extended attributes and these PaX markings.
97061 +
97062 + Note that if you enable the legacy EI_PAX marking support as well,
97063 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
97064 +
97065 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97066 + must make sure that the marks are the same if a binary has both marks.
97067 +
97068 + If you enable none of the marking options then all applications
97069 + will run with PaX enabled on them by default.
97070 +
97071 +choice
97072 + prompt 'MAC system integration'
97073 + default PAX_HAVE_ACL_FLAGS
97074 + help
97075 + Mandatory Access Control systems have the option of controlling
97076 + PaX flags on a per executable basis, choose the method supported
97077 + by your particular system.
97078 +
97079 + - "none": if your MAC system does not interact with PaX,
97080 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
97081 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
97082 +
97083 + NOTE: this option is for developers/integrators only.
97084 +
97085 + config PAX_NO_ACL_FLAGS
97086 + bool 'none'
97087 +
97088 + config PAX_HAVE_ACL_FLAGS
97089 + bool 'direct'
97090 +
97091 + config PAX_HOOK_ACL_FLAGS
97092 + bool 'hook'
97093 +endchoice
97094 +
97095 +endmenu
97096 +
97097 +menu "Non-executable pages"
97098 + depends on PAX
97099 +
97100 +config PAX_NOEXEC
97101 + bool "Enforce non-executable pages"
97102 + default y if GRKERNSEC_CONFIG_AUTO
97103 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
97104 + help
97105 + By design some architectures do not allow for protecting memory
97106 + pages against execution or even if they do, Linux does not make
97107 + use of this feature. In practice this means that if a page is
97108 + readable (such as the stack or heap) it is also executable.
97109 +
97110 + There is a well known exploit technique that makes use of this
97111 + fact and a common programming mistake where an attacker can
97112 + introduce code of his choice somewhere in the attacked program's
97113 + memory (typically the stack or the heap) and then execute it.
97114 +
97115 + If the attacked program was running with different (typically
97116 + higher) privileges than that of the attacker, then he can elevate
97117 + his own privilege level (e.g. get a root shell, write to files for
97118 + which he does not have write access to, etc).
97119 +
97120 + Enabling this option will let you choose from various features
97121 + that prevent the injection and execution of 'foreign' code in
97122 + a program.
97123 +
97124 + This will also break programs that rely on the old behaviour and
97125 + expect that dynamically allocated memory via the malloc() family
97126 + of functions is executable (which it is not). Notable examples
97127 + are the XFree86 4.x server, the java runtime and wine.
97128 +
97129 +config PAX_PAGEEXEC
97130 + bool "Paging based non-executable pages"
97131 + default y if GRKERNSEC_CONFIG_AUTO
97132 + depends on PAX_NOEXEC && (!X86_32 || M586 || M586TSC || M586MMX || M686 || MPENTIUMII || MPENTIUMIII || MPENTIUMM || MCORE2 || MATOM || MPENTIUM4 || MPSC || MK7 || MK8 || MWINCHIPC6 || MWINCHIP2 || MWINCHIP3D || MVIAC3_2 || MVIAC7)
97133 + select ARCH_TRACK_EXEC_LIMIT if X86_32
97134 + help
97135 + This implementation is based on the paging feature of the CPU.
97136 + On i386 without hardware non-executable bit support there is a
97137 + variable but usually low performance impact, however on Intel's
97138 + P4 core based CPUs it is very high so you should not enable this
97139 + for kernels meant to be used on such CPUs.
97140 +
97141 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
97142 + with hardware non-executable bit support there is no performance
97143 + impact, on ppc the impact is negligible.
97144 +
97145 + Note that several architectures require various emulations due to
97146 + badly designed userland ABIs, this will cause a performance impact
97147 + but will disappear as soon as userland is fixed. For example, ppc
97148 + userland MUST have been built with secure-plt by a recent toolchain.
97149 +
97150 +config PAX_SEGMEXEC
97151 + bool "Segmentation based non-executable pages"
97152 + default y if GRKERNSEC_CONFIG_AUTO
97153 + depends on PAX_NOEXEC && X86_32
97154 + help
97155 + This implementation is based on the segmentation feature of the
97156 + CPU and has a very small performance impact, however applications
97157 + will be limited to a 1.5 GB address space instead of the normal
97158 + 3 GB.
97159 +
97160 +config PAX_EMUTRAMP
97161 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
97162 + default y if PARISC
97163 + help
97164 + There are some programs and libraries that for one reason or
97165 + another attempt to execute special small code snippets from
97166 + non-executable memory pages. Most notable examples are the
97167 + signal handler return code generated by the kernel itself and
97168 + the GCC trampolines.
97169 +
97170 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
97171 + such programs will no longer work under your kernel.
97172 +
97173 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
97174 + utilities to enable trampoline emulation for the affected programs
97175 + yet still have the protection provided by the non-executable pages.
97176 +
97177 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
97178 + your system will not even boot.
97179 +
97180 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
97181 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
97182 + for the affected files.
97183 +
97184 + NOTE: enabling this feature *may* open up a loophole in the
97185 + protection provided by non-executable pages that an attacker
97186 + could abuse. Therefore the best solution is to not have any
97187 + files on your system that would require this option. This can
97188 + be achieved by not using libc5 (which relies on the kernel
97189 + signal handler return code) and not using or rewriting programs
97190 + that make use of the nested function implementation of GCC.
97191 + Skilled users can just fix GCC itself so that it implements
97192 + nested function calls in a way that does not interfere with PaX.
97193 +
97194 +config PAX_EMUSIGRT
97195 + bool "Automatically emulate sigreturn trampolines"
97196 + depends on PAX_EMUTRAMP && PARISC
97197 + default y
97198 + help
97199 + Enabling this option will have the kernel automatically detect
97200 + and emulate signal return trampolines executing on the stack
97201 + that would otherwise lead to task termination.
97202 +
97203 + This solution is intended as a temporary one for users with
97204 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
97205 + Modula-3 runtime, etc) or executables linked to such, basically
97206 + everything that does not specify its own SA_RESTORER function in
97207 + normal executable memory like glibc 2.1+ does.
97208 +
97209 + On parisc you MUST enable this option, otherwise your system will
97210 + not even boot.
97211 +
97212 + NOTE: this feature cannot be disabled on a per executable basis
97213 + and since it *does* open up a loophole in the protection provided
97214 + by non-executable pages, the best solution is to not have any
97215 + files on your system that would require this option.
97216 +
97217 +config PAX_MPROTECT
97218 + bool "Restrict mprotect()"
97219 + default y if GRKERNSEC_CONFIG_AUTO
97220 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
97221 + help
97222 + Enabling this option will prevent programs from
97223 + - changing the executable status of memory pages that were
97224 + not originally created as executable,
97225 + - making read-only executable pages writable again,
97226 + - creating executable pages from anonymous memory,
97227 + - making read-only-after-relocations (RELRO) data pages writable again.
97228 +
97229 + You should say Y here to complete the protection provided by
97230 + the enforcement of non-executable pages.
97231 +
97232 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
97233 + this feature on a per file basis.
97234 +
97235 +config PAX_MPROTECT_COMPAT
97236 + bool "Use legacy/compat protection demoting (read help)"
97237 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
97238 + depends on PAX_MPROTECT
97239 + help
97240 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
97241 + by sending the proper error code to the application. For some broken
97242 + userland, this can cause problems with Python or other applications. The
97243 + current implementation however allows for applications like clamav to
97244 + detect if JIT compilation/execution is allowed and to fall back gracefully
97245 + to an interpreter-based mode if it does not. While we encourage everyone
97246 + to use the current implementation as-is and push upstream to fix broken
97247 + userland (note that the RWX logging option can assist with this), in some
97248 + environments this may not be possible. Having to disable MPROTECT
97249 + completely on certain binaries reduces the security benefit of PaX,
97250 + so this option is provided for those environments to revert to the old
97251 + behavior.
97252 +
97253 +config PAX_ELFRELOCS
97254 + bool "Allow ELF text relocations (read help)"
97255 + depends on PAX_MPROTECT
97256 + default n
97257 + help
97258 + Non-executable pages and mprotect() restrictions are effective
97259 + in preventing the introduction of new executable code into an
97260 + attacked task's address space. There remain only two venues
97261 + for this kind of attack: if the attacker can execute already
97262 + existing code in the attacked task then he can either have it
97263 + create and mmap() a file containing his code or have it mmap()
97264 + an already existing ELF library that does not have position
97265 + independent code in it and use mprotect() on it to make it
97266 + writable and copy his code there. While protecting against
97267 + the former approach is beyond PaX, the latter can be prevented
97268 + by having only PIC ELF libraries on one's system (which do not
97269 + need to relocate their code). If you are sure this is your case,
97270 + as is the case with all modern Linux distributions, then leave
97271 + this option disabled. You should say 'n' here.
97272 +
97273 +config PAX_ETEXECRELOCS
97274 + bool "Allow ELF ET_EXEC text relocations"
97275 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
97276 + select PAX_ELFRELOCS
97277 + default y
97278 + help
97279 + On some architectures there are incorrectly created applications
97280 + that require text relocations and would not work without enabling
97281 + this option. If you are an alpha, ia64 or parisc user, you should
97282 + enable this option and disable it once you have made sure that
97283 + none of your applications need it.
97284 +
97285 +config PAX_EMUPLT
97286 + bool "Automatically emulate ELF PLT"
97287 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
97288 + default y
97289 + help
97290 + Enabling this option will have the kernel automatically detect
97291 + and emulate the Procedure Linkage Table entries in ELF files.
97292 + On some architectures such entries are in writable memory, and
97293 + become non-executable leading to task termination. Therefore
97294 + it is mandatory that you enable this option on alpha, parisc,
97295 + sparc and sparc64, otherwise your system would not even boot.
97296 +
97297 + NOTE: this feature *does* open up a loophole in the protection
97298 + provided by the non-executable pages, therefore the proper
97299 + solution is to modify the toolchain to produce a PLT that does
97300 + not need to be writable.
97301 +
97302 +config PAX_DLRESOLVE
97303 + bool 'Emulate old glibc resolver stub'
97304 + depends on PAX_EMUPLT && SPARC
97305 + default n
97306 + help
97307 + This option is needed if userland has an old glibc (before 2.4)
97308 + that puts a 'save' instruction into the runtime generated resolver
97309 + stub that needs special emulation.
97310 +
97311 +config PAX_KERNEXEC
97312 + bool "Enforce non-executable kernel pages"
97313 + default y if GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_NONE || (GRKERNSEC_CONFIG_VIRT_EPT && GRKERNSEC_CONFIG_VIRT_GUEST) || (GRKERNSEC_CONFIG_VIRT_EPT && GRKERNSEC_CONFIG_VIRT_KVM))
97314 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
97315 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
97316 + select PAX_KERNEXEC_PLUGIN if X86_64
97317 + help
97318 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
97319 + that is, enabling this option will make it harder to inject
97320 + and execute 'foreign' code in kernel memory itself.
97321 +
97322 +choice
97323 + prompt "Return Address Instrumentation Method"
97324 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
97325 + depends on PAX_KERNEXEC_PLUGIN
97326 + help
97327 + Select the method used to instrument function pointer dereferences.
97328 + Note that binary modules cannot be instrumented by this approach.
97329 +
97330 + Note that the implementation requires a gcc with plugin support,
97331 + i.e., gcc 4.5 or newer. You may need to install the supporting
97332 + headers explicitly in addition to the normal gcc package.
97333 +
97334 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
97335 + bool "bts"
97336 + help
97337 + This method is compatible with binary only modules but has
97338 + a higher runtime overhead.
97339 +
97340 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
97341 + bool "or"
97342 + depends on !PARAVIRT
97343 + help
97344 + This method is incompatible with binary only modules but has
97345 + a lower runtime overhead.
97346 +endchoice
97347 +
97348 +config PAX_KERNEXEC_PLUGIN_METHOD
97349 + string
97350 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
97351 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
97352 + default ""
97353 +
97354 +config PAX_KERNEXEC_MODULE_TEXT
97355 + int "Minimum amount of memory reserved for module code"
97356 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
97357 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
97358 + depends on PAX_KERNEXEC && X86_32
97359 + help
97360 + Due to implementation details the kernel must reserve a fixed
97361 + amount of memory for runtime allocated code (such as modules)
97362 + at compile time that cannot be changed at runtime. Here you
97363 + can specify the minimum amount in MB that will be reserved.
97364 + Due to the same implementation details this size will always
97365 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
97366 + the actually available memory for runtime allocated code will
97367 + usually be more than this minimum.
97368 +
97369 + The default 4 MB should be enough for most users but if you have
97370 + an excessive number of modules (e.g., most distribution configs
97371 + compile many drivers as modules) or use huge modules such as
97372 + nvidia's kernel driver, you will need to adjust this amount.
97373 + A good rule of thumb is to look at your currently loaded kernel
97374 + modules and add up their sizes.
97375 +
97376 +endmenu
97377 +
97378 +menu "Address Space Layout Randomization"
97379 + depends on PAX
97380 +
97381 +config PAX_ASLR
97382 + bool "Address Space Layout Randomization"
97383 + default y if GRKERNSEC_CONFIG_AUTO
97384 + help
97385 + Many if not most exploit techniques rely on the knowledge of
97386 + certain addresses in the attacked program. The following options
97387 + will allow the kernel to apply a certain amount of randomization
97388 + to specific parts of the program thereby forcing an attacker to
97389 + guess them in most cases. Any failed guess will most likely crash
97390 + the attacked program which allows the kernel to detect such attempts
97391 + and react on them. PaX itself provides no reaction mechanisms,
97392 + instead it is strongly encouraged that you make use of Nergal's
97393 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
97394 + (http://www.grsecurity.net/) built-in crash detection features or
97395 + develop one yourself.
97396 +
97397 + By saying Y here you can choose to randomize the following areas:
97398 + - top of the task's kernel stack
97399 + - top of the task's userland stack
97400 + - base address for mmap() requests that do not specify one
97401 + (this includes all libraries)
97402 + - base address of the main executable
97403 +
97404 + It is strongly recommended to say Y here as address space layout
97405 + randomization has negligible impact on performance yet it provides
97406 + a very effective protection.
97407 +
97408 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
97409 + this feature on a per file basis.
97410 +
97411 +config PAX_RANDKSTACK
97412 + bool "Randomize kernel stack base"
97413 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
97414 + depends on X86_TSC && X86
97415 + help
97416 + By saying Y here the kernel will randomize every task's kernel
97417 + stack on every system call. This will not only force an attacker
97418 + to guess it but also prevent him from making use of possible
97419 + leaked information about it.
97420 +
97421 + Since the kernel stack is a rather scarce resource, randomization
97422 + may cause unexpected stack overflows, therefore you should very
97423 + carefully test your system. Note that once enabled in the kernel
97424 + configuration, this feature cannot be disabled on a per file basis.
97425 +
97426 +config PAX_RANDUSTACK
97427 + bool "Randomize user stack base"
97428 + default y if GRKERNSEC_CONFIG_AUTO
97429 + depends on PAX_ASLR
97430 + help
97431 + By saying Y here the kernel will randomize every task's userland
97432 + stack. The randomization is done in two steps where the second
97433 + one may apply a big amount of shift to the top of the stack and
97434 + cause problems for programs that want to use lots of memory (more
97435 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
97436 + For this reason the second step can be controlled by 'chpax' or
97437 + 'paxctl' on a per file basis.
97438 +
97439 +config PAX_RANDMMAP
97440 + bool "Randomize mmap() base"
97441 + default y if GRKERNSEC_CONFIG_AUTO
97442 + depends on PAX_ASLR
97443 + help
97444 + By saying Y here the kernel will use a randomized base address for
97445 + mmap() requests that do not specify one themselves. As a result
97446 + all dynamically loaded libraries will appear at random addresses
97447 + and therefore be harder to exploit by a technique where an attacker
97448 + attempts to execute library code for his purposes (e.g. spawn a
97449 + shell from an exploited program that is running at an elevated
97450 + privilege level).
97451 +
97452 + Furthermore, if a program is relinked as a dynamic ELF file, its
97453 + base address will be randomized as well, completing the full
97454 + randomization of the address space layout. Attacking such programs
97455 + becomes a guess game. You can find an example of doing this at
97456 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
97457 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
97458 +
97459 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
97460 + feature on a per file basis.
97461 +
97462 +endmenu
97463 +
97464 +menu "Miscellaneous hardening features"
97465 +
97466 +config PAX_MEMORY_SANITIZE
97467 + bool "Sanitize all freed memory"
97468 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
97469 + depends on !HIBERNATION
97470 + help
97471 + By saying Y here the kernel will erase memory pages and slab objects
97472 + as soon as they are freed. This in turn reduces the lifetime of data
97473 + stored in them, making it less likely that sensitive information such
97474 + as passwords, cryptographic secrets, etc stay in memory for too long.
97475 +
97476 + This is especially useful for programs whose runtime is short, long
97477 + lived processes and the kernel itself benefit from this as long as
97478 + they ensure timely freeing of memory that may hold sensitive
97479 + information.
97480 +
97481 + A nice side effect of the sanitization of slab objects is the
97482 + reduction of possible info leaks caused by padding bytes within the
97483 + leaky structures. Use-after-free bugs for structures containing
97484 + pointers can also be detected as dereferencing the sanitized pointer
97485 + will generate an access violation.
97486 +
97487 + The tradeoff is performance impact, on a single CPU system kernel
97488 + compilation sees a 3% slowdown, other systems and workloads may vary
97489 + and you are advised to test this feature on your expected workload
97490 + before deploying it.
97491 +
97492 + To reduce the performance penalty by sanitizing pages only, albeit
97493 + limiting the effectiveness of this feature at the same time, slab
97494 + sanitization can be disabled with the kernel commandline parameter
97495 + "pax_sanitize_slab=0".
97496 +
97497 + Note that this feature does not protect data stored in live pages,
97498 + e.g., process memory swapped to disk may stay there for a long time.
97499 +
97500 +config PAX_MEMORY_STACKLEAK
97501 + bool "Sanitize kernel stack"
97502 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
97503 + depends on X86
97504 + help
97505 + By saying Y here the kernel will erase the kernel stack before it
97506 + returns from a system call. This in turn reduces the information
97507 + that a kernel stack leak bug can reveal.
97508 +
97509 + Note that such a bug can still leak information that was put on
97510 + the stack by the current system call (the one eventually triggering
97511 + the bug) but traces of earlier system calls on the kernel stack
97512 + cannot leak anymore.
97513 +
97514 + The tradeoff is performance impact: on a single CPU system kernel
97515 + compilation sees a 1% slowdown, other systems and workloads may vary
97516 + and you are advised to test this feature on your expected workload
97517 + before deploying it.
97518 +
97519 + Note that the full feature requires a gcc with plugin support,
97520 + i.e., gcc 4.5 or newer. You may need to install the supporting
97521 + headers explicitly in addition to the normal gcc package. Using
97522 + older gcc versions means that functions with large enough stack
97523 + frames may leave uninitialized memory behind that may be exposed
97524 + to a later syscall leaking the stack.
97525 +
97526 +config PAX_MEMORY_STRUCTLEAK
97527 + bool "Forcibly initialize local variables copied to userland"
97528 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
97529 + help
97530 + By saying Y here the kernel will zero initialize some local
97531 + variables that are going to be copied to userland. This in
97532 + turn prevents unintended information leakage from the kernel
97533 + stack should later code forget to explicitly set all parts of
97534 + the copied variable.
97535 +
97536 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
97537 + at a much smaller coverage.
97538 +
97539 + Note that the implementation requires a gcc with plugin support,
97540 + i.e., gcc 4.5 or newer. You may need to install the supporting
97541 + headers explicitly in addition to the normal gcc package.
97542 +
97543 +config PAX_MEMORY_UDEREF
97544 + bool "Prevent invalid userland pointer dereference"
97545 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
97546 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
97547 + select PAX_PER_CPU_PGD if X86_64
97548 + help
97549 + By saying Y here the kernel will be prevented from dereferencing
97550 + userland pointers in contexts where the kernel expects only kernel
97551 + pointers. This is both a useful runtime debugging feature and a
97552 + security measure that prevents exploiting a class of kernel bugs.
97553 +
97554 + The tradeoff is that some virtualization solutions may experience
97555 + a huge slowdown and therefore you should not enable this feature
97556 + for kernels meant to run in such environments. Whether a given VM
97557 + solution is affected or not is best determined by simply trying it
97558 + out, the performance impact will be obvious right on boot as this
97559 + mechanism engages from very early on. A good rule of thumb is that
97560 + VMs running on CPUs without hardware virtualization support (i.e.,
97561 + the majority of IA-32 CPUs) will likely experience the slowdown.
97562 +
97563 + On X86_64 the kernel will make use of PCID support when available
97564 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
97565 + or performance impact. Pass pax_weakuderef on the kernel command
97566 + line to choose the latter.
97567 +
97568 +config PAX_REFCOUNT
97569 + bool "Prevent various kernel object reference counter overflows"
97570 + default y if GRKERNSEC_CONFIG_AUTO
97571 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
97572 + help
97573 + By saying Y here the kernel will detect and prevent overflowing
97574 + various (but not all) kinds of object reference counters. Such
97575 + overflows can normally occur due to bugs only and are often, if
97576 + not always, exploitable.
97577 +
97578 + The tradeoff is that data structures protected by an overflowed
97579 + refcount will never be freed and therefore will leak memory. Note
97580 + that this leak also happens even without this protection but in
97581 + that case the overflow can eventually trigger the freeing of the
97582 + data structure while it is still being used elsewhere, resulting
97583 + in the exploitable situation that this feature prevents.
97584 +
97585 + Since this has a negligible performance impact, you should enable
97586 + this feature.
97587 +
97588 +config PAX_CONSTIFY_PLUGIN
97589 + bool "Automatically constify eligible structures"
97590 + default y
97591 + depends on !UML && PAX_KERNEXEC
97592 + help
97593 + By saying Y here the compiler will automatically constify a class
97594 + of types that contain only function pointers. This reduces the
97595 + kernel's attack surface and also produces a better memory layout.
97596 +
97597 + Note that the implementation requires a gcc with plugin support,
97598 + i.e., gcc 4.5 or newer. You may need to install the supporting
97599 + headers explicitly in addition to the normal gcc package.
97600 +
97601 + Note that if some code really has to modify constified variables
97602 + then the source code will have to be patched to allow it. Examples
97603 + can be found in PaX itself (the no_const attribute) and for some
97604 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
97605 +
97606 +config PAX_USERCOPY
97607 + bool "Harden heap object copies between kernel and userland"
97608 + default y if GRKERNSEC_CONFIG_AUTO
97609 + depends on ARM || IA64 || PPC || SPARC || X86
97610 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
97611 + select PAX_USERCOPY_SLABS
97612 + help
97613 + By saying Y here the kernel will enforce the size of heap objects
97614 + when they are copied in either direction between the kernel and
97615 + userland, even if only a part of the heap object is copied.
97616 +
97617 + Specifically, this checking prevents information leaking from the
97618 + kernel heap during kernel to userland copies (if the kernel heap
97619 + object is otherwise fully initialized) and prevents kernel heap
97620 + overflows during userland to kernel copies.
97621 +
97622 + Note that the current implementation provides the strictest bounds
97623 + checks for the SLUB allocator.
97624 +
97625 + Enabling this option also enables per-slab cache protection against
97626 + data in a given cache being copied into/out of via userland
97627 + accessors. Though the whitelist of regions will be reduced over
97628 + time, it notably protects important data structures like task structs.
97629 +
97630 + If frame pointers are enabled on x86, this option will also restrict
97631 + copies into and out of the kernel stack to local variables within a
97632 + single frame.
97633 +
97634 + Since this has a negligible performance impact, you should enable
97635 + this feature.
97636 +
97637 +config PAX_USERCOPY_DEBUG
97638 + bool
97639 + depends on X86 && PAX_USERCOPY
97640 + default n
97641 +
97642 +config PAX_SIZE_OVERFLOW
97643 + bool "Prevent various integer overflows in function size parameters"
97644 + default y if GRKERNSEC_CONFIG_AUTO
97645 + depends on X86
97646 + help
97647 + By saying Y here the kernel recomputes expressions of function
97648 + arguments marked by a size_overflow attribute with double integer
97649 + precision (DImode/TImode for 32/64 bit integer types).
97650 +
97651 + The recomputed argument is checked against TYPE_MAX and an event
97652 + is logged on overflow and the triggering process is killed.
97653 +
97654 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
97655 +
97656 + Note that the implementation requires a gcc with plugin support,
97657 + i.e., gcc 4.5 or newer. You may need to install the supporting
97658 + headers explicitly in addition to the normal gcc package.
97659 +
97660 +config PAX_LATENT_ENTROPY
97661 + bool "Generate some entropy during boot"
97662 + default y if GRKERNSEC_CONFIG_AUTO
97663 + help
97664 + By saying Y here the kernel will instrument early boot code to
97665 + extract some entropy from both original and artificially created
97666 + program state. This will help especially embedded systems where
97667 + there is little 'natural' source of entropy normally. The cost
97668 + is some slowdown of the boot process.
97669 +
97670 + When pax_extra_latent_entropy is passed on the kernel command line,
97671 + entropy will be extracted from up to the first 4GB of RAM while the
97672 + runtime memory allocator is being initialized. This costs even more
97673 + slowdown of the boot process.
97674 +
97675 + Note that the implementation requires a gcc with plugin support,
97676 + i.e., gcc 4.5 or newer. You may need to install the supporting
97677 + headers explicitly in addition to the normal gcc package.
97678 +
97679 + Note that entropy extracted this way is not cryptographically
97680 + secure!
97681 +
97682 +endmenu
97683 +
97684 +endmenu
97685 +
97686 +source grsecurity/Kconfig
97687 +
97688 +endmenu
97689 +
97690 +endmenu
97691 +
97692 source security/keys/Kconfig
97693
97694 config SECURITY_DMESG_RESTRICT
97695 @@ -103,7 +1056,7 @@ config INTEL_TXT
97696 config LSM_MMAP_MIN_ADDR
97697 int "Low address space for LSM to protect from user allocation"
97698 depends on SECURITY && SECURITY_SELINUX
97699 - default 32768 if ARM
97700 + default 32768 if ALPHA || ARM || PARISC || SPARC32
97701 default 65536
97702 help
97703 This is the portion of low virtual memory which should be protected
97704 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
97705 index 9b9013b..51ebf96 100644
97706 --- a/security/apparmor/Kconfig
97707 +++ b/security/apparmor/Kconfig
97708 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
97709 boot.
97710
97711 If you are unsure how to answer this question, answer 1.
97712 +
97713 +config SECURITY_APPARMOR_COMPAT_24
97714 + bool "Enable AppArmor 2.4 compatability"
97715 + depends on SECURITY_APPARMOR
97716 + default y
97717 + help
97718 + This option enables compatability with AppArmor 2.4. It is
97719 + recommended if compatability with older versions of AppArmor
97720 + is desired.
97721 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
97722 index 16c15ec..42b7c9f 100644
97723 --- a/security/apparmor/apparmorfs.c
97724 +++ b/security/apparmor/apparmorfs.c
97725 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
97726 .release = single_release,
97727 };
97728
97729 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
97730 +/**
97731 + * __next_namespace - find the next namespace to list
97732 + * @root: root namespace to stop search at (NOT NULL)
97733 + * @ns: current ns position (NOT NULL)
97734 + *
97735 + * Find the next namespace from @ns under @root and handle all locking needed
97736 + * while switching current namespace.
97737 + *
97738 + * Returns: next namespace or NULL if at last namespace under @root
97739 + * NOTE: will not unlock root->lock
97740 + */
97741 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
97742 + struct aa_namespace *ns)
97743 +{
97744 + struct aa_namespace *parent;
97745 +
97746 + /* is next namespace a child */
97747 + if (!list_empty(&ns->sub_ns)) {
97748 + struct aa_namespace *next;
97749 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
97750 + read_lock(&next->lock);
97751 + return next;
97752 + }
97753 +
97754 + /* check if the next ns is a sibling, parent, gp, .. */
97755 + parent = ns->parent;
97756 + while (parent) {
97757 + read_unlock(&ns->lock);
97758 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
97759 + read_lock(&ns->lock);
97760 + return ns;
97761 + }
97762 + if (parent == root)
97763 + return NULL;
97764 + ns = parent;
97765 + parent = parent->parent;
97766 + }
97767 +
97768 + return NULL;
97769 +}
97770 +
97771 +/**
97772 + * __first_profile - find the first profile in a namespace
97773 + * @root: namespace that is root of profiles being displayed (NOT NULL)
97774 + * @ns: namespace to start in (NOT NULL)
97775 + *
97776 + * Returns: unrefcounted profile or NULL if no profile
97777 + */
97778 +static struct aa_profile *__first_profile(struct aa_namespace *root,
97779 + struct aa_namespace *ns)
97780 +{
97781 + for ( ; ns; ns = __next_namespace(root, ns)) {
97782 + if (!list_empty(&ns->base.profiles))
97783 + return list_first_entry(&ns->base.profiles,
97784 + struct aa_profile, base.list);
97785 + }
97786 + return NULL;
97787 +}
97788 +
97789 +/**
97790 + * __next_profile - step to the next profile in a profile tree
97791 + * @profile: current profile in tree (NOT NULL)
97792 + *
97793 + * Perform a depth first taversal on the profile tree in a namespace
97794 + *
97795 + * Returns: next profile or NULL if done
97796 + * Requires: profile->ns.lock to be held
97797 + */
97798 +static struct aa_profile *__next_profile(struct aa_profile *p)
97799 +{
97800 + struct aa_profile *parent;
97801 + struct aa_namespace *ns = p->ns;
97802 +
97803 + /* is next profile a child */
97804 + if (!list_empty(&p->base.profiles))
97805 + return list_first_entry(&p->base.profiles, typeof(*p),
97806 + base.list);
97807 +
97808 + /* is next profile a sibling, parent sibling, gp, subling, .. */
97809 + parent = p->parent;
97810 + while (parent) {
97811 + list_for_each_entry_continue(p, &parent->base.profiles,
97812 + base.list)
97813 + return p;
97814 + p = parent;
97815 + parent = parent->parent;
97816 + }
97817 +
97818 + /* is next another profile in the namespace */
97819 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
97820 + return p;
97821 +
97822 + return NULL;
97823 +}
97824 +
97825 +/**
97826 + * next_profile - step to the next profile in where ever it may be
97827 + * @root: root namespace (NOT NULL)
97828 + * @profile: current profile (NOT NULL)
97829 + *
97830 + * Returns: next profile or NULL if there isn't one
97831 + */
97832 +static struct aa_profile *next_profile(struct aa_namespace *root,
97833 + struct aa_profile *profile)
97834 +{
97835 + struct aa_profile *next = __next_profile(profile);
97836 + if (next)
97837 + return next;
97838 +
97839 + /* finished all profiles in namespace move to next namespace */
97840 + return __first_profile(root, __next_namespace(root, profile->ns));
97841 +}
97842 +
97843 +/**
97844 + * p_start - start a depth first traversal of profile tree
97845 + * @f: seq_file to fill
97846 + * @pos: current position
97847 + *
97848 + * Returns: first profile under current namespace or NULL if none found
97849 + *
97850 + * acquires first ns->lock
97851 + */
97852 +static void *p_start(struct seq_file *f, loff_t *pos)
97853 + __acquires(root->lock)
97854 +{
97855 + struct aa_profile *profile = NULL;
97856 + struct aa_namespace *root = aa_current_profile()->ns;
97857 + loff_t l = *pos;
97858 + f->private = aa_get_namespace(root);
97859 +
97860 +
97861 + /* find the first profile */
97862 + read_lock(&root->lock);
97863 + profile = __first_profile(root, root);
97864 +
97865 + /* skip to position */
97866 + for (; profile && l > 0; l--)
97867 + profile = next_profile(root, profile);
97868 +
97869 + return profile;
97870 +}
97871 +
97872 +/**
97873 + * p_next - read the next profile entry
97874 + * @f: seq_file to fill
97875 + * @p: profile previously returned
97876 + * @pos: current position
97877 + *
97878 + * Returns: next profile after @p or NULL if none
97879 + *
97880 + * may acquire/release locks in namespace tree as necessary
97881 + */
97882 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
97883 +{
97884 + struct aa_profile *profile = p;
97885 + struct aa_namespace *root = f->private;
97886 + (*pos)++;
97887 +
97888 + return next_profile(root, profile);
97889 +}
97890 +
97891 +/**
97892 + * p_stop - stop depth first traversal
97893 + * @f: seq_file we are filling
97894 + * @p: the last profile writen
97895 + *
97896 + * Release all locking done by p_start/p_next on namespace tree
97897 + */
97898 +static void p_stop(struct seq_file *f, void *p)
97899 + __releases(root->lock)
97900 +{
97901 + struct aa_profile *profile = p;
97902 + struct aa_namespace *root = f->private, *ns;
97903 +
97904 + if (profile) {
97905 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
97906 + read_unlock(&ns->lock);
97907 + }
97908 + read_unlock(&root->lock);
97909 + aa_put_namespace(root);
97910 +}
97911 +
97912 +/**
97913 + * seq_show_profile - show a profile entry
97914 + * @f: seq_file to file
97915 + * @p: current position (profile) (NOT NULL)
97916 + *
97917 + * Returns: error on failure
97918 + */
97919 +static int seq_show_profile(struct seq_file *f, void *p)
97920 +{
97921 + struct aa_profile *profile = (struct aa_profile *)p;
97922 + struct aa_namespace *root = f->private;
97923 +
97924 + if (profile->ns != root)
97925 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
97926 + seq_printf(f, "%s (%s)\n", profile->base.hname,
97927 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
97928 +
97929 + return 0;
97930 +}
97931 +
97932 +static const struct seq_operations aa_fs_profiles_op = {
97933 + .start = p_start,
97934 + .next = p_next,
97935 + .stop = p_stop,
97936 + .show = seq_show_profile,
97937 +};
97938 +
97939 +static int profiles_open(struct inode *inode, struct file *file)
97940 +{
97941 + return seq_open(file, &aa_fs_profiles_op);
97942 +}
97943 +
97944 +static int profiles_release(struct inode *inode, struct file *file)
97945 +{
97946 + return seq_release(inode, file);
97947 +}
97948 +
97949 +const struct file_operations aa_fs_profiles_fops = {
97950 + .open = profiles_open,
97951 + .read = seq_read,
97952 + .llseek = seq_lseek,
97953 + .release = profiles_release,
97954 +};
97955 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
97956 +
97957 /** Base file system setup **/
97958
97959 static struct aa_fs_entry aa_fs_entry_file[] = {
97960 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
97961 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
97962 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
97963 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
97964 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
97965 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
97966 +#endif
97967 AA_FS_DIR("features", aa_fs_entry_features),
97968 { }
97969 };
97970 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
97971 index 2e2a0dd..a0cbc44 100644
97972 --- a/security/apparmor/lsm.c
97973 +++ b/security/apparmor/lsm.c
97974 @@ -613,7 +613,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
97975 return error;
97976 }
97977
97978 -static struct security_operations apparmor_ops = {
97979 +static struct security_operations apparmor_ops __read_only = {
97980 .name = "apparmor",
97981
97982 .ptrace_access_check = apparmor_ptrace_access_check,
97983 diff --git a/security/commoncap.c b/security/commoncap.c
97984 index c44b6fe..932df30 100644
97985 --- a/security/commoncap.c
97986 +++ b/security/commoncap.c
97987 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
97988 return 0;
97989 }
97990
97991 +/* returns:
97992 + 1 for suid privilege
97993 + 2 for sgid privilege
97994 + 3 for fscap privilege
97995 +*/
97996 +int is_privileged_binary(const struct dentry *dentry)
97997 +{
97998 + struct cpu_vfs_cap_data capdata;
97999 + struct inode *inode = dentry->d_inode;
98000 +
98001 + if (!inode || S_ISDIR(inode->i_mode))
98002 + return 0;
98003 +
98004 + if (inode->i_mode & S_ISUID)
98005 + return 1;
98006 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
98007 + return 2;
98008 +
98009 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
98010 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
98011 + return 3;
98012 + }
98013 +
98014 + return 0;
98015 +}
98016 +
98017 /*
98018 * Attempt to get the on-exec apply capability sets for an executable file from
98019 * its xattrs and, if present, apply them to the proposed credentials being
98020 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
98021 const struct cred *cred = current_cred();
98022 kuid_t root_uid = make_kuid(cred->user_ns, 0);
98023
98024 + if (gr_acl_enable_at_secure())
98025 + return 1;
98026 +
98027 if (!uid_eq(cred->uid, root_uid)) {
98028 if (bprm->cap_effective)
98029 return 1;
98030 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
98031 index b3dd616..4bb17f3 100644
98032 --- a/security/integrity/ima/ima.h
98033 +++ b/security/integrity/ima/ima.h
98034 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
98035 extern spinlock_t ima_queue_lock;
98036
98037 struct ima_h_table {
98038 - atomic_long_t len; /* number of stored measurements in the list */
98039 - atomic_long_t violations;
98040 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
98041 + atomic_long_unchecked_t violations;
98042 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
98043 };
98044 extern struct ima_h_table ima_htable;
98045 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
98046 index 1c03e8f1..398a941 100644
98047 --- a/security/integrity/ima/ima_api.c
98048 +++ b/security/integrity/ima/ima_api.c
98049 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
98050 int result;
98051
98052 /* can overflow, only indicator */
98053 - atomic_long_inc(&ima_htable.violations);
98054 + atomic_long_inc_unchecked(&ima_htable.violations);
98055
98056 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
98057 if (!entry) {
98058 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
98059 index 38477c9..87a60c7 100644
98060 --- a/security/integrity/ima/ima_fs.c
98061 +++ b/security/integrity/ima/ima_fs.c
98062 @@ -28,12 +28,12 @@
98063 static int valid_policy = 1;
98064 #define TMPBUFLEN 12
98065 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
98066 - loff_t *ppos, atomic_long_t *val)
98067 + loff_t *ppos, atomic_long_unchecked_t *val)
98068 {
98069 char tmpbuf[TMPBUFLEN];
98070 ssize_t len;
98071
98072 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
98073 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
98074 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
98075 }
98076
98077 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
98078 index ff63fe0..809cd96 100644
98079 --- a/security/integrity/ima/ima_queue.c
98080 +++ b/security/integrity/ima/ima_queue.c
98081 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
98082 INIT_LIST_HEAD(&qe->later);
98083 list_add_tail_rcu(&qe->later, &ima_measurements);
98084
98085 - atomic_long_inc(&ima_htable.len);
98086 + atomic_long_inc_unchecked(&ima_htable.len);
98087 key = ima_hash_key(entry->digest);
98088 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
98089 return 0;
98090 diff --git a/security/keys/compat.c b/security/keys/compat.c
98091 index d65fa7f..cbfe366 100644
98092 --- a/security/keys/compat.c
98093 +++ b/security/keys/compat.c
98094 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
98095 if (ret == 0)
98096 goto no_payload_free;
98097
98098 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
98099 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
98100 err:
98101 if (iov != iovstack)
98102 kfree(iov);
98103 diff --git a/security/keys/internal.h b/security/keys/internal.h
98104 index d4f1468..cc52f92 100644
98105 --- a/security/keys/internal.h
98106 +++ b/security/keys/internal.h
98107 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
98108 extern long keyctl_invalidate_key(key_serial_t);
98109
98110 extern long keyctl_instantiate_key_common(key_serial_t,
98111 - const struct iovec *,
98112 + const struct iovec __user *,
98113 unsigned, size_t, key_serial_t);
98114
98115 /*
98116 diff --git a/security/keys/key.c b/security/keys/key.c
98117 index 8fb7c7b..ba3610d 100644
98118 --- a/security/keys/key.c
98119 +++ b/security/keys/key.c
98120 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
98121
98122 atomic_set(&key->usage, 1);
98123 init_rwsem(&key->sem);
98124 - lockdep_set_class(&key->sem, &type->lock_class);
98125 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
98126 key->type = type;
98127 key->user = user;
98128 key->quotalen = quotalen;
98129 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
98130 struct key_type *p;
98131 int ret;
98132
98133 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
98134 + pax_open_kernel();
98135 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
98136 + pax_close_kernel();
98137
98138 ret = -EEXIST;
98139 down_write(&key_types_sem);
98140 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
98141 }
98142
98143 /* store the type */
98144 - list_add(&ktype->link, &key_types_list);
98145 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
98146
98147 pr_notice("Key type %s registered\n", ktype->name);
98148 ret = 0;
98149 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
98150 void unregister_key_type(struct key_type *ktype)
98151 {
98152 down_write(&key_types_sem);
98153 - list_del_init(&ktype->link);
98154 + pax_list_del_init((struct list_head *)&ktype->link);
98155 downgrade_write(&key_types_sem);
98156 key_gc_keytype(ktype);
98157 pr_notice("Key type %s unregistered\n", ktype->name);
98158 @@ -1084,10 +1086,10 @@ void __init key_init(void)
98159 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
98160
98161 /* add the special key types */
98162 - list_add_tail(&key_type_keyring.link, &key_types_list);
98163 - list_add_tail(&key_type_dead.link, &key_types_list);
98164 - list_add_tail(&key_type_user.link, &key_types_list);
98165 - list_add_tail(&key_type_logon.link, &key_types_list);
98166 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
98167 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
98168 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
98169 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
98170
98171 /* record the root user tracking */
98172 rb_link_node(&root_key_user.node,
98173 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
98174 index 33cfd27..842fc5a 100644
98175 --- a/security/keys/keyctl.c
98176 +++ b/security/keys/keyctl.c
98177 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
98178 /*
98179 * Copy the iovec data from userspace
98180 */
98181 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
98182 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
98183 unsigned ioc)
98184 {
98185 for (; ioc > 0; ioc--) {
98186 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
98187 * If successful, 0 will be returned.
98188 */
98189 long keyctl_instantiate_key_common(key_serial_t id,
98190 - const struct iovec *payload_iov,
98191 + const struct iovec __user *payload_iov,
98192 unsigned ioc,
98193 size_t plen,
98194 key_serial_t ringid)
98195 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
98196 [0].iov_len = plen
98197 };
98198
98199 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
98200 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
98201 }
98202
98203 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
98204 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
98205 if (ret == 0)
98206 goto no_payload_free;
98207
98208 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
98209 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
98210 err:
98211 if (iov != iovstack)
98212 kfree(iov);
98213 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
98214 index 6ece7f2..ecdb55c 100644
98215 --- a/security/keys/keyring.c
98216 +++ b/security/keys/keyring.c
98217 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
98218 ret = -EFAULT;
98219
98220 for (loop = 0; loop < klist->nkeys; loop++) {
98221 + key_serial_t serial;
98222 key = rcu_deref_link_locked(klist, loop,
98223 keyring);
98224 + serial = key->serial;
98225
98226 tmp = sizeof(key_serial_t);
98227 if (tmp > buflen)
98228 tmp = buflen;
98229
98230 - if (copy_to_user(buffer,
98231 - &key->serial,
98232 - tmp) != 0)
98233 + if (copy_to_user(buffer, &serial, tmp))
98234 goto error;
98235
98236 buflen -= tmp;
98237 diff --git a/security/min_addr.c b/security/min_addr.c
98238 index f728728..6457a0c 100644
98239 --- a/security/min_addr.c
98240 +++ b/security/min_addr.c
98241 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
98242 */
98243 static void update_mmap_min_addr(void)
98244 {
98245 +#ifndef SPARC
98246 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
98247 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
98248 mmap_min_addr = dac_mmap_min_addr;
98249 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
98250 #else
98251 mmap_min_addr = dac_mmap_min_addr;
98252 #endif
98253 +#endif
98254 }
98255
98256 /*
98257 diff --git a/security/security.c b/security/security.c
98258 index 94b35ae..f4e7751 100644
98259 --- a/security/security.c
98260 +++ b/security/security.c
98261 @@ -33,8 +33,8 @@
98262 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
98263 CONFIG_DEFAULT_SECURITY;
98264
98265 -static struct security_operations *security_ops;
98266 -static struct security_operations default_security_ops = {
98267 +struct security_operations *security_ops __read_only;
98268 +struct security_operations default_security_ops __read_only = {
98269 .name = "default",
98270 };
98271
98272 @@ -73,11 +73,6 @@ int __init security_init(void)
98273 return 0;
98274 }
98275
98276 -void reset_security_ops(void)
98277 -{
98278 - security_ops = &default_security_ops;
98279 -}
98280 -
98281 /* Save user chosen LSM */
98282 static int __init choose_lsm(char *str)
98283 {
98284 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
98285 index dad36a6..7e5ffbf 100644
98286 --- a/security/selinux/avc.c
98287 +++ b/security/selinux/avc.c
98288 @@ -59,7 +59,7 @@ struct avc_node {
98289 struct avc_cache {
98290 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
98291 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
98292 - atomic_t lru_hint; /* LRU hint for reclaim scan */
98293 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
98294 atomic_t active_nodes;
98295 u32 latest_notif; /* latest revocation notification */
98296 };
98297 @@ -167,7 +167,7 @@ void __init avc_init(void)
98298 spin_lock_init(&avc_cache.slots_lock[i]);
98299 }
98300 atomic_set(&avc_cache.active_nodes, 0);
98301 - atomic_set(&avc_cache.lru_hint, 0);
98302 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
98303
98304 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
98305 0, SLAB_PANIC, NULL);
98306 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
98307 spinlock_t *lock;
98308
98309 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
98310 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
98311 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
98312 head = &avc_cache.slots[hvalue];
98313 lock = &avc_cache.slots_lock[hvalue];
98314
98315 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
98316 index c956390..1899f06 100644
98317 --- a/security/selinux/hooks.c
98318 +++ b/security/selinux/hooks.c
98319 @@ -97,8 +97,6 @@
98320
98321 #define NUM_SEL_MNT_OPTS 5
98322
98323 -extern struct security_operations *security_ops;
98324 -
98325 /* SECMARK reference count */
98326 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
98327
98328 @@ -5609,7 +5607,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
98329
98330 #endif
98331
98332 -static struct security_operations selinux_ops = {
98333 +static struct security_operations selinux_ops __read_only = {
98334 .name = "selinux",
98335
98336 .ptrace_access_check = selinux_ptrace_access_check,
98337 @@ -5961,6 +5959,9 @@ static void selinux_nf_ip_exit(void)
98338 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
98339 static int selinux_disabled;
98340
98341 +extern struct security_operations *security_ops;
98342 +extern struct security_operations default_security_ops;
98343 +
98344 int selinux_disable(void)
98345 {
98346 if (ss_initialized) {
98347 @@ -5978,7 +5979,9 @@ int selinux_disable(void)
98348 selinux_disabled = 1;
98349 selinux_enabled = 0;
98350
98351 - reset_security_ops();
98352 + pax_open_kernel();
98353 + security_ops = &default_security_ops;
98354 + pax_close_kernel();
98355
98356 /* Try to destroy the avc node cache */
98357 avc_disable();
98358 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
98359 index 65f67cb..3f141ef 100644
98360 --- a/security/selinux/include/xfrm.h
98361 +++ b/security/selinux/include/xfrm.h
98362 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
98363
98364 static inline void selinux_xfrm_notify_policyload(void)
98365 {
98366 - atomic_inc(&flow_cache_genid);
98367 + atomic_inc_unchecked(&flow_cache_genid);
98368 rt_genid_bump(&init_net);
98369 }
98370 #else
98371 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
98372 index eefbd10..9f10ddb 100644
98373 --- a/security/smack/smack_lsm.c
98374 +++ b/security/smack/smack_lsm.c
98375 @@ -3711,7 +3711,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
98376 return 0;
98377 }
98378
98379 -struct security_operations smack_ops = {
98380 +struct security_operations smack_ops __read_only = {
98381 .name = "smack",
98382
98383 .ptrace_access_check = smack_ptrace_access_check,
98384 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
98385 index 390c646..f2f8db3 100644
98386 --- a/security/tomoyo/mount.c
98387 +++ b/security/tomoyo/mount.c
98388 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
98389 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
98390 need_dev = -1; /* dev_name is a directory */
98391 } else {
98392 + if (!capable(CAP_SYS_ADMIN)) {
98393 + error = -EPERM;
98394 + goto out;
98395 + }
98396 fstype = get_fs_type(type);
98397 if (!fstype) {
98398 error = -ENODEV;
98399 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
98400 index f0b756e..b129202 100644
98401 --- a/security/tomoyo/tomoyo.c
98402 +++ b/security/tomoyo/tomoyo.c
98403 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
98404 * tomoyo_security_ops is a "struct security_operations" which is used for
98405 * registering TOMOYO.
98406 */
98407 -static struct security_operations tomoyo_security_ops = {
98408 +static struct security_operations tomoyo_security_ops __read_only = {
98409 .name = "tomoyo",
98410 .cred_alloc_blank = tomoyo_cred_alloc_blank,
98411 .cred_prepare = tomoyo_cred_prepare,
98412 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
98413 index 20ef514..4182bed 100644
98414 --- a/security/yama/Kconfig
98415 +++ b/security/yama/Kconfig
98416 @@ -1,6 +1,6 @@
98417 config SECURITY_YAMA
98418 bool "Yama support"
98419 - depends on SECURITY
98420 + depends on SECURITY && !GRKERNSEC
98421 select SECURITYFS
98422 select SECURITY_PATH
98423 default n
98424 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
98425 index 13c88fbc..f8c115e 100644
98426 --- a/security/yama/yama_lsm.c
98427 +++ b/security/yama/yama_lsm.c
98428 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
98429 }
98430
98431 #ifndef CONFIG_SECURITY_YAMA_STACKED
98432 -static struct security_operations yama_ops = {
98433 +static struct security_operations yama_ops __read_only = {
98434 .name = "yama",
98435
98436 .ptrace_access_check = yama_ptrace_access_check,
98437 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
98438 #endif
98439
98440 #ifdef CONFIG_SYSCTL
98441 +static int zero __read_only;
98442 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
98443 +
98444 static int yama_dointvec_minmax(struct ctl_table *table, int write,
98445 void __user *buffer, size_t *lenp, loff_t *ppos)
98446 {
98447 - int rc;
98448 + ctl_table_no_const yama_table;
98449
98450 if (write && !capable(CAP_SYS_PTRACE))
98451 return -EPERM;
98452
98453 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
98454 - if (rc)
98455 - return rc;
98456 -
98457 + yama_table = *table;
98458 /* Lock the max value if it ever gets set. */
98459 - if (write && *(int *)table->data == *(int *)table->extra2)
98460 - table->extra1 = table->extra2;
98461 -
98462 - return rc;
98463 + if (ptrace_scope == max_scope)
98464 + yama_table.extra1 = &max_scope;
98465 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
98466 }
98467
98468 -static int zero;
98469 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
98470 -
98471 struct ctl_path yama_sysctl_path[] = {
98472 { .procname = "kernel", },
98473 { .procname = "yama", },
98474 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
98475 index 4cedc69..e59d8a3 100644
98476 --- a/sound/aoa/codecs/onyx.c
98477 +++ b/sound/aoa/codecs/onyx.c
98478 @@ -54,7 +54,7 @@ struct onyx {
98479 spdif_locked:1,
98480 analog_locked:1,
98481 original_mute:2;
98482 - int open_count;
98483 + local_t open_count;
98484 struct codec_info *codec_info;
98485
98486 /* mutex serializes concurrent access to the device
98487 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
98488 struct onyx *onyx = cii->codec_data;
98489
98490 mutex_lock(&onyx->mutex);
98491 - onyx->open_count++;
98492 + local_inc(&onyx->open_count);
98493 mutex_unlock(&onyx->mutex);
98494
98495 return 0;
98496 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
98497 struct onyx *onyx = cii->codec_data;
98498
98499 mutex_lock(&onyx->mutex);
98500 - onyx->open_count--;
98501 - if (!onyx->open_count)
98502 + if (local_dec_and_test(&onyx->open_count))
98503 onyx->spdif_locked = onyx->analog_locked = 0;
98504 mutex_unlock(&onyx->mutex);
98505
98506 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
98507 index ffd2025..df062c9 100644
98508 --- a/sound/aoa/codecs/onyx.h
98509 +++ b/sound/aoa/codecs/onyx.h
98510 @@ -11,6 +11,7 @@
98511 #include <linux/i2c.h>
98512 #include <asm/pmac_low_i2c.h>
98513 #include <asm/prom.h>
98514 +#include <asm/local.h>
98515
98516 /* PCM3052 register definitions */
98517
98518 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
98519 index 4c1cc51..16040040 100644
98520 --- a/sound/core/oss/pcm_oss.c
98521 +++ b/sound/core/oss/pcm_oss.c
98522 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
98523 if (in_kernel) {
98524 mm_segment_t fs;
98525 fs = snd_enter_user();
98526 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
98527 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
98528 snd_leave_user(fs);
98529 } else {
98530 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
98531 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
98532 }
98533 if (ret != -EPIPE && ret != -ESTRPIPE)
98534 break;
98535 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
98536 if (in_kernel) {
98537 mm_segment_t fs;
98538 fs = snd_enter_user();
98539 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
98540 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
98541 snd_leave_user(fs);
98542 } else {
98543 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
98544 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
98545 }
98546 if (ret == -EPIPE) {
98547 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
98548 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
98549 struct snd_pcm_plugin_channel *channels;
98550 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
98551 if (!in_kernel) {
98552 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
98553 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
98554 return -EFAULT;
98555 buf = runtime->oss.buffer;
98556 }
98557 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
98558 }
98559 } else {
98560 tmp = snd_pcm_oss_write2(substream,
98561 - (const char __force *)buf,
98562 + (const char __force_kernel *)buf,
98563 runtime->oss.period_bytes, 0);
98564 if (tmp <= 0)
98565 goto err;
98566 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
98567 struct snd_pcm_runtime *runtime = substream->runtime;
98568 snd_pcm_sframes_t frames, frames1;
98569 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
98570 - char __user *final_dst = (char __force __user *)buf;
98571 + char __user *final_dst = (char __force_user *)buf;
98572 if (runtime->oss.plugin_first) {
98573 struct snd_pcm_plugin_channel *channels;
98574 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
98575 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
98576 xfer += tmp;
98577 runtime->oss.buffer_used -= tmp;
98578 } else {
98579 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
98580 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
98581 runtime->oss.period_bytes, 0);
98582 if (tmp <= 0)
98583 goto err;
98584 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
98585 size1);
98586 size1 /= runtime->channels; /* frames */
98587 fs = snd_enter_user();
98588 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
98589 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
98590 snd_leave_user(fs);
98591 }
98592 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
98593 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
98594 index af49721..e85058e 100644
98595 --- a/sound/core/pcm_compat.c
98596 +++ b/sound/core/pcm_compat.c
98597 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
98598 int err;
98599
98600 fs = snd_enter_user();
98601 - err = snd_pcm_delay(substream, &delay);
98602 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
98603 snd_leave_user(fs);
98604 if (err < 0)
98605 return err;
98606 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
98607 index a68d4c6..72af3cf 100644
98608 --- a/sound/core/pcm_native.c
98609 +++ b/sound/core/pcm_native.c
98610 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
98611 switch (substream->stream) {
98612 case SNDRV_PCM_STREAM_PLAYBACK:
98613 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
98614 - (void __user *)arg);
98615 + (void __force_user *)arg);
98616 break;
98617 case SNDRV_PCM_STREAM_CAPTURE:
98618 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
98619 - (void __user *)arg);
98620 + (void __force_user *)arg);
98621 break;
98622 default:
98623 result = -EINVAL;
98624 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
98625 index 040c60e..989a19a 100644
98626 --- a/sound/core/seq/seq_device.c
98627 +++ b/sound/core/seq/seq_device.c
98628 @@ -64,7 +64,7 @@ struct ops_list {
98629 int argsize; /* argument size */
98630
98631 /* operators */
98632 - struct snd_seq_dev_ops ops;
98633 + struct snd_seq_dev_ops *ops;
98634
98635 /* registered devices */
98636 struct list_head dev_list; /* list of devices */
98637 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
98638
98639 mutex_lock(&ops->reg_mutex);
98640 /* copy driver operators */
98641 - ops->ops = *entry;
98642 + ops->ops = entry;
98643 ops->driver |= DRIVER_LOADED;
98644 ops->argsize = argsize;
98645
98646 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
98647 dev->name, ops->id, ops->argsize, dev->argsize);
98648 return -EINVAL;
98649 }
98650 - if (ops->ops.init_device(dev) >= 0) {
98651 + if (ops->ops->init_device(dev) >= 0) {
98652 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
98653 ops->num_init_devices++;
98654 } else {
98655 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
98656 dev->name, ops->id, ops->argsize, dev->argsize);
98657 return -EINVAL;
98658 }
98659 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
98660 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
98661 dev->status = SNDRV_SEQ_DEVICE_FREE;
98662 dev->driver_data = NULL;
98663 ops->num_init_devices--;
98664 diff --git a/sound/core/sound.c b/sound/core/sound.c
98665 index f002bd9..c462985 100644
98666 --- a/sound/core/sound.c
98667 +++ b/sound/core/sound.c
98668 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
98669 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
98670 default: return;
98671 }
98672 - request_module(str);
98673 + request_module("%s", str);
98674 }
98675
98676 #endif /* modular kernel */
98677 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
98678 index 4e0dd22..7a1f32c 100644
98679 --- a/sound/drivers/mts64.c
98680 +++ b/sound/drivers/mts64.c
98681 @@ -29,6 +29,7 @@
98682 #include <sound/initval.h>
98683 #include <sound/rawmidi.h>
98684 #include <sound/control.h>
98685 +#include <asm/local.h>
98686
98687 #define CARD_NAME "Miditerminal 4140"
98688 #define DRIVER_NAME "MTS64"
98689 @@ -67,7 +68,7 @@ struct mts64 {
98690 struct pardevice *pardev;
98691 int pardev_claimed;
98692
98693 - int open_count;
98694 + local_t open_count;
98695 int current_midi_output_port;
98696 int current_midi_input_port;
98697 u8 mode[MTS64_NUM_INPUT_PORTS];
98698 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
98699 {
98700 struct mts64 *mts = substream->rmidi->private_data;
98701
98702 - if (mts->open_count == 0) {
98703 + if (local_read(&mts->open_count) == 0) {
98704 /* We don't need a spinlock here, because this is just called
98705 if the device has not been opened before.
98706 So there aren't any IRQs from the device */
98707 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
98708
98709 msleep(50);
98710 }
98711 - ++(mts->open_count);
98712 + local_inc(&mts->open_count);
98713
98714 return 0;
98715 }
98716 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
98717 struct mts64 *mts = substream->rmidi->private_data;
98718 unsigned long flags;
98719
98720 - --(mts->open_count);
98721 - if (mts->open_count == 0) {
98722 + if (local_dec_return(&mts->open_count) == 0) {
98723 /* We need the spinlock_irqsave here because we can still
98724 have IRQs at this point */
98725 spin_lock_irqsave(&mts->lock, flags);
98726 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
98727
98728 msleep(500);
98729
98730 - } else if (mts->open_count < 0)
98731 - mts->open_count = 0;
98732 + } else if (local_read(&mts->open_count) < 0)
98733 + local_set(&mts->open_count, 0);
98734
98735 return 0;
98736 }
98737 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
98738 index b953fb4..1999c01 100644
98739 --- a/sound/drivers/opl4/opl4_lib.c
98740 +++ b/sound/drivers/opl4/opl4_lib.c
98741 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
98742 MODULE_DESCRIPTION("OPL4 driver");
98743 MODULE_LICENSE("GPL");
98744
98745 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
98746 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
98747 {
98748 int timeout = 10;
98749 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
98750 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
98751 index 991018d..8984740 100644
98752 --- a/sound/drivers/portman2x4.c
98753 +++ b/sound/drivers/portman2x4.c
98754 @@ -48,6 +48,7 @@
98755 #include <sound/initval.h>
98756 #include <sound/rawmidi.h>
98757 #include <sound/control.h>
98758 +#include <asm/local.h>
98759
98760 #define CARD_NAME "Portman 2x4"
98761 #define DRIVER_NAME "portman"
98762 @@ -85,7 +86,7 @@ struct portman {
98763 struct pardevice *pardev;
98764 int pardev_claimed;
98765
98766 - int open_count;
98767 + local_t open_count;
98768 int mode[PORTMAN_NUM_INPUT_PORTS];
98769 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
98770 };
98771 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
98772 index ea995af..f1bfa37 100644
98773 --- a/sound/firewire/amdtp.c
98774 +++ b/sound/firewire/amdtp.c
98775 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
98776 ptr = s->pcm_buffer_pointer + data_blocks;
98777 if (ptr >= pcm->runtime->buffer_size)
98778 ptr -= pcm->runtime->buffer_size;
98779 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
98780 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
98781
98782 s->pcm_period_pointer += data_blocks;
98783 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
98784 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
98785 */
98786 void amdtp_out_stream_update(struct amdtp_out_stream *s)
98787 {
98788 - ACCESS_ONCE(s->source_node_id_field) =
98789 + ACCESS_ONCE_RW(s->source_node_id_field) =
98790 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
98791 }
98792 EXPORT_SYMBOL(amdtp_out_stream_update);
98793 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
98794 index f6103d6..4843fbf 100644
98795 --- a/sound/firewire/amdtp.h
98796 +++ b/sound/firewire/amdtp.h
98797 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
98798 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
98799 struct snd_pcm_substream *pcm)
98800 {
98801 - ACCESS_ONCE(s->pcm) = pcm;
98802 + ACCESS_ONCE_RW(s->pcm) = pcm;
98803 }
98804
98805 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
98806 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
98807 index 58a5afe..af5bd64 100644
98808 --- a/sound/firewire/isight.c
98809 +++ b/sound/firewire/isight.c
98810 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
98811 ptr += count;
98812 if (ptr >= runtime->buffer_size)
98813 ptr -= runtime->buffer_size;
98814 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
98815 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
98816
98817 isight->period_counter += count;
98818 if (isight->period_counter >= runtime->period_size) {
98819 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
98820 if (err < 0)
98821 return err;
98822
98823 - ACCESS_ONCE(isight->pcm_active) = true;
98824 + ACCESS_ONCE_RW(isight->pcm_active) = true;
98825
98826 return 0;
98827 }
98828 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
98829 {
98830 struct isight *isight = substream->private_data;
98831
98832 - ACCESS_ONCE(isight->pcm_active) = false;
98833 + ACCESS_ONCE_RW(isight->pcm_active) = false;
98834
98835 mutex_lock(&isight->mutex);
98836 isight_stop_streaming(isight);
98837 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
98838
98839 switch (cmd) {
98840 case SNDRV_PCM_TRIGGER_START:
98841 - ACCESS_ONCE(isight->pcm_running) = true;
98842 + ACCESS_ONCE_RW(isight->pcm_running) = true;
98843 break;
98844 case SNDRV_PCM_TRIGGER_STOP:
98845 - ACCESS_ONCE(isight->pcm_running) = false;
98846 + ACCESS_ONCE_RW(isight->pcm_running) = false;
98847 break;
98848 default:
98849 return -EINVAL;
98850 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
98851 index 505fc81..62e569e 100644
98852 --- a/sound/firewire/scs1x.c
98853 +++ b/sound/firewire/scs1x.c
98854 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
98855 {
98856 struct scs *scs = stream->rmidi->private_data;
98857
98858 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
98859 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
98860 if (up) {
98861 scs->output_idle = false;
98862 tasklet_schedule(&scs->tasklet);
98863 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
98864 {
98865 struct scs *scs = stream->rmidi->private_data;
98866
98867 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
98868 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
98869 }
98870
98871 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
98872 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
98873
98874 snd_card_disconnect(scs->card);
98875
98876 - ACCESS_ONCE(scs->output) = NULL;
98877 - ACCESS_ONCE(scs->input) = NULL;
98878 + ACCESS_ONCE_RW(scs->output) = NULL;
98879 + ACCESS_ONCE_RW(scs->input) = NULL;
98880
98881 wait_event(scs->idle_wait, scs->output_idle);
98882
98883 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
98884 index 048439a..3be9f6f 100644
98885 --- a/sound/oss/sb_audio.c
98886 +++ b/sound/oss/sb_audio.c
98887 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
98888 buf16 = (signed short *)(localbuf + localoffs);
98889 while (c)
98890 {
98891 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
98892 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
98893 if (copy_from_user(lbuf8,
98894 userbuf+useroffs + p,
98895 locallen))
98896 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
98897 index 7d8803a..559f8d0 100644
98898 --- a/sound/oss/swarm_cs4297a.c
98899 +++ b/sound/oss/swarm_cs4297a.c
98900 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
98901 {
98902 struct cs4297a_state *s;
98903 u32 pwr, id;
98904 - mm_segment_t fs;
98905 int rval;
98906 #ifndef CONFIG_BCM_CS4297A_CSWARM
98907 u64 cfg;
98908 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
98909 if (!rval) {
98910 char *sb1250_duart_present;
98911
98912 +#if 0
98913 + mm_segment_t fs;
98914 fs = get_fs();
98915 set_fs(KERNEL_DS);
98916 -#if 0
98917 val = SOUND_MASK_LINE;
98918 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
98919 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
98920 val = initvol[i].vol;
98921 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
98922 }
98923 + set_fs(fs);
98924 // cs4297a_write_ac97(s, 0x18, 0x0808);
98925 #else
98926 // cs4297a_write_ac97(s, 0x5e, 0x180);
98927 cs4297a_write_ac97(s, 0x02, 0x0808);
98928 cs4297a_write_ac97(s, 0x18, 0x0808);
98929 #endif
98930 - set_fs(fs);
98931
98932 list_add(&s->list, &cs4297a_devs);
98933
98934 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
98935 index 8a005f0..4fe3059 100644
98936 --- a/sound/pci/hda/hda_codec.c
98937 +++ b/sound/pci/hda/hda_codec.c
98938 @@ -918,14 +918,10 @@ find_codec_preset(struct hda_codec *codec)
98939 mutex_unlock(&preset_mutex);
98940
98941 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
98942 - char name[32];
98943 if (!mod_requested)
98944 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
98945 - codec->vendor_id);
98946 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
98947 else
98948 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
98949 - (codec->vendor_id >> 16) & 0xffff);
98950 - request_module(name);
98951 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
98952 mod_requested++;
98953 goto again;
98954 }
98955 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
98956 index 4631a23..001ae57 100644
98957 --- a/sound/pci/ymfpci/ymfpci.h
98958 +++ b/sound/pci/ymfpci/ymfpci.h
98959 @@ -358,7 +358,7 @@ struct snd_ymfpci {
98960 spinlock_t reg_lock;
98961 spinlock_t voice_lock;
98962 wait_queue_head_t interrupt_sleep;
98963 - atomic_t interrupt_sleep_count;
98964 + atomic_unchecked_t interrupt_sleep_count;
98965 struct snd_info_entry *proc_entry;
98966 const struct firmware *dsp_microcode;
98967 const struct firmware *controller_microcode;
98968 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
98969 index d591c15..8cb8f94 100644
98970 --- a/sound/pci/ymfpci/ymfpci_main.c
98971 +++ b/sound/pci/ymfpci/ymfpci_main.c
98972 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
98973 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
98974 break;
98975 }
98976 - if (atomic_read(&chip->interrupt_sleep_count)) {
98977 - atomic_set(&chip->interrupt_sleep_count, 0);
98978 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
98979 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
98980 wake_up(&chip->interrupt_sleep);
98981 }
98982 __end:
98983 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
98984 continue;
98985 init_waitqueue_entry(&wait, current);
98986 add_wait_queue(&chip->interrupt_sleep, &wait);
98987 - atomic_inc(&chip->interrupt_sleep_count);
98988 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
98989 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
98990 remove_wait_queue(&chip->interrupt_sleep, &wait);
98991 }
98992 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
98993 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
98994 spin_unlock(&chip->reg_lock);
98995
98996 - if (atomic_read(&chip->interrupt_sleep_count)) {
98997 - atomic_set(&chip->interrupt_sleep_count, 0);
98998 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
98999 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99000 wake_up(&chip->interrupt_sleep);
99001 }
99002 }
99003 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
99004 spin_lock_init(&chip->reg_lock);
99005 spin_lock_init(&chip->voice_lock);
99006 init_waitqueue_head(&chip->interrupt_sleep);
99007 - atomic_set(&chip->interrupt_sleep_count, 0);
99008 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99009 chip->card = card;
99010 chip->pci = pci;
99011 chip->irq = -1;
99012 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
99013 index 2f2d837..3e3f1f6 100644
99014 --- a/sound/soc/fsl/fsl_ssi.c
99015 +++ b/sound/soc/fsl/fsl_ssi.c
99016 @@ -656,7 +656,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
99017 {
99018 struct fsl_ssi_private *ssi_private;
99019 int ret = 0;
99020 - struct device_attribute *dev_attr = NULL;
99021 + device_attribute_no_const *dev_attr = NULL;
99022 struct device_node *np = pdev->dev.of_node;
99023 const char *p, *sprop;
99024 const uint32_t *iprop;
99025 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
99026 new file mode 100644
99027 index 0000000..50f2f2f
99028 --- /dev/null
99029 +++ b/tools/gcc/.gitignore
99030 @@ -0,0 +1 @@
99031 +size_overflow_hash.h
99032 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
99033 new file mode 100644
99034 index 0000000..144dbee
99035 --- /dev/null
99036 +++ b/tools/gcc/Makefile
99037 @@ -0,0 +1,45 @@
99038 +#CC := gcc
99039 +#PLUGIN_SOURCE_FILES := pax_plugin.c
99040 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
99041 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
99042 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
99043 +
99044 +ifeq ($(PLUGINCC),$(HOSTCC))
99045 +HOSTLIBS := hostlibs
99046 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
99047 +else
99048 +HOSTLIBS := hostcxxlibs
99049 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
99050 +endif
99051 +
99052 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
99053 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
99054 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
99055 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
99056 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
99057 +$(HOSTLIBS)-y += colorize_plugin.so
99058 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
99059 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
99060 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
99061 +
99062 +always := $($(HOSTLIBS)-y)
99063 +
99064 +constify_plugin-objs := constify_plugin.o
99065 +stackleak_plugin-objs := stackleak_plugin.o
99066 +kallocstat_plugin-objs := kallocstat_plugin.o
99067 +kernexec_plugin-objs := kernexec_plugin.o
99068 +checker_plugin-objs := checker_plugin.o
99069 +colorize_plugin-objs := colorize_plugin.o
99070 +size_overflow_plugin-objs := size_overflow_plugin.o
99071 +latent_entropy_plugin-objs := latent_entropy_plugin.o
99072 +structleak_plugin-objs := structleak_plugin.o
99073 +
99074 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
99075 +
99076 +quiet_cmd_build_size_overflow_hash = GENHASH $@
99077 + cmd_build_size_overflow_hash = \
99078 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
99079 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
99080 + $(call if_changed,build_size_overflow_hash)
99081 +
99082 +targets += size_overflow_hash.h
99083 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
99084 new file mode 100644
99085 index 0000000..22f03c0
99086 --- /dev/null
99087 +++ b/tools/gcc/checker_plugin.c
99088 @@ -0,0 +1,172 @@
99089 +/*
99090 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
99091 + * Licensed under the GPL v2
99092 + *
99093 + * Note: the choice of the license means that the compilation process is
99094 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99095 + * but for the kernel it doesn't matter since it doesn't link against
99096 + * any of the gcc libraries
99097 + *
99098 + * gcc plugin to implement various sparse (source code checker) features
99099 + *
99100 + * TODO:
99101 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
99102 + *
99103 + * BUGS:
99104 + * - none known
99105 + */
99106 +#include "gcc-plugin.h"
99107 +#include "config.h"
99108 +#include "system.h"
99109 +#include "coretypes.h"
99110 +#include "tree.h"
99111 +#include "tree-pass.h"
99112 +#include "flags.h"
99113 +#include "intl.h"
99114 +#include "toplev.h"
99115 +#include "plugin.h"
99116 +//#include "expr.h" where are you...
99117 +#include "diagnostic.h"
99118 +#include "plugin-version.h"
99119 +#include "tm.h"
99120 +#include "function.h"
99121 +#include "basic-block.h"
99122 +#include "gimple.h"
99123 +#include "rtl.h"
99124 +#include "emit-rtl.h"
99125 +#include "tree-flow.h"
99126 +#include "target.h"
99127 +
99128 +extern void c_register_addr_space (const char *str, addr_space_t as);
99129 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
99130 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
99131 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
99132 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
99133 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
99134 +
99135 +extern void print_gimple_stmt(FILE *, gimple, int, int);
99136 +extern rtx emit_move_insn(rtx x, rtx y);
99137 +
99138 +int plugin_is_GPL_compatible;
99139 +
99140 +static struct plugin_info checker_plugin_info = {
99141 + .version = "201111150100",
99142 + .help = NULL,
99143 +};
99144 +
99145 +#define ADDR_SPACE_KERNEL 0
99146 +#define ADDR_SPACE_FORCE_KERNEL 1
99147 +#define ADDR_SPACE_USER 2
99148 +#define ADDR_SPACE_FORCE_USER 3
99149 +#define ADDR_SPACE_IOMEM 0
99150 +#define ADDR_SPACE_FORCE_IOMEM 0
99151 +#define ADDR_SPACE_PERCPU 0
99152 +#define ADDR_SPACE_FORCE_PERCPU 0
99153 +#define ADDR_SPACE_RCU 0
99154 +#define ADDR_SPACE_FORCE_RCU 0
99155 +
99156 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
99157 +{
99158 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
99159 +}
99160 +
99161 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
99162 +{
99163 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
99164 +}
99165 +
99166 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
99167 +{
99168 + return default_addr_space_valid_pointer_mode(mode, as);
99169 +}
99170 +
99171 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
99172 +{
99173 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
99174 +}
99175 +
99176 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
99177 +{
99178 + return default_addr_space_legitimize_address(x, oldx, mode, as);
99179 +}
99180 +
99181 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
99182 +{
99183 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
99184 + return true;
99185 +
99186 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
99187 + return true;
99188 +
99189 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
99190 + return true;
99191 +
99192 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
99193 + return true;
99194 +
99195 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
99196 + return true;
99197 +
99198 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
99199 + return true;
99200 +
99201 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
99202 + return true;
99203 +
99204 + return subset == superset;
99205 +}
99206 +
99207 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
99208 +{
99209 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
99210 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
99211 +
99212 + return op;
99213 +}
99214 +
99215 +static void register_checker_address_spaces(void *event_data, void *data)
99216 +{
99217 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
99218 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
99219 + c_register_addr_space("__user", ADDR_SPACE_USER);
99220 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
99221 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
99222 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
99223 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
99224 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
99225 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
99226 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
99227 +
99228 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
99229 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
99230 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
99231 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
99232 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
99233 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
99234 + targetm.addr_space.convert = checker_addr_space_convert;
99235 +}
99236 +
99237 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99238 +{
99239 + const char * const plugin_name = plugin_info->base_name;
99240 + const int argc = plugin_info->argc;
99241 + const struct plugin_argument * const argv = plugin_info->argv;
99242 + int i;
99243 +
99244 + if (!plugin_default_version_check(version, &gcc_version)) {
99245 + error(G_("incompatible gcc/plugin versions"));
99246 + return 1;
99247 + }
99248 +
99249 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
99250 +
99251 + for (i = 0; i < argc; ++i)
99252 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
99253 +
99254 + if (TARGET_64BIT == 0)
99255 + return 0;
99256 +
99257 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
99258 +
99259 + return 0;
99260 +}
99261 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
99262 new file mode 100644
99263 index 0000000..414fe5e
99264 --- /dev/null
99265 +++ b/tools/gcc/colorize_plugin.c
99266 @@ -0,0 +1,151 @@
99267 +/*
99268 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
99269 + * Licensed under the GPL v2
99270 + *
99271 + * Note: the choice of the license means that the compilation process is
99272 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99273 + * but for the kernel it doesn't matter since it doesn't link against
99274 + * any of the gcc libraries
99275 + *
99276 + * gcc plugin to colorize diagnostic output
99277 + *
99278 + */
99279 +
99280 +#include "gcc-plugin.h"
99281 +#include "config.h"
99282 +#include "system.h"
99283 +#include "coretypes.h"
99284 +#include "tree.h"
99285 +#include "tree-pass.h"
99286 +#include "flags.h"
99287 +#include "intl.h"
99288 +#include "toplev.h"
99289 +#include "plugin.h"
99290 +#include "diagnostic.h"
99291 +#include "plugin-version.h"
99292 +#include "tm.h"
99293 +
99294 +int plugin_is_GPL_compatible;
99295 +
99296 +static struct plugin_info colorize_plugin_info = {
99297 + .version = "201302112000",
99298 + .help = NULL,
99299 +};
99300 +
99301 +#define GREEN "\033[32m\033[2m"
99302 +#define LIGHTGREEN "\033[32m\033[1m"
99303 +#define YELLOW "\033[33m\033[2m"
99304 +#define LIGHTYELLOW "\033[33m\033[1m"
99305 +#define RED "\033[31m\033[2m"
99306 +#define LIGHTRED "\033[31m\033[1m"
99307 +#define BLUE "\033[34m\033[2m"
99308 +#define LIGHTBLUE "\033[34m\033[1m"
99309 +#define BRIGHT "\033[m\033[1m"
99310 +#define NORMAL "\033[m"
99311 +
99312 +static diagnostic_starter_fn old_starter;
99313 +static diagnostic_finalizer_fn old_finalizer;
99314 +
99315 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
99316 +{
99317 + const char *color;
99318 + char *newprefix;
99319 +
99320 + switch (diagnostic->kind) {
99321 + case DK_NOTE:
99322 + color = LIGHTBLUE;
99323 + break;
99324 +
99325 + case DK_PEDWARN:
99326 + case DK_WARNING:
99327 + color = LIGHTYELLOW;
99328 + break;
99329 +
99330 + case DK_ERROR:
99331 + case DK_FATAL:
99332 + case DK_ICE:
99333 + case DK_PERMERROR:
99334 + case DK_SORRY:
99335 + color = LIGHTRED;
99336 + break;
99337 +
99338 + default:
99339 + color = NORMAL;
99340 + }
99341 +
99342 + old_starter(context, diagnostic);
99343 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
99344 + return;
99345 + pp_destroy_prefix(context->printer);
99346 + pp_set_prefix(context->printer, newprefix);
99347 +}
99348 +
99349 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
99350 +{
99351 + old_finalizer(context, diagnostic);
99352 +}
99353 +
99354 +static void colorize_arm(void)
99355 +{
99356 + old_starter = diagnostic_starter(global_dc);
99357 + old_finalizer = diagnostic_finalizer(global_dc);
99358 +
99359 + diagnostic_starter(global_dc) = start_colorize;
99360 + diagnostic_finalizer(global_dc) = finalize_colorize;
99361 +}
99362 +
99363 +static unsigned int execute_colorize_rearm(void)
99364 +{
99365 + if (diagnostic_starter(global_dc) == start_colorize)
99366 + return 0;
99367 +
99368 + colorize_arm();
99369 + return 0;
99370 +}
99371 +
99372 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
99373 + .pass = {
99374 + .type = SIMPLE_IPA_PASS,
99375 + .name = "colorize_rearm",
99376 +#if BUILDING_GCC_VERSION >= 4008
99377 + .optinfo_flags = OPTGROUP_NONE,
99378 +#endif
99379 + .gate = NULL,
99380 + .execute = execute_colorize_rearm,
99381 + .sub = NULL,
99382 + .next = NULL,
99383 + .static_pass_number = 0,
99384 + .tv_id = TV_NONE,
99385 + .properties_required = 0,
99386 + .properties_provided = 0,
99387 + .properties_destroyed = 0,
99388 + .todo_flags_start = 0,
99389 + .todo_flags_finish = 0
99390 + }
99391 +};
99392 +
99393 +static void colorize_start_unit(void *gcc_data, void *user_data)
99394 +{
99395 + colorize_arm();
99396 +}
99397 +
99398 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99399 +{
99400 + const char * const plugin_name = plugin_info->base_name;
99401 + struct register_pass_info colorize_rearm_pass_info = {
99402 + .pass = &pass_ipa_colorize_rearm.pass,
99403 + .reference_pass_name = "*free_lang_data",
99404 + .ref_pass_instance_number = 1,
99405 + .pos_op = PASS_POS_INSERT_AFTER
99406 + };
99407 +
99408 + if (!plugin_default_version_check(version, &gcc_version)) {
99409 + error(G_("incompatible gcc/plugin versions"));
99410 + return 1;
99411 + }
99412 +
99413 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
99414 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
99415 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
99416 + return 0;
99417 +}
99418 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
99419 new file mode 100644
99420 index 0000000..c17312d
99421 --- /dev/null
99422 +++ b/tools/gcc/constify_plugin.c
99423 @@ -0,0 +1,560 @@
99424 +/*
99425 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
99426 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
99427 + * Licensed under the GPL v2, or (at your option) v3
99428 + *
99429 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
99430 + *
99431 + * Homepage:
99432 + * http://www.grsecurity.net/~ephox/const_plugin/
99433 + *
99434 + * Usage:
99435 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
99436 + * $ gcc -fplugin=constify_plugin.so test.c -O2
99437 + */
99438 +
99439 +#include "gcc-plugin.h"
99440 +#include "config.h"
99441 +#include "system.h"
99442 +#include "coretypes.h"
99443 +#include "tree.h"
99444 +#include "tree-pass.h"
99445 +#include "flags.h"
99446 +#include "intl.h"
99447 +#include "toplev.h"
99448 +#include "plugin.h"
99449 +#include "diagnostic.h"
99450 +#include "plugin-version.h"
99451 +#include "tm.h"
99452 +#include "function.h"
99453 +#include "basic-block.h"
99454 +#include "gimple.h"
99455 +#include "rtl.h"
99456 +#include "emit-rtl.h"
99457 +#include "tree-flow.h"
99458 +#include "target.h"
99459 +#include "langhooks.h"
99460 +
99461 +// should come from c-tree.h if only it were installed for gcc 4.5...
99462 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
99463 +
99464 +// unused type flag in all versions 4.5-4.8
99465 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
99466 +
99467 +int plugin_is_GPL_compatible;
99468 +
99469 +static struct plugin_info const_plugin_info = {
99470 + .version = "201305231310",
99471 + .help = "no-constify\tturn off constification\n",
99472 +};
99473 +
99474 +typedef struct {
99475 + bool has_fptr_field;
99476 + bool has_writable_field;
99477 + bool has_do_const_field;
99478 + bool has_no_const_field;
99479 +} constify_info;
99480 +
99481 +static const_tree get_field_type(const_tree field)
99482 +{
99483 + return strip_array_types(TREE_TYPE(field));
99484 +}
99485 +
99486 +static bool is_fptr(const_tree field)
99487 +{
99488 + const_tree ptr = get_field_type(field);
99489 +
99490 + if (TREE_CODE(ptr) != POINTER_TYPE)
99491 + return false;
99492 +
99493 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
99494 +}
99495 +
99496 +/*
99497 + * determine whether the given structure type meets the requirements for automatic constification,
99498 + * including the constification attributes on nested structure types
99499 + */
99500 +static void constifiable(const_tree node, constify_info *cinfo)
99501 +{
99502 + const_tree field;
99503 +
99504 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
99505 +
99506 + // e.g., pointer to structure fields while still constructing the structure type
99507 + if (TYPE_FIELDS(node) == NULL_TREE)
99508 + return;
99509 +
99510 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
99511 + const_tree type = get_field_type(field);
99512 + enum tree_code code = TREE_CODE(type);
99513 +
99514 + if (node == type)
99515 + continue;
99516 +
99517 + if (is_fptr(field))
99518 + cinfo->has_fptr_field = true;
99519 + else if (!TREE_READONLY(field))
99520 + cinfo->has_writable_field = true;
99521 +
99522 + if (code == RECORD_TYPE || code == UNION_TYPE) {
99523 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
99524 + cinfo->has_do_const_field = true;
99525 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
99526 + cinfo->has_no_const_field = true;
99527 + else
99528 + constifiable(type, cinfo);
99529 + }
99530 + }
99531 +}
99532 +
99533 +static bool constified(const_tree node)
99534 +{
99535 + constify_info cinfo = {
99536 + .has_fptr_field = false,
99537 + .has_writable_field = false,
99538 + .has_do_const_field = false,
99539 + .has_no_const_field = false
99540 + };
99541 +
99542 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
99543 +
99544 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
99545 + gcc_assert(!TYPE_READONLY(node));
99546 + return false;
99547 + }
99548 +
99549 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
99550 + gcc_assert(TYPE_READONLY(node));
99551 + return true;
99552 + }
99553 +
99554 + constifiable(node, &cinfo);
99555 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
99556 + return false;
99557 +
99558 + return TYPE_READONLY(node);
99559 +}
99560 +
99561 +static void deconstify_tree(tree node);
99562 +
99563 +static void deconstify_type(tree type)
99564 +{
99565 + tree field;
99566 +
99567 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
99568 +
99569 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
99570 + const_tree fieldtype = get_field_type(field);
99571 +
99572 + // special case handling of simple ptr-to-same-array-type members
99573 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
99574 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
99575 +
99576 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
99577 + continue;
99578 + if (TREE_TYPE(TREE_TYPE(field)) == type)
99579 + continue;
99580 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
99581 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
99582 + TREE_TYPE(TREE_TYPE(field)) = type;
99583 + }
99584 + continue;
99585 + }
99586 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
99587 + continue;
99588 + if (!constified(fieldtype))
99589 + continue;
99590 +
99591 + deconstify_tree(field);
99592 + TREE_READONLY(field) = 0;
99593 + }
99594 + TYPE_READONLY(type) = 0;
99595 + C_TYPE_FIELDS_READONLY(type) = 0;
99596 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
99597 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
99598 +}
99599 +
99600 +static void deconstify_tree(tree node)
99601 +{
99602 + tree old_type, new_type, field;
99603 +
99604 + old_type = TREE_TYPE(node);
99605 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
99606 + node = TREE_TYPE(node) = copy_node(old_type);
99607 + old_type = TREE_TYPE(old_type);
99608 + }
99609 +
99610 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
99611 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
99612 +
99613 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
99614 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
99615 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
99616 + DECL_FIELD_CONTEXT(field) = new_type;
99617 +
99618 + deconstify_type(new_type);
99619 +
99620 + TREE_TYPE(node) = new_type;
99621 +}
99622 +
99623 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
99624 +{
99625 + tree type;
99626 + constify_info cinfo = {
99627 + .has_fptr_field = false,
99628 + .has_writable_field = false,
99629 + .has_do_const_field = false,
99630 + .has_no_const_field = false
99631 + };
99632 +
99633 + *no_add_attrs = true;
99634 + if (TREE_CODE(*node) == FUNCTION_DECL) {
99635 + error("%qE attribute does not apply to functions", name);
99636 + return NULL_TREE;
99637 + }
99638 +
99639 + if (TREE_CODE(*node) == PARM_DECL) {
99640 + error("%qE attribute does not apply to function parameters", name);
99641 + return NULL_TREE;
99642 + }
99643 +
99644 + if (TREE_CODE(*node) == VAR_DECL) {
99645 + error("%qE attribute does not apply to variables", name);
99646 + return NULL_TREE;
99647 + }
99648 +
99649 + if (TYPE_P(*node)) {
99650 + *no_add_attrs = false;
99651 + type = *node;
99652 + } else {
99653 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
99654 + type = TREE_TYPE(*node);
99655 + }
99656 +
99657 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
99658 + error("%qE attribute applies to struct and union types only", name);
99659 + return NULL_TREE;
99660 + }
99661 +
99662 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
99663 + error("%qE attribute is already applied to the type", name);
99664 + return NULL_TREE;
99665 + }
99666 +
99667 + if (TYPE_P(*node)) {
99668 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
99669 + error("%qE attribute is incompatible with 'do_const'", name);
99670 + return NULL_TREE;
99671 + }
99672 +
99673 + constifiable(type, &cinfo);
99674 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
99675 + deconstify_tree(*node);
99676 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
99677 + return NULL_TREE;
99678 + }
99679 +
99680 + error("%qE attribute used on type that is not constified", name);
99681 + return NULL_TREE;
99682 +}
99683 +
99684 +static void constify_type(tree type)
99685 +{
99686 + TYPE_READONLY(type) = 1;
99687 + C_TYPE_FIELDS_READONLY(type) = 1;
99688 + TYPE_CONSTIFY_VISITED(type) = 1;
99689 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
99690 +}
99691 +
99692 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
99693 +{
99694 + *no_add_attrs = true;
99695 + if (!TYPE_P(*node)) {
99696 + error("%qE attribute applies to types only", name);
99697 + return NULL_TREE;
99698 + }
99699 +
99700 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
99701 + error("%qE attribute applies to struct and union types only", name);
99702 + return NULL_TREE;
99703 + }
99704 +
99705 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
99706 + error("%qE attribute is already applied to the type", name);
99707 + return NULL_TREE;
99708 + }
99709 +
99710 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
99711 + error("%qE attribute is incompatible with 'no_const'", name);
99712 + return NULL_TREE;
99713 + }
99714 +
99715 + *no_add_attrs = false;
99716 + return NULL_TREE;
99717 +}
99718 +
99719 +static struct attribute_spec no_const_attr = {
99720 + .name = "no_const",
99721 + .min_length = 0,
99722 + .max_length = 0,
99723 + .decl_required = false,
99724 + .type_required = false,
99725 + .function_type_required = false,
99726 + .handler = handle_no_const_attribute,
99727 +#if BUILDING_GCC_VERSION >= 4007
99728 + .affects_type_identity = true
99729 +#endif
99730 +};
99731 +
99732 +static struct attribute_spec do_const_attr = {
99733 + .name = "do_const",
99734 + .min_length = 0,
99735 + .max_length = 0,
99736 + .decl_required = false,
99737 + .type_required = false,
99738 + .function_type_required = false,
99739 + .handler = handle_do_const_attribute,
99740 +#if BUILDING_GCC_VERSION >= 4007
99741 + .affects_type_identity = true
99742 +#endif
99743 +};
99744 +
99745 +static void register_attributes(void *event_data, void *data)
99746 +{
99747 + register_attribute(&no_const_attr);
99748 + register_attribute(&do_const_attr);
99749 +}
99750 +
99751 +static void finish_type(void *event_data, void *data)
99752 +{
99753 + tree type = (tree)event_data;
99754 + constify_info cinfo = {
99755 + .has_fptr_field = false,
99756 + .has_writable_field = false,
99757 + .has_do_const_field = false,
99758 + .has_no_const_field = false
99759 + };
99760 +
99761 + if (type == NULL_TREE || type == error_mark_node)
99762 + return;
99763 +
99764 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
99765 + return;
99766 +
99767 + constifiable(type, &cinfo);
99768 +
99769 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
99770 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
99771 + return;
99772 + if (cinfo.has_writable_field)
99773 + return;
99774 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
99775 + return;
99776 + }
99777 +
99778 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
99779 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
99780 + deconstify_type(type);
99781 + TYPE_CONSTIFY_VISITED(type) = 1;
99782 + } else
99783 + error("'no_const' attribute used on type that is not constified");
99784 + return;
99785 + }
99786 +
99787 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
99788 + constify_type(type);
99789 + return;
99790 + }
99791 +
99792 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
99793 + constify_type(type);
99794 + return;
99795 + }
99796 +
99797 + deconstify_type(type);
99798 + TYPE_CONSTIFY_VISITED(type) = 1;
99799 +}
99800 +
99801 +static void check_global_variables(void)
99802 +{
99803 + struct varpool_node *node;
99804 +
99805 +#if BUILDING_GCC_VERSION <= 4007
99806 + for (node = varpool_nodes; node; node = node->next) {
99807 + tree var = node->decl;
99808 +#else
99809 + FOR_EACH_VARIABLE(node) {
99810 + tree var = node->symbol.decl;
99811 +#endif
99812 + tree type = TREE_TYPE(var);
99813 +
99814 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
99815 + continue;
99816 +
99817 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
99818 + continue;
99819 +
99820 + if (!TYPE_CONSTIFY_VISITED(type))
99821 + continue;
99822 +
99823 + if (DECL_EXTERNAL(var))
99824 + continue;
99825 +
99826 + if (DECL_INITIAL(var))
99827 + continue;
99828 +
99829 + // this works around a gcc bug/feature where uninitialized globals
99830 + // are moved into the .bss section regardless of any constification
99831 + DECL_INITIAL(var) = build_constructor(type, NULL);
99832 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
99833 + }
99834 +}
99835 +
99836 +static unsigned int check_local_variables(void)
99837 +{
99838 + unsigned int ret = 0;
99839 + tree var;
99840 +
99841 +#if BUILDING_GCC_VERSION == 4005
99842 + tree vars;
99843 +#else
99844 + unsigned int i;
99845 +#endif
99846 +
99847 +#if BUILDING_GCC_VERSION == 4005
99848 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
99849 + var = TREE_VALUE(vars);
99850 +#else
99851 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
99852 +#endif
99853 + tree type = TREE_TYPE(var);
99854 +
99855 + gcc_assert(DECL_P(var));
99856 + if (is_global_var(var))
99857 + continue;
99858 +
99859 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
99860 + continue;
99861 +
99862 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
99863 + continue;
99864 +
99865 + if (!TYPE_CONSTIFY_VISITED(type))
99866 + continue;
99867 +
99868 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
99869 + ret = 1;
99870 + }
99871 + return ret;
99872 +}
99873 +
99874 +static unsigned int check_variables(void)
99875 +{
99876 + check_global_variables();
99877 + return check_local_variables();
99878 +}
99879 +
99880 + unsigned int ret = 0;
99881 +static struct gimple_opt_pass pass_local_variable = {
99882 + {
99883 + .type = GIMPLE_PASS,
99884 + .name = "check_variables",
99885 +#if BUILDING_GCC_VERSION >= 4008
99886 + .optinfo_flags = OPTGROUP_NONE,
99887 +#endif
99888 + .gate = NULL,
99889 + .execute = check_variables,
99890 + .sub = NULL,
99891 + .next = NULL,
99892 + .static_pass_number = 0,
99893 + .tv_id = TV_NONE,
99894 + .properties_required = 0,
99895 + .properties_provided = 0,
99896 + .properties_destroyed = 0,
99897 + .todo_flags_start = 0,
99898 + .todo_flags_finish = 0
99899 + }
99900 +};
99901 +
99902 +static struct {
99903 + const char *name;
99904 + const char *asm_op;
99905 +} sections[] = {
99906 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
99907 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
99908 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
99909 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
99910 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
99911 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
99912 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
99913 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
99914 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
99915 +};
99916 +
99917 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
99918 +
99919 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
99920 +{
99921 + size_t i;
99922 +
99923 + for (i = 0; i < ARRAY_SIZE(sections); i++)
99924 + if (!strcmp(sections[i].name, name))
99925 + return 0;
99926 + return old_section_type_flags(decl, name, reloc);
99927 +}
99928 +
99929 +static void constify_start_unit(void *gcc_data, void *user_data)
99930 +{
99931 +// size_t i;
99932 +
99933 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
99934 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
99935 +// sections[i].section = get_section(sections[i].name, 0, NULL);
99936 +
99937 + old_section_type_flags = targetm.section_type_flags;
99938 + targetm.section_type_flags = constify_section_type_flags;
99939 +}
99940 +
99941 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99942 +{
99943 + const char * const plugin_name = plugin_info->base_name;
99944 + const int argc = plugin_info->argc;
99945 + const struct plugin_argument * const argv = plugin_info->argv;
99946 + int i;
99947 + bool constify = true;
99948 +
99949 + struct register_pass_info local_variable_pass_info = {
99950 + .pass = &pass_local_variable.pass,
99951 + .reference_pass_name = "ssa",
99952 + .ref_pass_instance_number = 1,
99953 + .pos_op = PASS_POS_INSERT_BEFORE
99954 + };
99955 +
99956 + if (!plugin_default_version_check(version, &gcc_version)) {
99957 + error(G_("incompatible gcc/plugin versions"));
99958 + return 1;
99959 + }
99960 +
99961 + for (i = 0; i < argc; ++i) {
99962 + if (!(strcmp(argv[i].key, "no-constify"))) {
99963 + constify = false;
99964 + continue;
99965 + }
99966 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
99967 + }
99968 +
99969 + if (strcmp(lang_hooks.name, "GNU C")) {
99970 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
99971 + constify = false;
99972 + }
99973 +
99974 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
99975 + if (constify) {
99976 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
99977 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
99978 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
99979 + }
99980 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
99981 +
99982 + return 0;
99983 +}
99984 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
99985 new file mode 100644
99986 index 0000000..e518932
99987 --- /dev/null
99988 +++ b/tools/gcc/generate_size_overflow_hash.sh
99989 @@ -0,0 +1,94 @@
99990 +#!/bin/bash
99991 +
99992 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
99993 +
99994 +header1="size_overflow_hash.h"
99995 +database="size_overflow_hash.data"
99996 +n=65536
99997 +
99998 +usage() {
99999 +cat <<EOF
100000 +usage: $0 options
100001 +OPTIONS:
100002 + -h|--help help
100003 + -o header file
100004 + -d database file
100005 + -n hash array size
100006 +EOF
100007 + return 0
100008 +}
100009 +
100010 +while true
100011 +do
100012 + case "$1" in
100013 + -h|--help) usage && exit 0;;
100014 + -n) n=$2; shift 2;;
100015 + -o) header1="$2"; shift 2;;
100016 + -d) database="$2"; shift 2;;
100017 + --) shift 1; break ;;
100018 + *) break ;;
100019 + esac
100020 +done
100021 +
100022 +create_defines() {
100023 + for i in `seq 0 31`
100024 + do
100025 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
100026 + done
100027 + echo >> "$header1"
100028 +}
100029 +
100030 +create_structs() {
100031 + rm -f "$header1"
100032 +
100033 + create_defines
100034 +
100035 + cat "$database" | while read data
100036 + do
100037 + data_array=($data)
100038 + struct_hash_name="${data_array[0]}"
100039 + funcn="${data_array[1]}"
100040 + params="${data_array[2]}"
100041 + next="${data_array[4]}"
100042 +
100043 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
100044 +
100045 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
100046 + echo -en "\t.param\t= " >> "$header1"
100047 + line=
100048 + for param_num in ${params//-/ };
100049 + do
100050 + line="${line}PARAM"$param_num"|"
100051 + done
100052 +
100053 + echo -e "${line%?},\n};\n" >> "$header1"
100054 + done
100055 +}
100056 +
100057 +create_headers() {
100058 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
100059 +}
100060 +
100061 +create_array_elements() {
100062 + index=0
100063 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
100064 + do
100065 + data_array=($data)
100066 + i="${data_array[3]}"
100067 + hash="${data_array[0]}"
100068 + while [[ $index -lt $i ]]
100069 + do
100070 + echo -e "\t["$index"]\t= NULL," >> "$header1"
100071 + index=$(($index + 1))
100072 + done
100073 + index=$(($index + 1))
100074 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
100075 + done
100076 + echo '};' >> $header1
100077 +}
100078 +
100079 +create_structs
100080 +create_headers
100081 +create_array_elements
100082 +
100083 +exit 0
100084 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
100085 new file mode 100644
100086 index 0000000..568b360
100087 --- /dev/null
100088 +++ b/tools/gcc/kallocstat_plugin.c
100089 @@ -0,0 +1,170 @@
100090 +/*
100091 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100092 + * Licensed under the GPL v2
100093 + *
100094 + * Note: the choice of the license means that the compilation process is
100095 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100096 + * but for the kernel it doesn't matter since it doesn't link against
100097 + * any of the gcc libraries
100098 + *
100099 + * gcc plugin to find the distribution of k*alloc sizes
100100 + *
100101 + * TODO:
100102 + *
100103 + * BUGS:
100104 + * - none known
100105 + */
100106 +#include "gcc-plugin.h"
100107 +#include "config.h"
100108 +#include "system.h"
100109 +#include "coretypes.h"
100110 +#include "tree.h"
100111 +#include "tree-pass.h"
100112 +#include "flags.h"
100113 +#include "intl.h"
100114 +#include "toplev.h"
100115 +#include "plugin.h"
100116 +//#include "expr.h" where are you...
100117 +#include "diagnostic.h"
100118 +#include "plugin-version.h"
100119 +#include "tm.h"
100120 +#include "function.h"
100121 +#include "basic-block.h"
100122 +#include "gimple.h"
100123 +#include "rtl.h"
100124 +#include "emit-rtl.h"
100125 +
100126 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100127 +
100128 +int plugin_is_GPL_compatible;
100129 +
100130 +static const char * const kalloc_functions[] = {
100131 + "__kmalloc",
100132 + "kmalloc",
100133 + "kmalloc_large",
100134 + "kmalloc_node",
100135 + "kmalloc_order",
100136 + "kmalloc_order_trace",
100137 + "kmalloc_slab",
100138 + "kzalloc",
100139 + "kzalloc_node",
100140 +};
100141 +
100142 +static struct plugin_info kallocstat_plugin_info = {
100143 + .version = "201302112000",
100144 +};
100145 +
100146 +static unsigned int execute_kallocstat(void);
100147 +
100148 +static struct gimple_opt_pass kallocstat_pass = {
100149 + .pass = {
100150 + .type = GIMPLE_PASS,
100151 + .name = "kallocstat",
100152 +#if BUILDING_GCC_VERSION >= 4008
100153 + .optinfo_flags = OPTGROUP_NONE,
100154 +#endif
100155 + .gate = NULL,
100156 + .execute = execute_kallocstat,
100157 + .sub = NULL,
100158 + .next = NULL,
100159 + .static_pass_number = 0,
100160 + .tv_id = TV_NONE,
100161 + .properties_required = 0,
100162 + .properties_provided = 0,
100163 + .properties_destroyed = 0,
100164 + .todo_flags_start = 0,
100165 + .todo_flags_finish = 0
100166 + }
100167 +};
100168 +
100169 +static bool is_kalloc(const char *fnname)
100170 +{
100171 + size_t i;
100172 +
100173 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
100174 + if (!strcmp(fnname, kalloc_functions[i]))
100175 + return true;
100176 + return false;
100177 +}
100178 +
100179 +static unsigned int execute_kallocstat(void)
100180 +{
100181 + basic_block bb;
100182 +
100183 + // 1. loop through BBs and GIMPLE statements
100184 + FOR_EACH_BB(bb) {
100185 + gimple_stmt_iterator gsi;
100186 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100187 + // gimple match:
100188 + tree fndecl, size;
100189 + gimple call_stmt;
100190 + const char *fnname;
100191 +
100192 + // is it a call
100193 + call_stmt = gsi_stmt(gsi);
100194 + if (!is_gimple_call(call_stmt))
100195 + continue;
100196 + fndecl = gimple_call_fndecl(call_stmt);
100197 + if (fndecl == NULL_TREE)
100198 + continue;
100199 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
100200 + continue;
100201 +
100202 + // is it a call to k*alloc
100203 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
100204 + if (!is_kalloc(fnname))
100205 + continue;
100206 +
100207 + // is the size arg the result of a simple const assignment
100208 + size = gimple_call_arg(call_stmt, 0);
100209 + while (true) {
100210 + gimple def_stmt;
100211 + expanded_location xloc;
100212 + size_t size_val;
100213 +
100214 + if (TREE_CODE(size) != SSA_NAME)
100215 + break;
100216 + def_stmt = SSA_NAME_DEF_STMT(size);
100217 + if (!def_stmt || !is_gimple_assign(def_stmt))
100218 + break;
100219 + if (gimple_num_ops(def_stmt) != 2)
100220 + break;
100221 + size = gimple_assign_rhs1(def_stmt);
100222 + if (!TREE_CONSTANT(size))
100223 + continue;
100224 + xloc = expand_location(gimple_location(def_stmt));
100225 + if (!xloc.file)
100226 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
100227 + size_val = TREE_INT_CST_LOW(size);
100228 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
100229 + break;
100230 + }
100231 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
100232 +//debug_tree(gimple_call_fn(call_stmt));
100233 +//print_node(stderr, "pax", fndecl, 4);
100234 + }
100235 + }
100236 +
100237 + return 0;
100238 +}
100239 +
100240 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100241 +{
100242 + const char * const plugin_name = plugin_info->base_name;
100243 + struct register_pass_info kallocstat_pass_info = {
100244 + .pass = &kallocstat_pass.pass,
100245 + .reference_pass_name = "ssa",
100246 + .ref_pass_instance_number = 1,
100247 + .pos_op = PASS_POS_INSERT_AFTER
100248 + };
100249 +
100250 + if (!plugin_default_version_check(version, &gcc_version)) {
100251 + error(G_("incompatible gcc/plugin versions"));
100252 + return 1;
100253 + }
100254 +
100255 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
100256 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
100257 +
100258 + return 0;
100259 +}
100260 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
100261 new file mode 100644
100262 index 0000000..698da67
100263 --- /dev/null
100264 +++ b/tools/gcc/kernexec_plugin.c
100265 @@ -0,0 +1,471 @@
100266 +/*
100267 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100268 + * Licensed under the GPL v2
100269 + *
100270 + * Note: the choice of the license means that the compilation process is
100271 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100272 + * but for the kernel it doesn't matter since it doesn't link against
100273 + * any of the gcc libraries
100274 + *
100275 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
100276 + *
100277 + * TODO:
100278 + *
100279 + * BUGS:
100280 + * - none known
100281 + */
100282 +#include "gcc-plugin.h"
100283 +#include "config.h"
100284 +#include "system.h"
100285 +#include "coretypes.h"
100286 +#include "tree.h"
100287 +#include "tree-pass.h"
100288 +#include "flags.h"
100289 +#include "intl.h"
100290 +#include "toplev.h"
100291 +#include "plugin.h"
100292 +//#include "expr.h" where are you...
100293 +#include "diagnostic.h"
100294 +#include "plugin-version.h"
100295 +#include "tm.h"
100296 +#include "function.h"
100297 +#include "basic-block.h"
100298 +#include "gimple.h"
100299 +#include "rtl.h"
100300 +#include "emit-rtl.h"
100301 +#include "tree-flow.h"
100302 +
100303 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100304 +extern rtx emit_move_insn(rtx x, rtx y);
100305 +
100306 +#if BUILDING_GCC_VERSION <= 4006
100307 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
100308 +#endif
100309 +
100310 +#if BUILDING_GCC_VERSION >= 4008
100311 +#define TODO_dump_func 0
100312 +#endif
100313 +
100314 +int plugin_is_GPL_compatible;
100315 +
100316 +static struct plugin_info kernexec_plugin_info = {
100317 + .version = "201308230150",
100318 + .help = "method=[bts|or]\tinstrumentation method\n"
100319 +};
100320 +
100321 +static unsigned int execute_kernexec_reload(void);
100322 +static unsigned int execute_kernexec_fptr(void);
100323 +static unsigned int execute_kernexec_retaddr(void);
100324 +static bool kernexec_cmodel_check(void);
100325 +
100326 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
100327 +static void (*kernexec_instrument_retaddr)(rtx);
100328 +
100329 +static struct gimple_opt_pass kernexec_reload_pass = {
100330 + .pass = {
100331 + .type = GIMPLE_PASS,
100332 + .name = "kernexec_reload",
100333 +#if BUILDING_GCC_VERSION >= 4008
100334 + .optinfo_flags = OPTGROUP_NONE,
100335 +#endif
100336 + .gate = kernexec_cmodel_check,
100337 + .execute = execute_kernexec_reload,
100338 + .sub = NULL,
100339 + .next = NULL,
100340 + .static_pass_number = 0,
100341 + .tv_id = TV_NONE,
100342 + .properties_required = 0,
100343 + .properties_provided = 0,
100344 + .properties_destroyed = 0,
100345 + .todo_flags_start = 0,
100346 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
100347 + }
100348 +};
100349 +
100350 +static struct gimple_opt_pass kernexec_fptr_pass = {
100351 + .pass = {
100352 + .type = GIMPLE_PASS,
100353 + .name = "kernexec_fptr",
100354 +#if BUILDING_GCC_VERSION >= 4008
100355 + .optinfo_flags = OPTGROUP_NONE,
100356 +#endif
100357 + .gate = kernexec_cmodel_check,
100358 + .execute = execute_kernexec_fptr,
100359 + .sub = NULL,
100360 + .next = NULL,
100361 + .static_pass_number = 0,
100362 + .tv_id = TV_NONE,
100363 + .properties_required = 0,
100364 + .properties_provided = 0,
100365 + .properties_destroyed = 0,
100366 + .todo_flags_start = 0,
100367 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
100368 + }
100369 +};
100370 +
100371 +static struct rtl_opt_pass kernexec_retaddr_pass = {
100372 + .pass = {
100373 + .type = RTL_PASS,
100374 + .name = "kernexec_retaddr",
100375 +#if BUILDING_GCC_VERSION >= 4008
100376 + .optinfo_flags = OPTGROUP_NONE,
100377 +#endif
100378 + .gate = kernexec_cmodel_check,
100379 + .execute = execute_kernexec_retaddr,
100380 + .sub = NULL,
100381 + .next = NULL,
100382 + .static_pass_number = 0,
100383 + .tv_id = TV_NONE,
100384 + .properties_required = 0,
100385 + .properties_provided = 0,
100386 + .properties_destroyed = 0,
100387 + .todo_flags_start = 0,
100388 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
100389 + }
100390 +};
100391 +
100392 +static bool kernexec_cmodel_check(void)
100393 +{
100394 + tree section;
100395 +
100396 + if (ix86_cmodel != CM_KERNEL)
100397 + return false;
100398 +
100399 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
100400 + if (!section || !TREE_VALUE(section))
100401 + return true;
100402 +
100403 + section = TREE_VALUE(TREE_VALUE(section));
100404 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
100405 + return true;
100406 +
100407 + return false;
100408 +}
100409 +
100410 +/*
100411 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
100412 + */
100413 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
100414 +{
100415 + gimple asm_movabs_stmt;
100416 +
100417 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
100418 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
100419 + gimple_asm_set_volatile(asm_movabs_stmt, true);
100420 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
100421 + update_stmt(asm_movabs_stmt);
100422 +}
100423 +
100424 +/*
100425 + * find all asm() stmts that clobber r10 and add a reload of r10
100426 + */
100427 +static unsigned int execute_kernexec_reload(void)
100428 +{
100429 + basic_block bb;
100430 +
100431 + // 1. loop through BBs and GIMPLE statements
100432 + FOR_EACH_BB(bb) {
100433 + gimple_stmt_iterator gsi;
100434 +
100435 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100436 + // gimple match: __asm__ ("" : : : "r10");
100437 + gimple asm_stmt;
100438 + size_t nclobbers;
100439 +
100440 + // is it an asm ...
100441 + asm_stmt = gsi_stmt(gsi);
100442 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
100443 + continue;
100444 +
100445 + // ... clobbering r10
100446 + nclobbers = gimple_asm_nclobbers(asm_stmt);
100447 + while (nclobbers--) {
100448 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
100449 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
100450 + continue;
100451 + kernexec_reload_fptr_mask(&gsi);
100452 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
100453 + break;
100454 + }
100455 + }
100456 + }
100457 +
100458 + return 0;
100459 +}
100460 +
100461 +/*
100462 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
100463 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
100464 + */
100465 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
100466 +{
100467 + gimple assign_intptr, assign_new_fptr, call_stmt;
100468 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
100469 +
100470 + call_stmt = gsi_stmt(*gsi);
100471 + old_fptr = gimple_call_fn(call_stmt);
100472 +
100473 + // create temporary unsigned long variable used for bitops and cast fptr to it
100474 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
100475 +#if BUILDING_GCC_VERSION <= 4007
100476 + add_referenced_var(intptr);
100477 +#endif
100478 + intptr = make_ssa_name(intptr, NULL);
100479 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
100480 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
100481 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
100482 + update_stmt(assign_intptr);
100483 +
100484 + // apply logical or to temporary unsigned long and bitmask
100485 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
100486 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
100487 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
100488 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
100489 + assign_intptr = gimple_build_assign(intptr, orptr);
100490 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
100491 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
100492 + update_stmt(assign_intptr);
100493 +
100494 + // cast temporary unsigned long back to a temporary fptr variable
100495 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
100496 +#if BUILDING_GCC_VERSION <= 4007
100497 + add_referenced_var(new_fptr);
100498 +#endif
100499 + new_fptr = make_ssa_name(new_fptr, NULL);
100500 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
100501 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
100502 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
100503 + update_stmt(assign_new_fptr);
100504 +
100505 + // replace call stmt fn with the new fptr
100506 + gimple_call_set_fn(call_stmt, new_fptr);
100507 + update_stmt(call_stmt);
100508 +}
100509 +
100510 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
100511 +{
100512 + gimple asm_or_stmt, call_stmt;
100513 + tree old_fptr, new_fptr, input, output;
100514 +#if BUILDING_GCC_VERSION <= 4007
100515 + VEC(tree, gc) *inputs = NULL;
100516 + VEC(tree, gc) *outputs = NULL;
100517 +#else
100518 + vec<tree, va_gc> *inputs = NULL;
100519 + vec<tree, va_gc> *outputs = NULL;
100520 +#endif
100521 +
100522 + call_stmt = gsi_stmt(*gsi);
100523 + old_fptr = gimple_call_fn(call_stmt);
100524 +
100525 + // create temporary fptr variable
100526 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
100527 +#if BUILDING_GCC_VERSION <= 4007
100528 + add_referenced_var(new_fptr);
100529 +#endif
100530 + new_fptr = make_ssa_name(new_fptr, NULL);
100531 +
100532 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
100533 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
100534 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
100535 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
100536 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
100537 +#if BUILDING_GCC_VERSION <= 4007
100538 + VEC_safe_push(tree, gc, inputs, input);
100539 + VEC_safe_push(tree, gc, outputs, output);
100540 +#else
100541 + vec_safe_push(inputs, input);
100542 + vec_safe_push(outputs, output);
100543 +#endif
100544 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
100545 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
100546 + gimple_asm_set_volatile(asm_or_stmt, true);
100547 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
100548 + update_stmt(asm_or_stmt);
100549 +
100550 + // replace call stmt fn with the new fptr
100551 + gimple_call_set_fn(call_stmt, new_fptr);
100552 + update_stmt(call_stmt);
100553 +}
100554 +
100555 +/*
100556 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
100557 + */
100558 +static unsigned int execute_kernexec_fptr(void)
100559 +{
100560 + basic_block bb;
100561 +
100562 + // 1. loop through BBs and GIMPLE statements
100563 + FOR_EACH_BB(bb) {
100564 + gimple_stmt_iterator gsi;
100565 +
100566 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
100567 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
100568 + tree fn;
100569 + gimple call_stmt;
100570 +
100571 + // is it a call ...
100572 + call_stmt = gsi_stmt(gsi);
100573 + if (!is_gimple_call(call_stmt))
100574 + continue;
100575 + fn = gimple_call_fn(call_stmt);
100576 + if (TREE_CODE(fn) == ADDR_EXPR)
100577 + continue;
100578 + if (TREE_CODE(fn) != SSA_NAME)
100579 + gcc_unreachable();
100580 +
100581 + // ... through a function pointer
100582 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
100583 + fn = SSA_NAME_VAR(fn);
100584 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
100585 + debug_tree(fn);
100586 + gcc_unreachable();
100587 + }
100588 + }
100589 + fn = TREE_TYPE(fn);
100590 + if (TREE_CODE(fn) != POINTER_TYPE)
100591 + continue;
100592 + fn = TREE_TYPE(fn);
100593 + if (TREE_CODE(fn) != FUNCTION_TYPE)
100594 + continue;
100595 +
100596 + kernexec_instrument_fptr(&gsi);
100597 +
100598 +//debug_tree(gimple_call_fn(call_stmt));
100599 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
100600 + }
100601 + }
100602 +
100603 + return 0;
100604 +}
100605 +
100606 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
100607 +static void kernexec_instrument_retaddr_bts(rtx insn)
100608 +{
100609 + rtx btsq;
100610 + rtvec argvec, constraintvec, labelvec;
100611 + int line;
100612 +
100613 + // create asm volatile("btsq $63,(%%rsp)":::)
100614 + argvec = rtvec_alloc(0);
100615 + constraintvec = rtvec_alloc(0);
100616 + labelvec = rtvec_alloc(0);
100617 + line = expand_location(RTL_LOCATION(insn)).line;
100618 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
100619 + MEM_VOLATILE_P(btsq) = 1;
100620 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
100621 + emit_insn_before(btsq, insn);
100622 +}
100623 +
100624 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
100625 +static void kernexec_instrument_retaddr_or(rtx insn)
100626 +{
100627 + rtx orq;
100628 + rtvec argvec, constraintvec, labelvec;
100629 + int line;
100630 +
100631 + // create asm volatile("orq %%r10,(%%rsp)":::)
100632 + argvec = rtvec_alloc(0);
100633 + constraintvec = rtvec_alloc(0);
100634 + labelvec = rtvec_alloc(0);
100635 + line = expand_location(RTL_LOCATION(insn)).line;
100636 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
100637 + MEM_VOLATILE_P(orq) = 1;
100638 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
100639 + emit_insn_before(orq, insn);
100640 +}
100641 +
100642 +/*
100643 + * find all asm level function returns and forcibly set the highest bit of the return address
100644 + */
100645 +static unsigned int execute_kernexec_retaddr(void)
100646 +{
100647 + rtx insn;
100648 +
100649 + // 1. find function returns
100650 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
100651 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
100652 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
100653 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
100654 + rtx body;
100655 +
100656 + // is it a retn
100657 + if (!JUMP_P(insn))
100658 + continue;
100659 + body = PATTERN(insn);
100660 + if (GET_CODE(body) == PARALLEL)
100661 + body = XVECEXP(body, 0, 0);
100662 + if (!ANY_RETURN_P(body))
100663 + continue;
100664 + kernexec_instrument_retaddr(insn);
100665 + }
100666 +
100667 +// print_simple_rtl(stderr, get_insns());
100668 +// print_rtl(stderr, get_insns());
100669 +
100670 + return 0;
100671 +}
100672 +
100673 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100674 +{
100675 + const char * const plugin_name = plugin_info->base_name;
100676 + const int argc = plugin_info->argc;
100677 + const struct plugin_argument * const argv = plugin_info->argv;
100678 + int i;
100679 + struct register_pass_info kernexec_reload_pass_info = {
100680 + .pass = &kernexec_reload_pass.pass,
100681 + .reference_pass_name = "ssa",
100682 + .ref_pass_instance_number = 1,
100683 + .pos_op = PASS_POS_INSERT_AFTER
100684 + };
100685 + struct register_pass_info kernexec_fptr_pass_info = {
100686 + .pass = &kernexec_fptr_pass.pass,
100687 + .reference_pass_name = "ssa",
100688 + .ref_pass_instance_number = 1,
100689 + .pos_op = PASS_POS_INSERT_AFTER
100690 + };
100691 + struct register_pass_info kernexec_retaddr_pass_info = {
100692 + .pass = &kernexec_retaddr_pass.pass,
100693 + .reference_pass_name = "pro_and_epilogue",
100694 + .ref_pass_instance_number = 1,
100695 + .pos_op = PASS_POS_INSERT_AFTER
100696 + };
100697 +
100698 + if (!plugin_default_version_check(version, &gcc_version)) {
100699 + error(G_("incompatible gcc/plugin versions"));
100700 + return 1;
100701 + }
100702 +
100703 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
100704 +
100705 + if (TARGET_64BIT == 0)
100706 + return 0;
100707 +
100708 + for (i = 0; i < argc; ++i) {
100709 + if (!strcmp(argv[i].key, "method")) {
100710 + if (!argv[i].value) {
100711 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100712 + continue;
100713 + }
100714 + if (!strcmp(argv[i].value, "bts")) {
100715 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
100716 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
100717 + } else if (!strcmp(argv[i].value, "or")) {
100718 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
100719 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
100720 + fix_register("r10", 1, 1);
100721 + } else
100722 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
100723 + continue;
100724 + }
100725 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100726 + }
100727 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
100728 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
100729 +
100730 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
100731 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
100732 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
100733 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
100734 +
100735 + return 0;
100736 +}
100737 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
100738 new file mode 100644
100739 index 0000000..cd6c242
100740 --- /dev/null
100741 +++ b/tools/gcc/latent_entropy_plugin.c
100742 @@ -0,0 +1,321 @@
100743 +/*
100744 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
100745 + * Licensed under the GPL v2
100746 + *
100747 + * Note: the choice of the license means that the compilation process is
100748 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100749 + * but for the kernel it doesn't matter since it doesn't link against
100750 + * any of the gcc libraries
100751 + *
100752 + * gcc plugin to help generate a little bit of entropy from program state,
100753 + * used during boot in the kernel
100754 + *
100755 + * TODO:
100756 + * - add ipa pass to identify not explicitly marked candidate functions
100757 + * - mix in more program state (function arguments/return values, loop variables, etc)
100758 + * - more instrumentation control via attribute parameters
100759 + *
100760 + * BUGS:
100761 + * - LTO needs -flto-partition=none for now
100762 + */
100763 +#include "gcc-plugin.h"
100764 +#include "config.h"
100765 +#include "system.h"
100766 +#include "coretypes.h"
100767 +#include "tree.h"
100768 +#include "tree-pass.h"
100769 +#include "flags.h"
100770 +#include "intl.h"
100771 +#include "toplev.h"
100772 +#include "plugin.h"
100773 +//#include "expr.h" where are you...
100774 +#include "diagnostic.h"
100775 +#include "plugin-version.h"
100776 +#include "tm.h"
100777 +#include "function.h"
100778 +#include "basic-block.h"
100779 +#include "gimple.h"
100780 +#include "rtl.h"
100781 +#include "emit-rtl.h"
100782 +#include "tree-flow.h"
100783 +#include "langhooks.h"
100784 +
100785 +#if BUILDING_GCC_VERSION >= 4008
100786 +#define TODO_dump_func 0
100787 +#endif
100788 +
100789 +int plugin_is_GPL_compatible;
100790 +
100791 +static tree latent_entropy_decl;
100792 +
100793 +static struct plugin_info latent_entropy_plugin_info = {
100794 + .version = "201308230230",
100795 + .help = NULL
100796 +};
100797 +
100798 +static unsigned int execute_latent_entropy(void);
100799 +static bool gate_latent_entropy(void);
100800 +
100801 +static struct gimple_opt_pass latent_entropy_pass = {
100802 + .pass = {
100803 + .type = GIMPLE_PASS,
100804 + .name = "latent_entropy",
100805 +#if BUILDING_GCC_VERSION >= 4008
100806 + .optinfo_flags = OPTGROUP_NONE,
100807 +#endif
100808 + .gate = gate_latent_entropy,
100809 + .execute = execute_latent_entropy,
100810 + .sub = NULL,
100811 + .next = NULL,
100812 + .static_pass_number = 0,
100813 + .tv_id = TV_NONE,
100814 + .properties_required = PROP_gimple_leh | PROP_cfg,
100815 + .properties_provided = 0,
100816 + .properties_destroyed = 0,
100817 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
100818 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
100819 + }
100820 +};
100821 +
100822 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100823 +{
100824 + if (TREE_CODE(*node) != FUNCTION_DECL) {
100825 + *no_add_attrs = true;
100826 + error("%qE attribute only applies to functions", name);
100827 + }
100828 + return NULL_TREE;
100829 +}
100830 +
100831 +static struct attribute_spec latent_entropy_attr = {
100832 + .name = "latent_entropy",
100833 + .min_length = 0,
100834 + .max_length = 0,
100835 + .decl_required = true,
100836 + .type_required = false,
100837 + .function_type_required = false,
100838 + .handler = handle_latent_entropy_attribute,
100839 +#if BUILDING_GCC_VERSION >= 4007
100840 + .affects_type_identity = false
100841 +#endif
100842 +};
100843 +
100844 +static void register_attributes(void *event_data, void *data)
100845 +{
100846 + register_attribute(&latent_entropy_attr);
100847 +}
100848 +
100849 +static bool gate_latent_entropy(void)
100850 +{
100851 + tree latent_entropy_attr;
100852 +
100853 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
100854 + return latent_entropy_attr != NULL_TREE;
100855 +}
100856 +
100857 +static unsigned HOST_WIDE_INT seed;
100858 +static unsigned HOST_WIDE_INT get_random_const(void)
100859 +{
100860 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
100861 + return seed;
100862 +}
100863 +
100864 +static enum tree_code get_op(tree *rhs)
100865 +{
100866 + static enum tree_code op;
100867 + unsigned HOST_WIDE_INT random_const;
100868 +
100869 + random_const = get_random_const();
100870 +
100871 + switch (op) {
100872 + case BIT_XOR_EXPR:
100873 + op = PLUS_EXPR;
100874 + break;
100875 +
100876 + case PLUS_EXPR:
100877 + if (rhs) {
100878 + op = LROTATE_EXPR;
100879 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
100880 + break;
100881 + }
100882 +
100883 + case LROTATE_EXPR:
100884 + default:
100885 + op = BIT_XOR_EXPR;
100886 + break;
100887 + }
100888 + if (rhs)
100889 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
100890 + return op;
100891 +}
100892 +
100893 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
100894 +{
100895 + gimple_stmt_iterator gsi;
100896 + gimple assign;
100897 + tree addxorrol, rhs;
100898 + enum tree_code op;
100899 +
100900 + op = get_op(&rhs);
100901 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
100902 + assign = gimple_build_assign(local_entropy, addxorrol);
100903 + gsi = gsi_after_labels(bb);
100904 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
100905 + update_stmt(assign);
100906 +//debug_bb(bb);
100907 +}
100908 +
100909 +static void perturb_latent_entropy(basic_block bb, tree rhs)
100910 +{
100911 + gimple_stmt_iterator gsi;
100912 + gimple assign;
100913 + tree addxorrol, temp;
100914 +
100915 + // 1. create temporary copy of latent_entropy
100916 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
100917 +#if BUILDING_GCC_VERSION <= 4007
100918 + add_referenced_var(temp);
100919 +#endif
100920 +
100921 + // 2. read...
100922 + temp = make_ssa_name(temp, NULL);
100923 + assign = gimple_build_assign(temp, latent_entropy_decl);
100924 + SSA_NAME_DEF_STMT(temp) = assign;
100925 +#if BUILDING_GCC_VERSION <= 4007
100926 + add_referenced_var(latent_entropy_decl);
100927 +#endif
100928 + gsi = gsi_after_labels(bb);
100929 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
100930 + update_stmt(assign);
100931 +
100932 + // 3. ...modify...
100933 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
100934 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
100935 + assign = gimple_build_assign(temp, addxorrol);
100936 + SSA_NAME_DEF_STMT(temp) = assign;
100937 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
100938 + update_stmt(assign);
100939 +
100940 + // 4. ...write latent_entropy
100941 + assign = gimple_build_assign(latent_entropy_decl, temp);
100942 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
100943 + update_stmt(assign);
100944 +}
100945 +
100946 +static unsigned int execute_latent_entropy(void)
100947 +{
100948 + basic_block bb;
100949 + gimple assign;
100950 + gimple_stmt_iterator gsi;
100951 + tree local_entropy;
100952 +
100953 + if (!latent_entropy_decl) {
100954 + struct varpool_node *node;
100955 +
100956 +#if BUILDING_GCC_VERSION <= 4007
100957 + for (node = varpool_nodes; node; node = node->next) {
100958 + tree var = node->decl;
100959 +#else
100960 + FOR_EACH_VARIABLE(node) {
100961 + tree var = node->symbol.decl;
100962 +#endif
100963 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
100964 + continue;
100965 + latent_entropy_decl = var;
100966 +// debug_tree(var);
100967 + break;
100968 + }
100969 + if (!latent_entropy_decl) {
100970 +// debug_tree(current_function_decl);
100971 + return 0;
100972 + }
100973 + }
100974 +
100975 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
100976 +
100977 + // 1. create local entropy variable
100978 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
100979 +#if BUILDING_GCC_VERSION <= 4007
100980 + add_referenced_var(local_entropy);
100981 + mark_sym_for_renaming(local_entropy);
100982 +#endif
100983 +
100984 + // 2. initialize local entropy variable
100985 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
100986 + if (dom_info_available_p(CDI_DOMINATORS))
100987 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
100988 + gsi = gsi_start_bb(bb);
100989 +
100990 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
100991 +// gimple_set_location(assign, loc);
100992 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
100993 + update_stmt(assign);
100994 +//debug_bb(bb);
100995 + bb = bb->next_bb;
100996 +
100997 + // 3. instrument each BB with an operation on the local entropy variable
100998 + while (bb != EXIT_BLOCK_PTR) {
100999 + perturb_local_entropy(bb, local_entropy);
101000 +//debug_bb(bb);
101001 + bb = bb->next_bb;
101002 + };
101003 +
101004 + // 4. mix local entropy into the global entropy variable
101005 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
101006 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
101007 + return 0;
101008 +}
101009 +
101010 +static void start_unit_callback(void *gcc_data, void *user_data)
101011 +{
101012 + tree latent_entropy_type;
101013 +
101014 +#if BUILDING_GCC_VERSION >= 4007
101015 + seed = get_random_seed(false);
101016 +#else
101017 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
101018 + seed *= seed;
101019 +#endif
101020 +
101021 + if (in_lto_p)
101022 + return;
101023 +
101024 + // extern volatile u64 latent_entropy
101025 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
101026 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
101027 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
101028 +
101029 + TREE_STATIC(latent_entropy_decl) = 1;
101030 + TREE_PUBLIC(latent_entropy_decl) = 1;
101031 + TREE_USED(latent_entropy_decl) = 1;
101032 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
101033 + DECL_EXTERNAL(latent_entropy_decl) = 1;
101034 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
101035 + DECL_INITIAL(latent_entropy_decl) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
101036 + lang_hooks.decls.pushdecl(latent_entropy_decl);
101037 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
101038 +// varpool_finalize_decl(latent_entropy_decl);
101039 +// varpool_mark_needed_node(latent_entropy_decl);
101040 +}
101041 +
101042 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101043 +{
101044 + const char * const plugin_name = plugin_info->base_name;
101045 + struct register_pass_info latent_entropy_pass_info = {
101046 + .pass = &latent_entropy_pass.pass,
101047 + .reference_pass_name = "optimized",
101048 + .ref_pass_instance_number = 1,
101049 + .pos_op = PASS_POS_INSERT_BEFORE
101050 + };
101051 +
101052 + if (!plugin_default_version_check(version, &gcc_version)) {
101053 + error(G_("incompatible gcc/plugin versions"));
101054 + return 1;
101055 + }
101056 +
101057 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
101058 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
101059 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
101060 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101061 +
101062 + return 0;
101063 +}
101064 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
101065 new file mode 100644
101066 index 0000000..b04803b
101067 --- /dev/null
101068 +++ b/tools/gcc/size_overflow_hash.data
101069 @@ -0,0 +1,6350 @@
101070 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
101071 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
101072 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
101073 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
101074 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
101075 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
101076 +padzero_55 padzero 1 55 &sel_read_policyvers_55
101077 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
101078 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
101079 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
101080 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
101081 +load_msg_95 load_msg 2 95 NULL
101082 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
101083 +init_q_132 init_q 4 132 NULL
101084 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
101085 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
101086 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
101087 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
101088 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
101089 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
101090 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
101091 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
101092 +br_port_info_size_268 br_port_info_size 0 268 NULL
101093 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
101094 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
101095 +SYSC_connect_304 SYSC_connect 3 304 NULL
101096 +syslog_print_307 syslog_print 2 307 NULL
101097 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
101098 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
101099 +next_node_allowed_318 next_node_allowed 1 318 NULL
101100 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
101101 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
101102 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
101103 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
101104 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
101105 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
101106 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
101107 +pidlist_resize_496 pidlist_resize 2 496 NULL
101108 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
101109 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
101110 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
101111 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
101112 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
101113 +dle_count_543 dle_count 0 543 NULL
101114 +devres_alloc_551 devres_alloc 2 551 NULL
101115 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
101116 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
101117 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
101118 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
101119 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
101120 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
101121 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
101122 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
101123 +isp1760_register_628 isp1760_register 1-2 628 NULL
101124 +clone_split_bio_633 clone_split_bio 6 633 NULL
101125 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
101126 +remap_to_cache_640 remap_to_cache 3 640 NULL
101127 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
101128 +unlink_queued_645 unlink_queued 3-4 645 NULL
101129 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
101130 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
101131 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
101132 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
101133 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
101134 +disk_max_parts_719 disk_max_parts 0 719 NULL
101135 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
101136 +dvb_video_write_754 dvb_video_write 3 754 NULL
101137 +if_writecmd_815 if_writecmd 2 815 NULL
101138 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
101139 +read_fifo_826 read_fifo 3 826 NULL
101140 +um_idi_read_850 um_idi_read 3 850 NULL
101141 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
101142 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
101143 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
101144 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
101145 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
101146 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
101147 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
101148 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
101149 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
101150 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
101151 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
101152 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
101153 +_do_truncate_1019 _do_truncate 2 1019 NULL
101154 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
101155 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
101156 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
101157 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
101158 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
101159 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
101160 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
101161 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
101162 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
101163 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
101164 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
101165 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
101166 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
101167 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
101168 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
101169 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
101170 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
101171 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
101172 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
101173 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
101174 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
101175 +nested_get_page_1252 nested_get_page 2 1252 NULL
101176 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
101177 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
101178 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
101179 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
101180 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
101181 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
101182 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
101183 +ffs_1322 ffs 0 1322 NULL
101184 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
101185 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
101186 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
101187 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
101188 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
101189 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
101190 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
101191 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
101192 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
101193 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
101194 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
101195 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
101196 +zone_page_state_1393 zone_page_state 0 1393 NULL
101197 +file_read_actor_1401 file_read_actor 4 1401 NULL
101198 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
101199 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
101200 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
101201 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
101202 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
101203 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
101204 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
101205 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
101206 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
101207 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
101208 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
101209 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
101210 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
101211 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
101212 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
101213 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
101214 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
101215 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
101216 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
101217 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
101218 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
101219 +rmap_add_1677 rmap_add 3 1677 NULL
101220 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
101221 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
101222 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
101223 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
101224 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
101225 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
101226 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
101227 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
101228 +cosa_write_1774 cosa_write 3 1774 NULL
101229 +update_macheader_1775 update_macheader 7 1775 NULL
101230 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
101231 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
101232 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
101233 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
101234 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
101235 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
101236 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
101237 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
101238 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
101239 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
101240 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
101241 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
101242 +read_swap_header_1957 read_swap_header 0 1957 NULL
101243 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
101244 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
101245 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
101246 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
101247 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
101248 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
101249 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
101250 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
101251 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
101252 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
101253 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
101254 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
101255 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
101256 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
101257 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
101258 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
101259 +audit_expand_2098 audit_expand 2 2098 NULL
101260 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
101261 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
101262 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
101263 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
101264 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
101265 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
101266 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
101267 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
101268 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
101269 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
101270 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
101271 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
101272 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
101273 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
101274 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
101275 +vhci_write_2224 vhci_write 3 2224 NULL
101276 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
101277 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
101278 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
101279 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
101280 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
101281 +do_update_counters_2259 do_update_counters 4 2259 NULL
101282 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
101283 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
101284 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
101285 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
101286 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
101287 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
101288 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
101289 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
101290 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
101291 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
101292 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
101293 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
101294 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
101295 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
101296 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
101297 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
101298 +raid1_size_2419 raid1_size 0-2 2419 NULL
101299 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
101300 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
101301 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
101302 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
101303 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
101304 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
101305 +update_pmkid_2481 update_pmkid 4 2481 NULL
101306 +wiphy_new_2482 wiphy_new 2 2482 NULL
101307 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
101308 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
101309 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
101310 +dm_write_2513 dm_write 3 2513 NULL
101311 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
101312 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
101313 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
101314 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
101315 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
101316 +slot_bytes_2609 slot_bytes 0 2609 NULL
101317 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
101318 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
101319 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
101320 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
101321 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
101322 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
101323 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
101324 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
101325 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
101326 +__next_cpu_2782 __next_cpu 1 2782 NULL
101327 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
101328 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
101329 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
101330 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
101331 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
101332 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
101333 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
101334 +mq_map_2871 mq_map 2 2871 NULL
101335 +nla_padlen_2883 nla_padlen 1 2883 NULL
101336 +cmm_write_2896 cmm_write 3 2896 NULL
101337 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
101338 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
101339 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
101340 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
101341 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
101342 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
101343 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
101344 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
101345 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
101346 +depth_write_3021 depth_write 3 3021 NULL
101347 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
101348 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
101349 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
101350 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
101351 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
101352 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
101353 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
101354 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
101355 +free_coherent_3082 free_coherent 4-2 3082 NULL
101356 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
101357 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
101358 +rb_alloc_3102 rb_alloc 1 3102 NULL
101359 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
101360 +print_time_3132 print_time 0 3132 NULL
101361 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
101362 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
101363 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
101364 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
101365 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
101366 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
101367 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
101368 +alloc_context_3194 alloc_context 1 3194 NULL
101369 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
101370 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
101371 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
101372 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
101373 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
101374 +key_key_read_3241 key_key_read 3 3241 NULL
101375 +number_3243 number 0 3243 NULL
101376 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
101377 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
101378 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
101379 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
101380 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
101381 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
101382 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
101383 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
101384 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
101385 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
101386 +scnprintf_3360 scnprintf 0-2 3360 NULL
101387 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
101388 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
101389 +send_stream_3397 send_stream 4 3397 NULL
101390 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
101391 +msix_map_region_3411 msix_map_region 3 3411 NULL
101392 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
101393 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
101394 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
101395 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
101396 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
101397 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
101398 +map_single_3449 map_single 0-2 3449 NULL
101399 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
101400 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
101401 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
101402 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
101403 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
101404 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
101405 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
101406 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
101407 +SyS_readv_3539 SyS_readv 3 3539 NULL
101408 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
101409 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
101410 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
101411 +evtchn_read_3569 evtchn_read 3 3569 NULL
101412 +vc_resize_3585 vc_resize 2-3 3585 NULL
101413 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
101414 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
101415 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
101416 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
101417 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
101418 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
101419 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
101420 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
101421 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
101422 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
101423 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
101424 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
101425 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
101426 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
101427 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
101428 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
101429 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
101430 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
101431 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
101432 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
101433 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
101434 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
101435 +get_fd_set_3866 get_fd_set 1 3866 NULL
101436 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
101437 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
101438 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
101439 +nvram_write_3894 nvram_write 3 3894 NULL
101440 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
101441 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
101442 +vcs_write_3910 vcs_write 3 3910 NULL
101443 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
101444 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
101445 +do_add_counters_3992 do_add_counters 3 3992 NULL
101446 +userspace_status_4004 userspace_status 4 4004 NULL
101447 +mei_write_4005 mei_write 3 4005 NULL nohasharray
101448 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
101449 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
101450 +mm_populate_4016 mm_populate 1 4016 NULL
101451 +blk_end_request_4024 blk_end_request 3 4024 NULL
101452 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
101453 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
101454 +read_file_queues_4078 read_file_queues 3 4078 NULL
101455 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
101456 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
101457 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
101458 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
101459 +tm6000_read_4151 tm6000_read 3 4151 NULL
101460 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
101461 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
101462 +get_alua_req_4166 get_alua_req 3 4166 NULL
101463 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
101464 +read_file_bool_4180 read_file_bool 3 4180 NULL
101465 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
101466 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
101467 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
101468 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
101469 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
101470 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
101471 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
101472 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
101473 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
101474 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
101475 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
101476 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
101477 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
101478 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
101479 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
101480 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
101481 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
101482 +memparse_4444 memparse 0 4444 NULL
101483 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
101484 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
101485 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
101486 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
101487 +set_link_security_4502 set_link_security 4 4502 NULL
101488 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
101489 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
101490 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
101491 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
101492 +tty_register_device_4544 tty_register_device 2 4544 NULL
101493 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
101494 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
101495 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
101496 +bch_alloc_4593 bch_alloc 1 4593 NULL
101497 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
101498 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
101499 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
101500 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
101501 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
101502 +kone_receive_4690 kone_receive 4 4690 NULL
101503 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
101504 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
101505 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
101506 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
101507 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
101508 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
101509 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
101510 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
101511 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
101512 +create_subvol_4791 create_subvol 4 4791 NULL
101513 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
101514 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
101515 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
101516 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
101517 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
101518 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
101519 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
101520 +sys_ipc_4889 sys_ipc 3 4889 NULL
101521 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
101522 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
101523 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
101524 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
101525 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
101526 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
101527 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
101528 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
101529 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
101530 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
101531 +do_mincore_5018 do_mincore 0-1 5018 NULL
101532 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
101533 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
101534 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
101535 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
101536 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
101537 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
101538 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
101539 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
101540 +sound_write_5102 sound_write 3 5102 NULL
101541 +clear_dirty_5105 clear_dirty 3 5105 NULL
101542 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
101543 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
101544 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
101545 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
101546 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
101547 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
101548 +skb_network_header_5203 skb_network_header 0 5203 NULL
101549 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
101550 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
101551 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
101552 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
101553 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
101554 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
101555 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
101556 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
101557 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
101558 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
101559 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
101560 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
101561 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
101562 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
101563 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
101564 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
101565 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
101566 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
101567 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
101568 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
101569 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
101570 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
101571 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
101572 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
101573 +tty_write_5494 tty_write 3 5494 NULL
101574 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
101575 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
101576 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
101577 +spidev_message_5518 spidev_message 3 5518 NULL
101578 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
101579 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
101580 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
101581 +le_readq_5557 le_readq 0 5557 NULL
101582 +inw_5558 inw 0 5558 NULL
101583 +fir16_create_5574 fir16_create 3 5574 NULL
101584 +bioset_create_5580 bioset_create 1 5580 NULL
101585 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
101586 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
101587 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
101588 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
101589 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
101590 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
101591 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
101592 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
101593 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
101594 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
101595 +get_arg_5694 get_arg 3 5694 NULL
101596 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
101597 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
101598 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
101599 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
101600 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
101601 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
101602 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
101603 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
101604 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
101605 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
101606 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
101607 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
101608 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
101609 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
101610 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
101611 +setup_req_5848 setup_req 3 5848 NULL
101612 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
101613 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
101614 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
101615 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
101616 +port_show_regs_5904 port_show_regs 3 5904 NULL
101617 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
101618 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
101619 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
101620 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
101621 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
101622 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
101623 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
101624 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
101625 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
101626 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
101627 +native_pte_val_5978 native_pte_val 0 5978 NULL
101628 +SyS_semop_5980 SyS_semop 3 5980 NULL
101629 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
101630 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
101631 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
101632 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
101633 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
101634 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
101635 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
101636 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
101637 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
101638 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
101639 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
101640 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
101641 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
101642 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
101643 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
101644 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
101645 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
101646 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
101647 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
101648 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
101649 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
101650 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
101651 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
101652 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
101653 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
101654 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
101655 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
101656 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
101657 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
101658 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
101659 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
101660 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
101661 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
101662 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
101663 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
101664 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
101665 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
101666 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
101667 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
101668 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
101669 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
101670 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
101671 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
101672 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
101673 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
101674 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
101675 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
101676 +mei_read_6507 mei_read 3 6507 NULL
101677 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
101678 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
101679 +wdm_read_6549 wdm_read 3 6549 NULL
101680 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
101681 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
101682 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
101683 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
101684 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
101685 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
101686 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
101687 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
101688 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
101689 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
101690 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
101691 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
101692 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
101693 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
101694 +mpeg_read_6708 mpeg_read 3 6708 NULL
101695 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
101696 +video_proc_write_6724 video_proc_write 3 6724 NULL
101697 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
101698 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
101699 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
101700 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
101701 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
101702 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
101703 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
101704 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
101705 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
101706 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
101707 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
101708 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
101709 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
101710 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
101711 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
101712 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
101713 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
101714 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
101715 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
101716 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
101717 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
101718 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
101719 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
101720 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
101721 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
101722 +request_key_async_6990 request_key_async 4 6990 NULL
101723 +tpl_write_6998 tpl_write 3 6998 NULL
101724 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
101725 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
101726 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
101727 +wimax_msg_7030 wimax_msg 4 7030 NULL
101728 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
101729 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
101730 +event_enable_read_7074 event_enable_read 3 7074 NULL
101731 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
101732 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
101733 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
101734 +check_header_7108 check_header 0 7108 NULL
101735 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
101736 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
101737 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
101738 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
101739 +get_param_h_7247 get_param_h 0 7247 NULL
101740 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
101741 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
101742 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
101743 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
101744 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
101745 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
101746 +mgmt_control_7349 mgmt_control 3 7349 NULL
101747 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
101748 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
101749 +hweight_long_7388 hweight_long 0-1 7388 NULL
101750 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
101751 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
101752 +readb_7401 readb 0 7401 NULL
101753 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
101754 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
101755 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
101756 +numa_emulation_7466 numa_emulation 2 7466 NULL
101757 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
101758 +garp_request_join_7471 garp_request_join 4 7471 NULL
101759 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
101760 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
101761 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
101762 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
101763 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
101764 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
101765 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
101766 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
101767 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
101768 +groups_alloc_7614 groups_alloc 1 7614 NULL
101769 +sg_virt_7616 sg_virt 0 7616 NULL
101770 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
101771 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
101772 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
101773 +dev_write_7708 dev_write 3 7708 NULL
101774 +unmap_region_7709 unmap_region 1 7709 NULL
101775 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
101776 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
101777 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
101778 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
101779 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
101780 +ioread32be_7773 ioread32be 0 7773 NULL
101781 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
101782 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
101783 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
101784 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
101785 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
101786 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
101787 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
101788 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
101789 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
101790 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
101791 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
101792 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
101793 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
101794 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
101795 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
101796 +sys_mbind_7990 sys_mbind 5 7990 NULL
101797 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
101798 +vcs_read_8017 vcs_read 3 8017 NULL
101799 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
101800 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
101801 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
101802 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
101803 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
101804 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
101805 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
101806 +venus_lookup_8121 venus_lookup 4 8121 NULL
101807 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
101808 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
101809 +ore_truncate_8181 ore_truncate 3 8181 NULL
101810 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
101811 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
101812 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
101813 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
101814 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
101815 +play_iframe_8219 play_iframe 3 8219 NULL
101816 +create_log_8225 create_log 2 8225 NULL nohasharray
101817 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
101818 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
101819 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
101820 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
101821 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
101822 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
101823 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
101824 +init_cdev_8274 init_cdev 1 8274 NULL
101825 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
101826 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
101827 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
101828 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
101829 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
101830 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
101831 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
101832 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
101833 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
101834 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
101835 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
101836 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
101837 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
101838 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
101839 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
101840 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
101841 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
101842 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
101843 +dev_config_8506 dev_config 3 8506 NULL
101844 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
101845 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
101846 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
101847 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
101848 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
101849 +user_on_off_8552 user_on_off 2 8552 NULL
101850 +profile_remove_8556 profile_remove 3 8556 NULL
101851 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
101852 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
101853 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
101854 +tower_write_8580 tower_write 3 8580 NULL
101855 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
101856 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
101857 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
101858 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
101859 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
101860 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
101861 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
101862 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
101863 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
101864 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
101865 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
101866 +arcfb_write_8702 arcfb_write 3 8702 NULL
101867 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
101868 +init_header_8703 init_header 0 8703 &i_size_read_8703
101869 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
101870 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
101871 +f_dupfd_8730 f_dupfd 1 8730 NULL
101872 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
101873 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
101874 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
101875 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
101876 +sys_prctl_8766 sys_prctl 4 8766 NULL
101877 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
101878 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
101879 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
101880 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
101881 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
101882 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
101883 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
101884 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
101885 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
101886 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
101887 +clear_bitset_8840 clear_bitset 2 8840 NULL
101888 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
101889 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
101890 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
101891 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
101892 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
101893 +layout_commit_8926 layout_commit 3 8926 NULL
101894 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
101895 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
101896 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
101897 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
101898 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
101899 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
101900 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
101901 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
101902 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
101903 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
101904 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
101905 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
101906 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
101907 +nla_put_9042 nla_put 3 9042 NULL
101908 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
101909 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
101910 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
101911 +string_9080 string 0 9080 NULL
101912 +create_queues_9088 create_queues 2-3 9088 NULL
101913 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
101914 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
101915 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
101916 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
101917 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
101918 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
101919 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
101920 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
101921 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
101922 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
101923 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
101924 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
101925 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
101926 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
101927 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
101928 +get_pfn_9207 get_pfn 1 9207 NULL
101929 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
101930 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
101931 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
101932 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
101933 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
101934 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
101935 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
101936 +flakey_status_9274 flakey_status 5 9274 NULL
101937 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
101938 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
101939 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
101940 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
101941 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
101942 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
101943 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
101944 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
101945 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
101946 +read_9397 read 3 9397 NULL
101947 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
101948 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
101949 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
101950 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
101951 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
101952 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
101953 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
101954 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
101955 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
101956 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
101957 +lp_write_9511 lp_write 3 9511 NULL
101958 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
101959 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
101960 +read_file_dma_9530 read_file_dma 3 9530 NULL
101961 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
101962 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
101963 +fw_node_create_9559 fw_node_create 2 9559 NULL
101964 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
101965 +kobj_map_9566 kobj_map 2-3 9566 NULL
101966 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
101967 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
101968 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
101969 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
101970 +do_sync_9604 do_sync 1 9604 NULL
101971 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
101972 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
101973 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
101974 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
101975 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
101976 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
101977 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
101978 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
101979 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
101980 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
101981 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
101982 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
101983 +is_hole_9694 is_hole 2 9694 NULL nohasharray
101984 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
101985 +fnb_9703 fnb 2-3 9703 NULL
101986 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
101987 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
101988 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
101989 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
101990 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
101991 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
101992 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
101993 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
101994 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
101995 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
101996 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
101997 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
101998 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
101999 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
102000 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
102001 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
102002 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
102003 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
102004 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
102005 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
102006 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
102007 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
102008 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
102009 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
102010 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
102011 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
102012 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
102013 +read_file_misc_9948 read_file_misc 3 9948 NULL
102014 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
102015 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
102016 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
102017 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
102018 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
102019 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
102020 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
102021 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
102022 +handle_request_10024 handle_request 9 10024 NULL
102023 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
102024 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
102025 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
102026 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
102027 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
102028 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
102029 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
102030 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
102031 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
102032 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
102033 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
102034 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
102035 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
102036 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
102037 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
102038 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
102039 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
102040 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
102041 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
102042 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
102043 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
102044 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
102045 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
102046 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
102047 +read_emulate_10310 read_emulate 2-4 10310 NULL
102048 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
102049 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
102050 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
102051 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
102052 +get_dump_page_10338 get_dump_page 1 10338 NULL
102053 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
102054 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
102055 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
102056 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
102057 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
102058 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
102059 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
102060 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
102061 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
102062 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
102063 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
102064 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
102065 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
102066 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
102067 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
102068 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
102069 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
102070 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
102071 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
102072 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
102073 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
102074 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
102075 +otp_read_10594 otp_read 2-4-5 10594 NULL
102076 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
102077 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
102078 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
102079 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
102080 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
102081 +parport_write_10669 parport_write 0 10669 NULL
102082 +inl_10708 inl 0 10708 NULL nohasharray
102083 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
102084 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
102085 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
102086 +spi_sync_10731 spi_sync 0 10731 NULL
102087 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
102088 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
102089 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
102090 +sys_syslog_10746 sys_syslog 3 10746 NULL
102091 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
102092 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
102093 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
102094 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
102095 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
102096 +sys_bind_10799 sys_bind 3 10799 NULL
102097 +compat_put_int_10828 compat_put_int 1 10828 NULL
102098 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
102099 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
102100 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
102101 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
102102 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
102103 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
102104 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
102105 +get_scq_10897 get_scq 2 10897 NULL
102106 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
102107 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
102108 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
102109 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
102110 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
102111 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
102112 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
102113 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
102114 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
102115 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
102116 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
102117 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
102118 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
102119 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
102120 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
102121 +count_argc_11083 count_argc 0 11083 NULL
102122 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
102123 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
102124 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
102125 +page_offset_11120 page_offset 0 11120 NULL
102126 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
102127 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
102128 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
102129 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
102130 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
102131 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
102132 +__swab16p_11220 __swab16p 0 11220 NULL
102133 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
102134 +mmap_region_11247 mmap_region 0-2 11247 NULL
102135 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
102136 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
102137 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
102138 +cru_detect_11272 cru_detect 1 11272 NULL
102139 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
102140 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
102141 +construct_key_11329 construct_key 3 11329 NULL nohasharray
102142 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
102143 +next_segment_11330 next_segment 0-2-1 11330 NULL
102144 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
102145 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
102146 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
102147 +sel_write_create_11353 sel_write_create 3 11353 NULL
102148 +handle_unit_11355 handle_unit 0-1 11355 NULL
102149 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
102150 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
102151 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
102152 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
102153 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
102154 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
102155 +str_to_user_11411 str_to_user 2 11411 NULL
102156 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
102157 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
102158 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
102159 +trace_options_read_11419 trace_options_read 3 11419 NULL
102160 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
102161 +prepare_image_11424 prepare_image 0 11424 NULL
102162 +vring_size_11426 vring_size 0-1-2 11426 NULL
102163 +bttv_read_11432 bttv_read 3 11432 NULL
102164 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
102165 +swp_offset_11475 swp_offset 0 11475 NULL
102166 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
102167 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
102168 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
102169 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
102170 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
102171 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
102172 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
102173 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
102174 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
102175 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
102176 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
102177 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
102178 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
102179 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
102180 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
102181 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
102182 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
102183 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
102184 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
102185 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
102186 +split_11691 split 2 11691 NULL
102187 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
102188 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
102189 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
102190 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
102191 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
102192 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
102193 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
102194 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
102195 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
102196 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
102197 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
102198 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
102199 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
102200 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
102201 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
102202 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
102203 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
102204 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
102205 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
102206 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
102207 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
102208 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
102209 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
102210 +atmel_read16_11981 atmel_read16 0 11981 NULL
102211 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
102212 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
102213 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
102214 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
102215 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
102216 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
102217 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
102218 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
102219 +set_powered_12129 set_powered 4 12129 NULL
102220 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
102221 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
102222 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
102223 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
102224 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
102225 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
102226 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
102227 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
102228 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
102229 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
102230 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
102231 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
102232 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
102233 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
102234 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
102235 +scaled_div_12201 scaled_div 1-2 12201 NULL
102236 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
102237 +receive_copy_12216 receive_copy 3 12216 NULL
102238 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
102239 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
102240 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
102241 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
102242 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
102243 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
102244 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
102245 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
102246 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
102247 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
102248 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
102249 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
102250 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
102251 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
102252 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
102253 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
102254 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
102255 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
102256 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
102257 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
102258 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
102259 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
102260 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
102261 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
102262 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
102263 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
102264 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
102265 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
102266 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
102267 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
102268 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
102269 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
102270 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
102271 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
102272 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
102273 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
102274 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
102275 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
102276 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
102277 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
102278 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
102279 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
102280 +wb_create_12651 wb_create 1 12651 NULL
102281 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
102282 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
102283 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
102284 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
102285 +ivtv_write_12721 ivtv_write 3 12721 NULL
102286 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
102287 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
102288 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
102289 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
102290 +listxattr_12769 listxattr 3 12769 NULL
102291 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
102292 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
102293 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
102294 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
102295 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
102296 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
102297 +readq_12825 readq 0 12825 NULL
102298 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
102299 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
102300 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
102301 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
102302 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
102303 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
102304 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
102305 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
102306 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
102307 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
102308 +bm_status_write_12964 bm_status_write 3 12964 NULL
102309 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
102310 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
102311 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
102312 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
102313 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
102314 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
102315 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
102316 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
102317 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
102318 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
102319 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
102320 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
102321 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
102322 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
102323 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
102324 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
102325 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
102326 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
102327 +blk_update_request_13146 blk_update_request 3 13146 NULL
102328 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
102329 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
102330 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
102331 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
102332 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
102333 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
102334 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
102335 +comedi_read_13199 comedi_read 3 13199 NULL
102336 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
102337 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
102338 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
102339 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
102340 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
102341 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
102342 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
102343 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
102344 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
102345 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
102346 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
102347 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
102348 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
102349 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
102350 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
102351 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
102352 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
102353 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
102354 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
102355 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
102356 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
102357 +cache_ctr_13364 cache_ctr 2 13364 NULL
102358 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
102359 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
102360 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
102361 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
102362 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
102363 +sky2_receive_13407 sky2_receive 2 13407 NULL
102364 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
102365 +keyring_read_13438 keyring_read 3 13438 NULL
102366 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
102367 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
102368 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
102369 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
102370 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
102371 +core_status_13515 core_status 4 13515 NULL
102372 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
102373 +bm_init_13529 bm_init 2 13529 NULL
102374 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
102375 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
102376 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
102377 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
102378 +sys_madvise_13569 sys_madvise 1 13569 NULL
102379 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
102380 +cache_write_13589 cache_write 3 13589 NULL
102381 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
102382 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
102383 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
102384 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
102385 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
102386 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
102387 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
102388 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
102389 +packet_snd_13634 packet_snd 3 13634 NULL
102390 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
102391 +cache_downcall_13666 cache_downcall 3 13666 NULL
102392 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
102393 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
102394 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
102395 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
102396 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
102397 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
102398 +random_read_13815 random_read 3 13815 NULL
102399 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
102400 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
102401 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
102402 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
102403 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
102404 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
102405 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
102406 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
102407 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
102408 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
102409 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
102410 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
102411 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
102412 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
102413 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
102414 +com90xx_found_13974 com90xx_found 3 13974 NULL
102415 +qcam_read_13977 qcam_read 3 13977 NULL
102416 +dsp_read_13980 dsp_read 2 13980 NULL
102417 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
102418 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
102419 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
102420 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
102421 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
102422 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
102423 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
102424 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
102425 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
102426 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
102427 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
102428 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
102429 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
102430 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
102431 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
102432 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
102433 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
102434 +em_canid_change_14150 em_canid_change 3 14150 NULL
102435 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
102436 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
102437 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
102438 +alloc_async_14208 alloc_async 1 14208 NULL
102439 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
102440 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
102441 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
102442 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
102443 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
102444 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
102445 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
102446 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
102447 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
102448 +rr_status_14293 rr_status 5 14293 NULL
102449 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
102450 +oo_objects_14319 oo_objects 0 14319 NULL
102451 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
102452 +scsi2int_14358 scsi2int 0 14358 NULL
102453 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
102454 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
102455 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
102456 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
102457 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
102458 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
102459 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
102460 +block_size_14443 block_size 0 14443 NULL
102461 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
102462 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
102463 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
102464 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
102465 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
102466 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
102467 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
102468 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
102469 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
102470 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
102471 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
102472 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
102473 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
102474 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
102475 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
102476 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
102477 +dbJoin_14644 dbJoin 0 14644 NULL
102478 +profile_replace_14652 profile_replace 3 14652 NULL
102479 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
102480 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
102481 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
102482 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
102483 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
102484 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
102485 +get_bio_block_14714 get_bio_block 0 14714 NULL
102486 +vfd_write_14717 vfd_write 3 14717 NULL
102487 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
102488 +raid1_resize_14740 raid1_resize 2 14740 NULL
102489 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
102490 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
102491 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
102492 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
102493 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
102494 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
102495 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
102496 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
102497 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
102498 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
102499 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
102500 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
102501 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
102502 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
102503 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
102504 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
102505 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
102506 +unifi_read_14899 unifi_read 3 14899 NULL
102507 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
102508 +krealloc_14908 krealloc 2 14908 NULL
102509 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
102510 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
102511 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
102512 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
102513 +queue_cnt_14951 queue_cnt 0 14951 NULL
102514 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
102515 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
102516 +setkey_14987 setkey 3 14987 NULL nohasharray
102517 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
102518 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
102519 +vmap_15025 vmap 2 15025 NULL
102520 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
102521 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
102522 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
102523 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
102524 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
102525 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
102526 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
102527 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
102528 +start_port_15124 start_port 0 15124 NULL
102529 +memchr_15126 memchr 0 15126 NULL
102530 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
102531 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
102532 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
102533 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
102534 +reserve_resources_15194 reserve_resources 3 15194 NULL
102535 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
102536 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
102537 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
102538 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
102539 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
102540 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
102541 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
102542 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
102543 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
102544 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
102545 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
102546 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
102547 +ioread16_15342 ioread16 0 15342 NULL
102548 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
102549 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
102550 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
102551 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
102552 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
102553 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
102554 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
102555 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
102556 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
102557 +get_modalias_15406 get_modalias 2 15406 NULL
102558 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
102559 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
102560 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
102561 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
102562 +memweight_15450 memweight 2 15450 NULL
102563 +vmalloc_15464 vmalloc 1 15464 NULL
102564 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
102565 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
102566 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
102567 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
102568 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
102569 +persistent_status_15574 persistent_status 4 15574 NULL
102570 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
102571 +vme_user_write_15587 vme_user_write 3 15587 NULL
102572 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
102573 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
102574 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
102575 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
102576 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
102577 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
102578 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
102579 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
102580 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
102581 +fs_path_add_15648 fs_path_add 3 15648 NULL
102582 +xsd_read_15653 xsd_read 3 15653 NULL
102583 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
102584 +unix_bind_15668 unix_bind 3 15668 NULL
102585 +dm_read_15674 dm_read 3 15674 NULL
102586 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
102587 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
102588 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
102589 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
102590 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
102591 +do_test_15766 do_test 1 15766 NULL
102592 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
102593 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
102594 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
102595 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
102596 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
102597 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
102598 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
102599 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
102600 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
102601 +table_size_15851 table_size 0-1-2 15851 NULL
102602 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
102603 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
102604 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
102605 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
102606 +native_read_msr_15905 native_read_msr 0 15905 NULL
102607 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
102608 +power_read_15939 power_read 3 15939 NULL
102609 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
102610 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
102611 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
102612 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
102613 +frame_alloc_15981 frame_alloc 4 15981 NULL
102614 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
102615 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
102616 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
102617 +got_frame_16028 got_frame 2 16028 NULL
102618 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
102619 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
102620 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
102621 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
102622 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
102623 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
102624 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
102625 +fsm_init_16134 fsm_init 2 16134 NULL
102626 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
102627 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
102628 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
102629 +mapping_level_16188 mapping_level 2 16188 NULL
102630 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
102631 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
102632 +create_table_16213 create_table 2 16213 NULL
102633 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
102634 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
102635 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
102636 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
102637 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
102638 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
102639 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
102640 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
102641 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
102642 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
102643 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
102644 +account_16283 account 0-2-4 16283 NULL nohasharray
102645 +mirror_status_16283 mirror_status 5 16283 &account_16283
102646 +retry_instruction_16285 retry_instruction 2 16285 NULL
102647 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
102648 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
102649 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
102650 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
102651 +wb_map_16301 wb_map 2 16301 NULL
102652 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
102653 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
102654 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
102655 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
102656 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
102657 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
102658 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
102659 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
102660 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
102661 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
102662 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
102663 +raid10_resize_16537 raid10_resize 2 16537 NULL
102664 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
102665 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
102666 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
102667 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
102668 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
102669 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
102670 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
102671 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
102672 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
102673 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
102674 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
102675 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
102676 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
102677 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
102678 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
102679 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
102680 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
102681 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
102682 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
102683 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
102684 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
102685 +st_write_16874 st_write 3 16874 NULL
102686 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
102687 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
102688 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
102689 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
102690 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
102691 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
102692 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
102693 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
102694 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
102695 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
102696 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
102697 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
102698 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
102699 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
102700 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
102701 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
102702 +mac_address_string_17091 mac_address_string 0 17091 NULL
102703 +entry_length_17093 entry_length 0 17093 NULL
102704 +sys_preadv_17100 sys_preadv 3 17100 NULL
102705 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
102706 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
102707 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
102708 +sep_read_17161 sep_read 3 17161 NULL
102709 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
102710 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
102711 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
102712 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
102713 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
102714 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
102715 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
102716 +to_oblock_17254 to_oblock 0-1 17254 NULL
102717 +unpack_value_17259 unpack_value 1 17259 NULL
102718 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
102719 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
102720 +alloc_ep_17269 alloc_ep 1 17269 NULL
102721 +pg_read_17276 pg_read 3 17276 NULL
102722 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
102723 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
102724 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
102725 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
102726 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
102727 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
102728 +skb_pad_17302 skb_pad 2 17302 NULL
102729 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
102730 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
102731 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
102732 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
102733 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
102734 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
102735 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
102736 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
102737 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
102738 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
102739 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
102740 +compat_cmd_17465 compat_cmd 2 17465 NULL
102741 +probe_bios_17467 probe_bios 1 17467 NULL
102742 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
102743 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
102744 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
102745 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
102746 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
102747 +copy_from_user_17559 copy_from_user 3 17559 NULL
102748 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
102749 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
102750 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
102751 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
102752 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
102753 +osst_execute_17607 osst_execute 7-6 17607 NULL
102754 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
102755 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
102756 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
102757 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
102758 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
102759 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
102760 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
102761 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
102762 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
102763 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
102764 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
102765 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
102766 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
102767 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
102768 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
102769 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
102770 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
102771 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
102772 +perf_clock_17787 perf_clock 0 17787 NULL
102773 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
102774 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
102775 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
102776 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
102777 +count_leafs_17842 count_leafs 0 17842 NULL
102778 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
102779 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
102780 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
102781 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
102782 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
102783 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
102784 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
102785 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
102786 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
102787 +recover_head_17904 recover_head 3 17904 NULL
102788 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
102789 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
102790 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
102791 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
102792 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
102793 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
102794 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
102795 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
102796 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
102797 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
102798 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
102799 +fill_read_18019 fill_read 0 18019 NULL
102800 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
102801 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
102802 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
102803 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
102804 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
102805 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
102806 +packet_came_18072 packet_came 3 18072 NULL
102807 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
102808 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
102809 +get_vm_area_18080 get_vm_area 1 18080 NULL
102810 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
102811 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
102812 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
102813 +svc_getnl_18120 svc_getnl 0 18120 NULL
102814 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
102815 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
102816 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
102817 +_has_tag_18169 _has_tag 2 18169 NULL
102818 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
102819 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
102820 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
102821 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
102822 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
102823 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
102824 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
102825 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
102826 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
102827 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
102828 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
102829 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
102830 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
102831 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
102832 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
102833 +um_idi_write_18293 um_idi_write 3 18293 NULL
102834 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
102835 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
102836 +vga_r_18310 vga_r 0 18310 NULL
102837 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
102838 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
102839 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
102840 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
102841 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
102842 +ep_io_18367 ep_io 0 18367 NULL
102843 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
102844 +ci_role_write_18388 ci_role_write 3 18388 NULL
102845 +__video_register_device_18399 __video_register_device 3 18399 NULL
102846 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
102847 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
102848 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
102849 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
102850 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
102851 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
102852 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
102853 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
102854 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
102855 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
102856 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
102857 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
102858 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
102859 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
102860 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
102861 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
102862 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
102863 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
102864 +debug_output_18575 debug_output 3 18575 NULL
102865 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
102866 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
102867 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
102868 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
102869 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
102870 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
102871 +from_buffer_18625 from_buffer 3 18625 NULL
102872 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
102873 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
102874 +unmap_page_18665 unmap_page 2-3 18665 NULL
102875 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
102876 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
102877 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
102878 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
102879 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
102880 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
102881 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
102882 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
102883 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
102884 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
102885 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
102886 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
102887 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
102888 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
102889 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
102890 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
102891 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
102892 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
102893 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
102894 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
102895 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
102896 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
102897 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
102898 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
102899 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
102900 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
102901 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
102902 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
102903 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
102904 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
102905 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
102906 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
102907 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
102908 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
102909 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
102910 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
102911 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
102912 +huge_page_size_19008 huge_page_size 0 19008 NULL
102913 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
102914 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
102915 +revalidate_19043 revalidate 2 19043 NULL
102916 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
102917 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
102918 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
102919 +msix_map_region_19072 msix_map_region 2 19072 NULL
102920 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
102921 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
102922 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
102923 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
102924 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
102925 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
102926 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
102927 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
102928 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
102929 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
102930 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
102931 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
102932 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
102933 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
102934 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
102935 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
102936 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
102937 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
102938 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
102939 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
102940 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
102941 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
102942 +qc_capture_19298 qc_capture 3 19298 NULL
102943 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
102944 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
102945 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
102946 +debug_read_19322 debug_read 3 19322 NULL
102947 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
102948 +closure_sub_19359 closure_sub 2 19359 NULL
102949 +read_zero_19366 read_zero 3 19366 NULL
102950 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
102951 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
102952 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
102953 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
102954 +__phys_addr_19434 __phys_addr 0 19434 NULL
102955 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
102956 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
102957 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
102958 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
102959 +sky2_read16_19475 sky2_read16 0 19475 NULL
102960 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
102961 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
102962 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
102963 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
102964 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
102965 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
102966 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
102967 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
102968 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
102969 +nfsd_read_19568 nfsd_read 5 19568 NULL
102970 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
102971 +bm_status_read_19583 bm_status_read 3 19583 NULL
102972 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
102973 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
102974 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
102975 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
102976 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
102977 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
102978 +bio_detain_19690 bio_detain 2 19690 NULL
102979 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
102980 +read_reg_19723 read_reg 0 19723 NULL
102981 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
102982 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
102983 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
102984 +p9_client_read_19750 p9_client_read 5 19750 NULL
102985 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
102986 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
102987 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
102988 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
102989 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
102990 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
102991 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
102992 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
102993 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
102994 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
102995 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
102996 +__nla_put_19857 __nla_put 3 19857 NULL
102997 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
102998 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
102999 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
103000 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
103001 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
103002 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
103003 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
103004 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
103005 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
103006 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
103007 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
103008 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
103009 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
103010 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
103011 +team_options_register_20091 team_options_register 3 20091 NULL
103012 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
103013 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
103014 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
103015 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
103016 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
103017 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
103018 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
103019 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
103020 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
103021 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
103022 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
103023 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
103024 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
103025 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
103026 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
103027 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
103028 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
103029 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
103030 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
103031 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
103032 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
103033 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
103034 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
103035 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
103036 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
103037 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
103038 +read_buf_20469 read_buf 2 20469 NULL
103039 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
103040 +fast_user_write_20494 fast_user_write 5 20494 NULL
103041 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
103042 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
103043 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
103044 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
103045 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
103046 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
103047 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
103048 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
103049 +venus_create_20555 venus_create 4 20555 NULL
103050 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
103051 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
103052 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
103053 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
103054 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
103055 +lirc_write_20604 lirc_write 3 20604 NULL
103056 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
103057 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
103058 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
103059 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
103060 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
103061 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
103062 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
103063 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
103064 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
103065 +cpumask_size_20683 cpumask_size 0 20683 NULL
103066 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
103067 +gru_vtop_20689 gru_vtop 2 20689 NULL
103068 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
103069 +__maestro_read_20700 __maestro_read 0 20700 NULL
103070 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
103071 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
103072 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
103073 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
103074 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
103075 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
103076 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
103077 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
103078 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
103079 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
103080 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
103081 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
103082 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
103083 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
103084 +sys_sendto_20809 sys_sendto 6 20809 NULL
103085 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
103086 +strndup_user_20819 strndup_user 2 20819 NULL
103087 +calc_layout_20829 calc_layout 3 20829 NULL
103088 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
103089 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
103090 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
103091 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
103092 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
103093 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
103094 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
103095 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
103096 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
103097 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
103098 +htable_bits_20933 htable_bits 0 20933 NULL
103099 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
103100 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
103101 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
103102 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
103103 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
103104 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
103105 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
103106 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
103107 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
103108 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
103109 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
103110 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
103111 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
103112 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
103113 +multipath_status_21094 multipath_status 5 21094 NULL
103114 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
103115 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
103116 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
103117 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
103118 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
103119 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
103120 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
103121 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
103122 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
103123 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
103124 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
103125 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
103126 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
103127 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
103128 +input_ff_create_21240 input_ff_create 2 21240 NULL
103129 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
103130 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
103131 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
103132 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
103133 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
103134 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
103135 +add_res_range_21310 add_res_range 4 21310 NULL
103136 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
103137 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
103138 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
103139 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
103140 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
103141 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
103142 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
103143 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
103144 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
103145 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
103146 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
103147 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
103148 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
103149 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
103150 +concat_writev_21451 concat_writev 3 21451 NULL
103151 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
103152 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
103153 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
103154 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
103155 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
103156 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
103157 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
103158 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
103159 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
103160 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
103161 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
103162 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
103163 +validate_nnode_21638 validate_nnode 0 21638 NULL
103164 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
103165 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
103166 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
103167 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
103168 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
103169 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
103170 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
103171 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
103172 +vm_brk_21739 vm_brk 1 21739 NULL
103173 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
103174 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
103175 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
103176 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
103177 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
103178 +min_odd_21802 min_odd 0 21802 NULL
103179 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
103180 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
103181 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
103182 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
103183 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
103184 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
103185 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
103186 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
103187 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
103188 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
103189 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
103190 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
103191 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
103192 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
103193 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
103194 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
103195 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
103196 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
103197 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
103198 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
103199 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
103200 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
103201 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
103202 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
103203 +write_opcode_22082 write_opcode 2 22082 NULL
103204 +mem_rw_22085 mem_rw 3 22085 NULL
103205 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
103206 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
103207 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
103208 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
103209 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
103210 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
103211 +compat_insn_22142 compat_insn 2 22142 NULL
103212 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
103213 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
103214 +fls_22210 fls 0 22210 NULL
103215 +mem_write_22232 mem_write 3 22232 NULL
103216 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
103217 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
103218 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
103219 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
103220 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
103221 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
103222 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
103223 +extend_brk_22301 extend_brk 0 22301 NULL
103224 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
103225 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
103226 +get_segment_base_22324 get_segment_base 0 22324 NULL
103227 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
103228 +atomic_read_22342 atomic_read 0 22342 NULL
103229 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
103230 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
103231 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
103232 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
103233 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
103234 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
103235 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
103236 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
103237 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
103238 +zoran_write_22404 zoran_write 3 22404 NULL
103239 +queue_reply_22416 queue_reply 3 22416 NULL
103240 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
103241 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
103242 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
103243 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
103244 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
103245 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
103246 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
103247 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
103248 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
103249 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
103250 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
103251 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
103252 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
103253 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
103254 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
103255 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
103256 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
103257 +snapshot_read_22601 snapshot_read 3 22601 NULL
103258 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
103259 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
103260 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
103261 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
103262 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
103263 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
103264 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
103265 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
103266 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
103267 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
103268 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
103269 +map_22700 map 2 22700 NULL
103270 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
103271 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
103272 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
103273 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
103274 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
103275 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
103276 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
103277 +print_frame_22769 print_frame 0 22769 NULL
103278 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
103279 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
103280 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
103281 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
103282 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
103283 +create_attr_set_22861 create_attr_set 1 22861 NULL
103284 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
103285 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
103286 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
103287 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
103288 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
103289 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
103290 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
103291 +vme_get_size_22964 vme_get_size 0 22964 NULL
103292 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
103293 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
103294 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
103295 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
103296 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
103297 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
103298 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
103299 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
103300 +st_status_23032 st_status 5 23032 NULL
103301 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
103302 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
103303 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
103304 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
103305 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
103306 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
103307 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
103308 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
103309 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
103310 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
103311 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
103312 +fls_long_23096 fls_long 0 23096 NULL
103313 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
103314 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
103315 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
103316 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
103317 +__clear_user_23118 __clear_user 0 23118 NULL
103318 +dm_write_async_23120 dm_write_async 3 23120 NULL
103319 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
103320 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
103321 +read_file_ani_23161 read_file_ani 3 23161 NULL
103322 +ioremap_23172 ioremap 1-2 23172 NULL
103323 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
103324 +usblp_write_23178 usblp_write 3 23178 NULL
103325 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
103326 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
103327 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
103328 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
103329 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
103330 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
103331 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
103332 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
103333 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
103334 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
103335 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
103336 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
103337 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
103338 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
103339 +doc_probe_23285 doc_probe 1 23285 NULL
103340 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
103341 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
103342 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
103343 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
103344 +page_readlink_23346 page_readlink 3 23346 NULL
103345 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
103346 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
103347 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
103348 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
103349 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
103350 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
103351 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
103352 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
103353 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
103354 +event_filter_read_23494 event_filter_read 3 23494 NULL
103355 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
103356 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
103357 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
103358 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
103359 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
103360 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
103361 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
103362 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
103363 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
103364 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
103365 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
103366 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
103367 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
103368 +sInW_23663 sInW 0 23663 NULL
103369 +SyS_connect_23669 SyS_connect 3 23669 NULL
103370 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
103371 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
103372 +cx18_read_23699 cx18_read 3 23699 NULL
103373 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
103374 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
103375 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
103376 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
103377 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
103378 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
103379 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
103380 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
103381 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
103382 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
103383 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
103384 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
103385 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
103386 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
103387 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
103388 +p54_init_common_23850 p54_init_common 1 23850 NULL
103389 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
103390 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
103391 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
103392 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
103393 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
103394 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
103395 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
103396 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
103397 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
103398 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
103399 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
103400 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
103401 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
103402 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
103403 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
103404 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
103405 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
103406 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
103407 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
103408 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
103409 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
103410 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
103411 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
103412 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
103413 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
103414 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
103415 +mpu401_read_24126 mpu401_read 3 24126 NULL
103416 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
103417 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
103418 +set_discard_24162 set_discard 2 24162 NULL
103419 +adu_read_24177 adu_read 3 24177 NULL
103420 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
103421 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
103422 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
103423 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
103424 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
103425 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
103426 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
103427 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
103428 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
103429 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
103430 +thin_status_24278 thin_status 5 24278 NULL
103431 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
103432 +msg_size_24288 msg_size 0 24288 NULL
103433 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
103434 +map_page_24298 map_page 3-4 24298 NULL
103435 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
103436 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
103437 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
103438 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
103439 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
103440 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
103441 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
103442 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
103443 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
103444 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
103445 +igetword_24373 igetword 0 24373 NULL
103446 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
103447 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
103448 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
103449 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
103450 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
103451 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
103452 +smk_user_access_24440 smk_user_access 3 24440 NULL
103453 +page_address_24444 page_address 0 24444 NULL
103454 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
103455 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
103456 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
103457 +pd_video_read_24510 pd_video_read 3 24510 NULL
103458 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
103459 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
103460 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
103461 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
103462 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
103463 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
103464 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
103465 +count_preds_24600 count_preds 0 24600 NULL
103466 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
103467 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
103468 +context_alloc_24645 context_alloc 3 24645 NULL
103469 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
103470 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
103471 +read_fs_24717 read_fs 0 24717 NULL
103472 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
103473 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
103474 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
103475 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
103476 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
103477 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
103478 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
103479 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
103480 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
103481 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
103482 +cache_read_24790 cache_read 3 24790 NULL
103483 +unpack_str_24798 unpack_str 0 24798 NULL
103484 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
103485 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
103486 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
103487 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
103488 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
103489 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
103490 +setup_buffering_24872 setup_buffering 3 24872 NULL
103491 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
103492 +queues_read_24877 queues_read 3 24877 NULL nohasharray
103493 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
103494 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
103495 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
103496 +next_token_24929 next_token 0 24929 NULL
103497 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
103498 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
103499 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
103500 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
103501 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
103502 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
103503 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
103504 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
103505 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
103506 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
103507 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
103508 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
103509 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
103510 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
103511 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
103512 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
103513 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
103514 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
103515 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
103516 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
103517 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
103518 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
103519 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
103520 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
103521 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
103522 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
103523 +stripe_status_25259 stripe_status 5 25259 NULL
103524 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
103525 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
103526 +vfs_writev_25278 vfs_writev 3 25278 NULL
103527 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
103528 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
103529 +help_25316 help 5 25316 NULL nohasharray
103530 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
103531 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
103532 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
103533 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
103534 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
103535 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
103536 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
103537 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
103538 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
103539 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
103540 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
103541 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
103542 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
103543 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
103544 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
103545 +sb_permission_25523 sb_permission 0 25523 NULL
103546 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
103547 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
103548 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
103549 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
103550 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
103551 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
103552 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
103553 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
103554 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
103555 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
103556 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
103557 +__direct_map_25647 __direct_map 5-6 25647 NULL
103558 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
103559 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
103560 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
103561 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
103562 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
103563 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
103564 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
103565 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
103566 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
103567 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
103568 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
103569 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
103570 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
103571 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
103572 +sg_read_25799 sg_read 3 25799 NULL
103573 +system_enable_read_25815 system_enable_read 3 25815 NULL
103574 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
103575 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
103576 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
103577 +parport_read_25855 parport_read 0 25855 NULL
103578 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
103579 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
103580 +key_attr_size_25865 key_attr_size 0 25865 NULL
103581 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
103582 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
103583 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
103584 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
103585 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
103586 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
103587 +rcname_read_25919 rcname_read 3 25919 NULL
103588 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
103589 +key_flags_read_25931 key_flags_read 3 25931 NULL
103590 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
103591 +flush_25957 flush 2 25957 NULL
103592 +video_register_device_25971 video_register_device 3 25971 NULL
103593 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
103594 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
103595 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
103596 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
103597 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
103598 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
103599 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
103600 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
103601 +tun_do_read_26047 tun_do_read 5 26047 NULL
103602 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
103603 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
103604 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
103605 +skb_cow_26138 skb_cow 2 26138 NULL
103606 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
103607 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
103608 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
103609 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
103610 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
103611 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
103612 +disk_devt_26180 disk_devt 0 26180 NULL
103613 +get_registers_26187 get_registers 3 26187 NULL
103614 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
103615 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
103616 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
103617 +mce_write_26201 mce_write 3 26201 NULL
103618 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
103619 +bio_split_26235 bio_split 2 26235 NULL
103620 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
103621 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
103622 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
103623 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
103624 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
103625 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
103626 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
103627 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
103628 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
103629 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
103630 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
103631 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
103632 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
103633 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
103634 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
103635 +read_vmcore_26501 read_vmcore 3 26501 NULL
103636 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
103637 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
103638 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
103639 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
103640 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
103641 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
103642 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
103643 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
103644 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
103645 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
103646 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
103647 +pack_value_26625 pack_value 1 26625 NULL
103648 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
103649 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
103650 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
103651 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
103652 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
103653 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
103654 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
103655 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
103656 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
103657 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
103658 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
103659 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
103660 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
103661 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
103662 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
103663 +smk_write_load_26829 smk_write_load 3 26829 NULL
103664 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
103665 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
103666 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
103667 +scnprint_id_26842 scnprint_id 3 26842 NULL
103668 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
103669 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
103670 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
103671 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
103672 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
103673 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
103674 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
103675 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
103676 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
103677 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
103678 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
103679 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
103680 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
103681 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
103682 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
103683 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
103684 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
103685 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
103686 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
103687 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
103688 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
103689 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
103690 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
103691 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
103692 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
103693 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
103694 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
103695 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
103696 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
103697 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
103698 +pms_capture_27142 pms_capture 4 27142 NULL
103699 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
103700 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
103701 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
103702 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
103703 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
103704 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
103705 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
103706 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
103707 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
103708 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
103709 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
103710 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
103711 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
103712 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
103713 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
103714 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
103715 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
103716 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
103717 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
103718 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
103719 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
103720 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
103721 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
103722 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
103723 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
103724 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
103725 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
103726 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
103727 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
103728 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
103729 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
103730 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
103731 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
103732 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
103733 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
103734 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
103735 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
103736 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
103737 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
103738 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
103739 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
103740 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
103741 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
103742 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
103743 +qword_get_27670 qword_get 0 27670 NULL
103744 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
103745 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
103746 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
103747 +evm_write_key_27715 evm_write_key 3 27715 NULL
103748 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
103749 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
103750 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
103751 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
103752 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
103753 +kcalloc_27770 kcalloc 1-2 27770 NULL
103754 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
103755 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
103756 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
103757 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
103758 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
103759 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
103760 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
103761 +read_profile_27859 read_profile 3 27859 NULL
103762 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
103763 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
103764 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
103765 +gluebi_write_27905 gluebi_write 3 27905 NULL
103766 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
103767 +bm_find_next_27929 bm_find_next 2 27929 NULL
103768 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
103769 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
103770 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
103771 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
103772 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
103773 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
103774 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
103775 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
103776 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
103777 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
103778 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
103779 +pool_status_28055 pool_status 5 28055 NULL
103780 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
103781 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
103782 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
103783 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
103784 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
103785 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
103786 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
103787 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
103788 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
103789 +video_read_28148 video_read 3 28148 NULL
103790 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
103791 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
103792 +vread_28173 vread 0 28173 NULL
103793 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
103794 +d_path_28198 d_path 0 28198 NULL
103795 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
103796 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
103797 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
103798 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
103799 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
103800 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
103801 +usemap_size_28281 usemap_size 0 28281 NULL
103802 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
103803 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
103804 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
103805 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
103806 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
103807 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
103808 +snapshot_write_28351 snapshot_write 3 28351 NULL
103809 +sys_writev_28384 sys_writev 3 28384 NULL
103810 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
103811 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
103812 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
103813 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
103814 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
103815 +__split_large_page_28429 __split_large_page 2 28429 NULL
103816 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
103817 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
103818 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
103819 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
103820 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
103821 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
103822 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
103823 +max_response_pages_28492 max_response_pages 0 28492 NULL
103824 +clear_discard_28494 clear_discard 2 28494 NULL
103825 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
103826 +__next_node_28521 __next_node 1 28521 NULL
103827 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
103828 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
103829 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
103830 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
103831 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
103832 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
103833 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
103834 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
103835 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
103836 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
103837 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
103838 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
103839 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
103840 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
103841 +_set_range_28627 _set_range 3 28627 NULL
103842 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
103843 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
103844 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
103845 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
103846 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
103847 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
103848 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
103849 +spi_execute_28736 spi_execute 5 28736 NULL
103850 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
103851 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
103852 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
103853 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
103854 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
103855 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
103856 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
103857 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
103858 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
103859 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
103860 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
103861 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
103862 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
103863 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
103864 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
103865 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
103866 +to_cblock_28899 to_cblock 0-1 28899 NULL
103867 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
103868 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
103869 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
103870 +push_rx_28939 push_rx 3 28939 NULL
103871 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
103872 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
103873 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
103874 +bin_uuid_28999 bin_uuid 3 28999 NULL
103875 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
103876 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
103877 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
103878 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
103879 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
103880 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
103881 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
103882 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
103883 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
103884 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
103885 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
103886 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
103887 +snprintf_29125 snprintf 0 29125 NULL
103888 +iov_shorten_29130 iov_shorten 0 29130 NULL
103889 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
103890 +reshape_ring_29147 reshape_ring 2 29147 NULL
103891 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
103892 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
103893 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
103894 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
103895 +__mm_populate_29204 __mm_populate 1 29204 NULL
103896 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
103897 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
103898 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
103899 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
103900 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
103901 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
103902 +recover_peb_29238 recover_peb 6-7 29238 NULL
103903 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
103904 +block_div_29268 block_div 0-1-2 29268 NULL
103905 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
103906 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
103907 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
103908 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
103909 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
103910 +tun_put_user_29337 tun_put_user 5 29337 NULL
103911 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
103912 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
103913 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
103914 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
103915 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
103916 +mempool_create_29437 mempool_create 1 29437 NULL
103917 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
103918 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
103919 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
103920 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
103921 +do_register_entry_29478 do_register_entry 4 29478 NULL
103922 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
103923 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
103924 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
103925 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
103926 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
103927 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
103928 +set_brk_29551 set_brk 1 29551 NULL nohasharray
103929 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
103930 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
103931 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
103932 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
103933 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
103934 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
103935 +slots_per_page_29601 slots_per_page 0 29601 NULL
103936 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
103937 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
103938 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
103939 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
103940 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
103941 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
103942 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
103943 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
103944 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
103945 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
103946 +probes_write_29711 probes_write 3 29711 NULL
103947 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
103948 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
103949 +std_nic_write_29752 std_nic_write 3 29752 NULL
103950 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
103951 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
103952 +dbAlloc_29794 dbAlloc 0 29794 NULL
103953 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
103954 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
103955 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
103956 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
103957 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
103958 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
103959 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
103960 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
103961 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
103962 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
103963 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
103964 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
103965 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
103966 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
103967 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
103968 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
103969 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
103970 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
103971 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
103972 +drp_wmove_30043 drp_wmove 4 30043 NULL
103973 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
103974 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
103975 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
103976 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
103977 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
103978 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
103979 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
103980 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
103981 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
103982 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
103983 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
103984 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
103985 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
103986 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
103987 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
103988 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
103989 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
103990 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
103991 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
103992 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
103993 +compat_readv_30273 compat_readv 3 30273 NULL
103994 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
103995 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
103996 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
103997 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
103998 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
103999 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
104000 +resource_from_user_30341 resource_from_user 3 30341 NULL
104001 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
104002 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
104003 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
104004 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
104005 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
104006 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
104007 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
104008 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
104009 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
104010 +mq_create_30425 mq_create 1 30425 NULL
104011 +enable_write_30456 enable_write 3 30456 NULL
104012 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
104013 +urandom_read_30462 urandom_read 3 30462 NULL
104014 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
104015 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
104016 +write_head_30481 write_head 4 30481 NULL
104017 +adu_write_30487 adu_write 3 30487 NULL
104018 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
104019 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
104020 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
104021 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
104022 +set_le_30581 set_le 4 30581 NULL
104023 +from_cblock_30582 from_cblock 0-1 30582 NULL
104024 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
104025 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
104026 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
104027 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
104028 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
104029 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
104030 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
104031 +agp_remap_30665 agp_remap 2 30665 NULL
104032 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
104033 +il_free_pages_30692 il_free_pages 2 30692 NULL
104034 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
104035 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
104036 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
104037 +snapshot_status_30744 snapshot_status 5 30744 NULL
104038 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
104039 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
104040 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
104041 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
104042 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
104043 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
104044 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
104045 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
104046 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
104047 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
104048 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
104049 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
104050 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
104051 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
104052 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
104053 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
104054 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
104055 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
104056 +sys_mincore_31079 sys_mincore 1 31079 NULL
104057 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
104058 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
104059 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
104060 +depth_read_31112 depth_read 3 31112 NULL
104061 +ssb_read16_31139 ssb_read16 0 31139 NULL
104062 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
104063 +size_inside_page_31141 size_inside_page 0 31141 NULL
104064 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
104065 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
104066 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
104067 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
104068 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
104069 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
104070 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
104071 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
104072 +__read_reg_31216 __read_reg 0 31216 NULL
104073 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
104074 +cyy_readb_31240 cyy_readb 0 31240 NULL
104075 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
104076 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
104077 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
104078 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
104079 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
104080 +command_file_write_31318 command_file_write 3 31318 NULL
104081 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
104082 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
104083 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
104084 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
104085 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
104086 +inb_31388 inb 0 31388 NULL
104087 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
104088 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
104089 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
104090 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
104091 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
104092 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
104093 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
104094 +do_fcntl_31468 do_fcntl 3 31468 NULL
104095 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
104096 +alg_setkey_31485 alg_setkey 3 31485 NULL
104097 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
104098 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
104099 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
104100 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
104101 +hidraw_write_31536 hidraw_write 3 31536 NULL
104102 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
104103 +usbvision_read_31555 usbvision_read 3 31555 NULL
104104 +normalize_31566 normalize 0-1-2 31566 NULL
104105 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
104106 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
104107 +osst_write_31581 osst_write 3 31581 NULL
104108 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
104109 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
104110 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
104111 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
104112 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
104113 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
104114 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
104115 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
104116 +__lgread_31668 __lgread 4 31668 NULL
104117 +symbol_string_31670 symbol_string 0 31670 NULL
104118 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
104119 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
104120 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
104121 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
104122 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
104123 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
104124 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
104125 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
104126 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
104127 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
104128 +muldiv64_31743 muldiv64 2-3 31743 NULL
104129 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
104130 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
104131 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
104132 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
104133 +get_count_order_31800 get_count_order 0 31800 NULL
104134 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
104135 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
104136 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
104137 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
104138 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
104139 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
104140 +xattr_permission_31907 xattr_permission 0 31907 NULL
104141 +new_dir_31919 new_dir 3 31919 NULL
104142 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
104143 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
104144 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
104145 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
104146 +vb2_write_31948 vb2_write 3 31948 NULL
104147 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
104148 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
104149 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
104150 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
104151 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
104152 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
104153 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
104154 +calc_hmac_32010 calc_hmac 3 32010 NULL
104155 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
104156 +aead_len_32021 aead_len 0 32021 NULL
104157 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
104158 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
104159 +stk_read_32038 stk_read 3 32038 NULL
104160 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
104161 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
104162 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
104163 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
104164 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
104165 +bio_alloc_32095 bio_alloc 2 32095 NULL
104166 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
104167 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
104168 +disk_status_32120 disk_status 4 32120 NULL
104169 +venus_link_32165 venus_link 5 32165 NULL
104170 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
104171 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
104172 +load_header_32183 load_header 0 32183 NULL
104173 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
104174 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
104175 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
104176 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
104177 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
104178 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
104179 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
104180 +hex_string_32310 hex_string 0 32310 NULL
104181 +SyS_select_32319 SyS_select 1 32319 NULL
104182 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
104183 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
104184 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
104185 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
104186 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
104187 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
104188 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
104189 +local_clock_32385 local_clock 0 32385 NULL
104190 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
104191 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
104192 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
104193 +log_text_32428 log_text 0 32428 NULL
104194 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
104195 +hid_input_report_32458 hid_input_report 4 32458 NULL
104196 +cache_status_32462 cache_status 5 32462 NULL
104197 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
104198 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
104199 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
104200 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
104201 +disconnect_32521 disconnect 4 32521 NULL
104202 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
104203 +ilo_read_32531 ilo_read 3 32531 NULL
104204 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
104205 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
104206 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
104207 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
104208 +__first_node_32558 __first_node 0 32558 NULL
104209 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
104210 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
104211 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
104212 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
104213 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
104214 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
104215 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
104216 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
104217 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
104218 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
104219 +kvmalloc_32646 kvmalloc 1 32646 NULL
104220 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
104221 +generic_readlink_32654 generic_readlink 3 32654 NULL
104222 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
104223 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
104224 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
104225 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
104226 +get_arg_page_32746 get_arg_page 2 32746 NULL
104227 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
104228 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
104229 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
104230 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
104231 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
104232 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
104233 +vga_rseq_32848 vga_rseq 0 32848 NULL
104234 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
104235 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
104236 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
104237 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
104238 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
104239 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
104240 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
104241 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
104242 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
104243 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
104244 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
104245 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
104246 +compat_filldir_32999 compat_filldir 3 32999 NULL
104247 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
104248 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
104249 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
104250 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
104251 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
104252 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
104253 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
104254 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
104255 +alloc_tio_33077 alloc_tio 3 33077 NULL
104256 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
104257 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
104258 +write_node_33121 write_node 4 33121 NULL
104259 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
104260 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
104261 +__len_within_target_33132 __len_within_target 0 33132 NULL
104262 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
104263 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
104264 +pp_read_33210 pp_read 3 33210 NULL
104265 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
104266 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
104267 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
104268 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
104269 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
104270 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
104271 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
104272 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
104273 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
104274 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
104275 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
104276 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
104277 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
104278 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
104279 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
104280 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
104281 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
104282 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
104283 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
104284 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
104285 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
104286 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
104287 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
104288 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
104289 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
104290 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
104291 +create_entry_33479 create_entry 2 33479 NULL
104292 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
104293 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
104294 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
104295 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
104296 +res_counter_read_33499 res_counter_read 4 33499 NULL
104297 +fb_read_33506 fb_read 3 33506 NULL
104298 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
104299 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
104300 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
104301 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
104302 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
104303 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
104304 +dup_array_33551 dup_array 3 33551 NULL
104305 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
104306 +count_subheaders_33591 count_subheaders 0 33591 NULL
104307 +scsi_execute_33596 scsi_execute 5 33596 NULL
104308 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
104309 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
104310 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
104311 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
104312 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
104313 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
104314 +inw_p_33668 inw_p 0 33668 NULL
104315 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
104316 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
104317 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
104318 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
104319 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
104320 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
104321 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
104322 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
104323 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
104324 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
104325 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
104326 +Read_hfc_33755 Read_hfc 0 33755 NULL
104327 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
104328 +hashtab_create_33769 hashtab_create 3 33769 NULL
104329 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
104330 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
104331 +find_next_offset_33804 find_next_offset 3 33804 NULL
104332 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
104333 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
104334 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
104335 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
104336 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
104337 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
104338 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
104339 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
104340 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
104341 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
104342 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
104343 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
104344 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
104345 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
104346 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
104347 +ppp_write_34034 ppp_write 3 34034 NULL
104348 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
104349 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
104350 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
104351 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
104352 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
104353 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
104354 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
104355 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
104356 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
104357 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
104358 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
104359 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
104360 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
104361 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
104362 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
104363 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
104364 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
104365 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
104366 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
104367 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
104368 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
104369 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
104370 +__insert_34349 __insert 2-3 34349 NULL
104371 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
104372 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
104373 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
104374 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
104375 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
104376 +ea_read_34378 ea_read 0 34378 NULL
104377 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
104378 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
104379 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
104380 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
104381 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
104382 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
104383 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
104384 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
104385 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
104386 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
104387 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
104388 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
104389 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
104390 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
104391 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
104392 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
104393 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
104394 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
104395 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
104396 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
104397 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
104398 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
104399 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
104400 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
104401 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
104402 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
104403 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
104404 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
104405 +port_print_34704 port_print 3 34704 NULL
104406 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
104407 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
104408 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
104409 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
104410 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
104411 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
104412 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
104413 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
104414 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
104415 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
104416 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
104417 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
104418 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
104419 +msg_print_text_34889 msg_print_text 0 34889 NULL
104420 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
104421 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
104422 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
104423 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
104424 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
104425 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
104426 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
104427 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
104428 +Realloc_34961 Realloc 2 34961 NULL
104429 +mq_lookup_34990 mq_lookup 2 34990 NULL
104430 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
104431 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
104432 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
104433 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
104434 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
104435 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
104436 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
104437 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
104438 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
104439 +store_ifalias_35088 store_ifalias 4 35088 NULL
104440 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
104441 +capi_write_35104 capi_write 3 35104 NULL nohasharray
104442 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
104443 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
104444 +pointer_35138 pointer 0 35138 NULL
104445 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
104446 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
104447 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
104448 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
104449 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
104450 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
104451 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
104452 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
104453 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
104454 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
104455 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
104456 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
104457 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
104458 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
104459 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
104460 +set_fd_set_35249 set_fd_set 1 35249 NULL
104461 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
104462 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
104463 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
104464 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
104465 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
104466 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
104467 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
104468 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
104469 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
104470 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
104471 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
104472 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
104473 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
104474 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
104475 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
104476 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
104477 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
104478 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
104479 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
104480 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
104481 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
104482 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
104483 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
104484 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
104485 +async_setkey_35521 async_setkey 3 35521 NULL
104486 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
104487 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
104488 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
104489 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
104490 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
104491 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
104492 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
104493 +ReadZReg_35604 ReadZReg 0 35604 NULL
104494 +kernel_readv_35617 kernel_readv 3 35617 NULL
104495 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
104496 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
104497 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
104498 +store_debug_level_35652 store_debug_level 3 35652 NULL
104499 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
104500 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
104501 +dm_table_create_35687 dm_table_create 3 35687 NULL
104502 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
104503 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
104504 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
104505 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
104506 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
104507 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
104508 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
104509 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
104510 +fls64_35862 fls64 0 35862 NULL
104511 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
104512 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
104513 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
104514 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
104515 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
104516 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
104517 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
104518 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
104519 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
104520 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
104521 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
104522 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
104523 +acl_alloc_35979 acl_alloc 1 35979 NULL
104524 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
104525 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
104526 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
104527 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
104528 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
104529 +account_shadowed_36048 account_shadowed 2 36048 NULL
104530 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
104531 +write_emulate_36065 write_emulate 2-4 36065 NULL
104532 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
104533 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
104534 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
104535 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
104536 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
104537 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
104538 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
104539 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
104540 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
104541 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
104542 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
104543 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
104544 +twl_set_36154 twl_set 2 36154 NULL
104545 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
104546 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
104547 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
104548 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
104549 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
104550 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
104551 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
104552 +is_dirty_36223 is_dirty 2 36223 NULL
104553 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
104554 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
104555 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
104556 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
104557 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
104558 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
104559 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
104560 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
104561 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
104562 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
104563 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
104564 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
104565 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
104566 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
104567 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
104568 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
104569 +lc_create_36332 lc_create 4 36332 NULL
104570 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
104571 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
104572 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
104573 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
104574 +to_sector_36361 to_sector 0-1 36361 NULL
104575 +tunables_read_36385 tunables_read 3 36385 NULL
104576 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
104577 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
104578 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
104579 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
104580 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
104581 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
104582 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
104583 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
104584 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
104585 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
104586 +get_param_l_36518 get_param_l 0 36518 NULL
104587 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
104588 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
104589 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
104590 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
104591 +get_entry_len_36549 get_entry_len 0 36549 NULL
104592 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
104593 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
104594 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
104595 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
104596 +__erst_read_36579 __erst_read 0 36579 NULL
104597 +put_cmsg_36589 put_cmsg 4 36589 NULL
104598 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
104599 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
104600 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
104601 +format_decode_36638 format_decode 0 36638 NULL
104602 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
104603 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
104604 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
104605 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
104606 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
104607 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
104608 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
104609 +sched_clock_36717 sched_clock 0 36717 NULL
104610 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
104611 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
104612 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
104613 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
104614 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
104615 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
104616 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
104617 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
104618 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
104619 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
104620 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
104621 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
104622 +cm_write_36858 cm_write 3 36858 NULL
104623 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
104624 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
104625 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
104626 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
104627 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
104628 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
104629 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
104630 +build_key_36931 build_key 1 36931 NULL
104631 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
104632 +write_leb_36957 write_leb 5 36957 NULL
104633 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
104634 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
104635 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
104636 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
104637 +setxattr_37006 setxattr 4 37006 NULL
104638 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
104639 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
104640 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
104641 +parse_command_37079 parse_command 2 37079 NULL
104642 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
104643 +tun_get_user_37094 tun_get_user 5 37094 NULL
104644 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
104645 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
104646 +msg_word_37164 msg_word 0 37164 NULL
104647 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
104648 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
104649 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
104650 +__do_replace_37227 __do_replace 5 37227 NULL
104651 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
104652 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
104653 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
104654 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
104655 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
104656 +c101_run_37279 c101_run 2 37279 NULL
104657 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
104658 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
104659 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
104660 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
104661 +send_msg_37323 send_msg 4 37323 NULL
104662 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
104663 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
104664 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
104665 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
104666 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
104667 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
104668 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
104669 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
104670 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
104671 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
104672 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
104673 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
104674 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
104675 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
104676 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
104677 +__remove_37457 __remove 2 37457 NULL
104678 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
104679 +get_est_timing_37484 get_est_timing 0 37484 NULL
104680 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
104681 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
104682 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
104683 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
104684 +hdr_size_37536 hdr_size 0 37536 NULL
104685 +a2p_37544 a2p 0-1 37544 NULL
104686 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
104687 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
104688 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
104689 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
104690 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
104691 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
104692 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
104693 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
104694 +check_pt_base_37635 check_pt_base 3 37635 NULL
104695 +alloc_fd_37637 alloc_fd 1 37637 NULL
104696 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
104697 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
104698 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
104699 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
104700 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
104701 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
104702 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
104703 +nametbl_header_37698 nametbl_header 2 37698 NULL
104704 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
104705 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
104706 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
104707 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
104708 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
104709 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
104710 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
104711 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
104712 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
104713 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
104714 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
104715 +deny_write_access_37813 deny_write_access 0 37813 NULL
104716 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
104717 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
104718 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
104719 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
104720 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
104721 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
104722 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
104723 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
104724 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
104725 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
104726 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
104727 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
104728 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
104729 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
104730 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
104731 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
104732 +vfs_readv_38011 vfs_readv 3 38011 NULL
104733 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
104734 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
104735 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
104736 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
104737 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
104738 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
104739 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
104740 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
104741 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
104742 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
104743 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
104744 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
104745 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
104746 +ep0_read_38095 ep0_read 3 38095 NULL
104747 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
104748 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
104749 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
104750 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
104751 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
104752 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
104753 +cdev_add_38176 cdev_add 2-3 38176 NULL
104754 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
104755 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
104756 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
104757 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
104758 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
104759 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
104760 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
104761 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
104762 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
104763 +from_dblock_38256 from_dblock 0-1 38256 NULL
104764 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
104765 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
104766 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
104767 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
104768 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
104769 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
104770 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
104771 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
104772 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
104773 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
104774 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
104775 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
104776 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
104777 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
104778 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
104779 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
104780 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
104781 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
104782 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
104783 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
104784 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
104785 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
104786 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
104787 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
104788 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
104789 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
104790 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
104791 +dev_names_read_38509 dev_names_read 3 38509 NULL
104792 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
104793 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
104794 +set_queue_count_38519 set_queue_count 0 38519 NULL
104795 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
104796 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
104797 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
104798 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
104799 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
104800 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
104801 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
104802 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
104803 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
104804 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
104805 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
104806 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
104807 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
104808 +cma_create_area_38642 cma_create_area 2 38642 NULL
104809 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
104810 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
104811 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
104812 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
104813 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
104814 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
104815 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
104816 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
104817 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
104818 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
104819 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
104820 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
104821 +udf_readpages_38761 udf_readpages 4 38761 NULL
104822 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
104823 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
104824 +err_decode_38804 err_decode 2 38804 NULL
104825 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
104826 +sys_select_38827 sys_select 1 38827 NULL
104827 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
104828 +direct_entry_38836 direct_entry 3 38836 NULL
104829 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
104830 +interfaces_38859 interfaces 2 38859 NULL
104831 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
104832 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
104833 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
104834 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
104835 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
104836 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
104837 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
104838 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
104839 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
104840 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
104841 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
104842 +udf_new_block_38999 udf_new_block 4 38999 NULL
104843 +get_nodes_39012 get_nodes 3 39012 NULL
104844 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
104845 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
104846 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
104847 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
104848 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
104849 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
104850 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
104851 +ea_foreach_39133 ea_foreach 0 39133 NULL
104852 +generic_permission_39150 generic_permission 0 39150 NULL
104853 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
104854 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
104855 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
104856 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
104857 +init_list_set_39188 init_list_set 2-3 39188 NULL
104858 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
104859 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
104860 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
104861 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
104862 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
104863 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
104864 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
104865 +drm_order_39244 drm_order 0 39244 NULL
104866 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
104867 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
104868 +__skb_cow_39254 __skb_cow 2 39254 NULL
104869 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
104870 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
104871 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
104872 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
104873 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
104874 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
104875 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
104876 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
104877 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
104878 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
104879 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
104880 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
104881 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
104882 +__send_to_port_39386 __send_to_port 3 39386 NULL
104883 +user_power_read_39414 user_power_read 3 39414 NULL
104884 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
104885 +sys_semop_39457 sys_semop 3 39457 NULL
104886 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
104887 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
104888 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
104889 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
104890 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
104891 +int_proc_write_39542 int_proc_write 3 39542 NULL
104892 +pp_write_39554 pp_write 3 39554 NULL
104893 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
104894 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
104895 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
104896 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
104897 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
104898 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
104899 +ext_depth_39607 ext_depth 0 39607 NULL
104900 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
104901 +sdio_readb_39618 sdio_readb 0 39618 NULL
104902 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
104903 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
104904 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
104905 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
104906 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
104907 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
104908 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
104909 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
104910 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
104911 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
104912 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
104913 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
104914 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
104915 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
104916 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
104917 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
104918 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
104919 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
104920 +pkt_add_39897 pkt_add 3 39897 NULL
104921 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
104922 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
104923 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
104924 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
104925 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
104926 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
104927 +__spi_async_39932 __spi_async 0 39932 NULL
104928 +__get_order_39935 __get_order 0 39935 NULL
104929 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
104930 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
104931 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
104932 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
104933 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
104934 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
104935 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
104936 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
104937 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
104938 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
104939 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
104940 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
104941 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
104942 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
104943 +add_tty_40055 add_tty 1 40055 NULL nohasharray
104944 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
104945 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
104946 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
104947 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
104948 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
104949 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
104950 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
104951 +pt_write_40159 pt_write 3 40159 NULL
104952 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
104953 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
104954 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
104955 +allocate_probes_40204 allocate_probes 1 40204 NULL
104956 +compat_put_long_40214 compat_put_long 1 40214 NULL
104957 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
104958 +osst_read_40237 osst_read 3 40237 NULL
104959 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
104960 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
104961 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
104962 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
104963 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
104964 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
104965 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
104966 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
104967 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
104968 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
104969 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
104970 +mmio_read_40348 mmio_read 4 40348 NULL
104971 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
104972 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
104973 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
104974 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
104975 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
104976 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
104977 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
104978 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
104979 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
104980 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
104981 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
104982 +tty_write_room_40495 tty_write_room 0 40495 NULL
104983 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
104984 +sg_phys_40507 sg_phys 0 40507 NULL
104985 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
104986 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
104987 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
104988 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
104989 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
104990 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
104991 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
104992 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
104993 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
104994 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
104995 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
104996 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
104997 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
104998 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
104999 +fops_read_40672 fops_read 3 40672 NULL
105000 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
105001 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
105002 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
105003 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
105004 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
105005 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
105006 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
105007 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
105008 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
105009 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
105010 +card_send_command_40757 card_send_command 3 40757 NULL
105011 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
105012 +pg_write_40766 pg_write 3 40766 NULL
105013 +show_list_40775 show_list 3 40775 NULL
105014 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
105015 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
105016 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
105017 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
105018 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
105019 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
105020 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
105021 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
105022 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
105023 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
105024 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
105025 +read_file_queue_40895 read_file_queue 3 40895 NULL
105026 +waiters_read_40902 waiters_read 3 40902 NULL
105027 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
105028 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
105029 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
105030 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
105031 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
105032 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
105033 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
105034 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
105035 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
105036 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
105037 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
105038 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
105039 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
105040 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
105041 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
105042 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
105043 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
105044 +dma_attach_41094 dma_attach 5-6 41094 NULL
105045 +provide_user_output_41105 provide_user_output 3 41105 NULL
105046 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
105047 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
105048 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
105049 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
105050 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
105051 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
105052 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
105053 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
105054 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
105055 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
105056 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
105057 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
105058 +erst_read_41260 erst_read 0 41260 NULL
105059 +__fprog_create_41263 __fprog_create 2 41263 NULL
105060 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
105061 +alloc_context_41283 alloc_context 1 41283 NULL
105062 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
105063 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
105064 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
105065 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
105066 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
105067 +kmp_init_41373 kmp_init 2 41373 NULL
105068 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
105069 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
105070 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
105071 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
105072 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
105073 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
105074 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
105075 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
105076 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
105077 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
105078 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
105079 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
105080 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
105081 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
105082 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
105083 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
105084 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
105085 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
105086 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
105087 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
105088 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
105089 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
105090 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
105091 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
105092 +vga_io_r_41609 vga_io_r 0 41609 NULL
105093 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
105094 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
105095 +a2mp_send_41615 a2mp_send 4 41615 NULL
105096 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
105097 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
105098 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
105099 +get_std_timing_41654 get_std_timing 0 41654 NULL
105100 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
105101 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
105102 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
105103 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
105104 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
105105 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
105106 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
105107 +fillonedir_41746 fillonedir 3 41746 NULL
105108 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
105109 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
105110 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
105111 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
105112 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
105113 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
105114 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
105115 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
105116 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
105117 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
105118 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
105119 +get_packet_41914 get_packet 3 41914 NULL
105120 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
105121 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
105122 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
105123 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
105124 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
105125 +read_gssp_41947 read_gssp 3 41947 NULL
105126 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
105127 +portnames_read_41958 portnames_read 3 41958 NULL
105128 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
105129 +dst_mtu_41969 dst_mtu 0 41969 NULL
105130 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
105131 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
105132 +lguest_map_42008 lguest_map 1-2 42008 NULL
105133 +pool_allocate_42012 pool_allocate 3 42012 NULL
105134 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
105135 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
105136 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
105137 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
105138 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
105139 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
105140 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
105141 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
105142 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
105143 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
105144 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
105145 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
105146 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
105147 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
105148 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
105149 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
105150 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
105151 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
105152 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
105153 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
105154 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
105155 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
105156 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
105157 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
105158 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
105159 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
105160 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
105161 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
105162 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
105163 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
105164 +free_cblock_42318 free_cblock 2 42318 NULL
105165 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
105166 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
105167 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
105168 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
105169 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
105170 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
105171 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
105172 +krng_get_random_42420 krng_get_random 3 42420 NULL
105173 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
105174 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
105175 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
105176 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
105177 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
105178 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
105179 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
105180 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
105181 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
105182 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
105183 +bypass_write_42498 bypass_write 3 42498 NULL
105184 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
105185 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
105186 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
105187 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
105188 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
105189 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
105190 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
105191 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
105192 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
105193 +map_state_42602 map_state 1 42602 NULL nohasharray
105194 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
105195 +nd_get_link_42603 nd_get_link 0 42603 NULL
105196 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
105197 +resp_write_42628 resp_write 2 42628 NULL
105198 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
105199 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
105200 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
105201 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
105202 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
105203 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
105204 +vb2_read_42703 vb2_read 3 42703 NULL
105205 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
105206 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
105207 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
105208 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
105209 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
105210 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
105211 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
105212 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
105213 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
105214 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
105215 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
105216 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
105217 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
105218 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
105219 +set_arg_42824 set_arg 3 42824 NULL
105220 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
105221 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
105222 +prandom_u32_42853 prandom_u32 0 42853 NULL
105223 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
105224 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
105225 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
105226 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
105227 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
105228 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
105229 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
105230 +hd_end_request_42904 hd_end_request 2 42904 NULL
105231 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
105232 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
105233 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
105234 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
105235 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
105236 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
105237 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
105238 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
105239 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
105240 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
105241 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
105242 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
105243 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
105244 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
105245 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
105246 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
105247 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
105248 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
105249 +uuid_string_43154 uuid_string 0 43154 NULL
105250 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
105251 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
105252 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
105253 +process_measurement_43190 process_measurement 0 43190 NULL
105254 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
105255 +uio_write_43202 uio_write 3 43202 NULL
105256 +iso_callback_43208 iso_callback 3 43208 NULL
105257 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
105258 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
105259 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
105260 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
105261 +fixup_leb_43256 fixup_leb 3 43256 NULL
105262 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
105263 +evtchn_write_43278 evtchn_write 3 43278 NULL
105264 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
105265 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
105266 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
105267 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
105268 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
105269 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
105270 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
105271 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
105272 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
105273 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
105274 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
105275 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
105276 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
105277 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
105278 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
105279 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
105280 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
105281 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
105282 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
105283 +do_readlink_43518 do_readlink 2 43518 NULL
105284 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
105285 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
105286 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
105287 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
105288 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
105289 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
105290 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
105291 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
105292 +proc_read_43614 proc_read 3 43614 NULL
105293 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
105294 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
105295 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
105296 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
105297 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
105298 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
105299 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
105300 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
105301 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
105302 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
105303 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
105304 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
105305 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
105306 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
105307 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
105308 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
105309 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
105310 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
105311 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
105312 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
105313 +read_flush_43851 read_flush 3 43851 NULL
105314 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
105315 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
105316 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
105317 +SendString_43928 SendString 3 43928 NULL
105318 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
105319 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
105320 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
105321 +nla_reserve_43984 nla_reserve 3 43984 NULL
105322 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
105323 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
105324 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
105325 +emit_flags_44006 emit_flags 4-3 44006 NULL
105326 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
105327 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
105328 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
105329 +load_discard_44083 load_discard 3 44083 NULL
105330 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
105331 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
105332 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
105333 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
105334 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
105335 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
105336 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
105337 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
105338 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
105339 +__set_free_44211 __set_free 2 44211 NULL
105340 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
105341 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
105342 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
105343 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
105344 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
105345 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
105346 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
105347 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
105348 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
105349 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
105350 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
105351 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
105352 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
105353 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
105354 +__is_discarded_44359 __is_discarded 2 44359 NULL
105355 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
105356 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
105357 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
105358 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
105359 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
105360 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
105361 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
105362 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
105363 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
105364 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
105365 +bio_advance_44496 bio_advance 2 44496 NULL
105366 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
105367 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
105368 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
105369 +spidev_write_44510 spidev_write 3 44510 NULL
105370 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
105371 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
105372 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
105373 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
105374 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
105375 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
105376 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
105377 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
105378 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
105379 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
105380 +mpi_resize_44674 mpi_resize 2 44674 NULL
105381 +ts_read_44687 ts_read 3 44687 NULL
105382 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
105383 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
105384 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
105385 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
105386 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
105387 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
105388 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
105389 +set_brk_44749 set_brk 1 44749 NULL
105390 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
105391 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
105392 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
105393 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
105394 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
105395 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
105396 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
105397 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
105398 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
105399 +sisusb_write_44834 sisusb_write 3 44834 NULL
105400 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
105401 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
105402 +cubic_root_44848 cubic_root 1 44848 NULL
105403 +copydesc_user_44855 copydesc_user 3 44855 NULL
105404 +skb_availroom_44883 skb_availroom 0 44883 NULL
105405 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
105406 +do_tty_write_44896 do_tty_write 5 44896 NULL
105407 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
105408 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
105409 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
105410 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
105411 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
105412 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
105413 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
105414 +sel_write_user_45060 sel_write_user 3 45060 NULL
105415 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
105416 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
105417 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
105418 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
105419 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
105420 +usbdev_read_45114 usbdev_read 3 45114 NULL
105421 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
105422 +send_to_tty_45141 send_to_tty 3 45141 NULL
105423 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
105424 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
105425 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
105426 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
105427 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
105428 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
105429 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
105430 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
105431 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
105432 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
105433 +add_child_45201 add_child 4 45201 NULL
105434 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
105435 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
105436 +__dirty_45228 __dirty 2 45228 NULL
105437 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
105438 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
105439 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
105440 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
105441 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
105442 +pte_val_45313 pte_val 0 45313 NULL
105443 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
105444 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
105445 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
105446 +keymap_store_45406 keymap_store 4 45406 NULL
105447 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
105448 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
105449 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
105450 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
105451 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
105452 +__node_remap_45458 __node_remap 4 45458 NULL
105453 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
105454 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
105455 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
105456 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
105457 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
105458 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
105459 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
105460 +copy_macs_45534 copy_macs 4 45534 NULL
105461 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
105462 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
105463 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
105464 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
105465 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
105466 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
105467 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
105468 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
105469 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
105470 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
105471 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
105472 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
105473 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
105474 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
105475 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
105476 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
105477 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
105478 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
105479 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
105480 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
105481 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
105482 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
105483 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
105484 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
105485 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
105486 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
105487 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
105488 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
105489 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
105490 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
105491 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
105492 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
105493 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
105494 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
105495 +isdn_write_45863 isdn_write 3 45863 NULL
105496 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
105497 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
105498 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
105499 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
105500 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
105501 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
105502 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
105503 +alloc_mr_45935 alloc_mr 1 45935 NULL
105504 +split_large_page_45941 split_large_page 2 45941 NULL
105505 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
105506 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
105507 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
105508 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
105509 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
105510 +get_free_entries_46030 get_free_entries 1 46030 NULL
105511 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
105512 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
105513 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
105514 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
105515 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
105516 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
105517 +slhc_toss_46066 slhc_toss 0 46066 NULL
105518 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
105519 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
105520 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
105521 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
105522 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
105523 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
105524 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
105525 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
105526 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
105527 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
105528 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
105529 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
105530 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
105531 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
105532 +add_conn_list_46197 add_conn_list 3 46197 NULL
105533 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
105534 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
105535 +dsp_write_46218 dsp_write 2 46218 NULL
105536 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
105537 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
105538 +ReadReg_46277 ReadReg 0 46277 NULL
105539 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
105540 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
105541 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
105542 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
105543 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
105544 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
105545 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
105546 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
105547 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
105548 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
105549 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
105550 +filldir64_46469 filldir64 3 46469 NULL
105551 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
105552 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
105553 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
105554 +kmsg_read_46514 kmsg_read 3 46514 NULL
105555 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
105556 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
105557 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
105558 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
105559 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
105560 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
105561 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
105562 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
105563 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
105564 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
105565 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
105566 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
105567 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
105568 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
105569 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
105570 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
105571 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
105572 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
105573 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
105574 +prepare_copy_46725 prepare_copy 2 46725 NULL
105575 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
105576 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
105577 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
105578 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
105579 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
105580 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
105581 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
105582 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
105583 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
105584 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
105585 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
105586 +spi_async_46857 spi_async 0 46857 NULL
105587 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
105588 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
105589 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
105590 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
105591 +rvmalloc_46873 rvmalloc 1 46873 NULL
105592 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
105593 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
105594 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
105595 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
105596 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
105597 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
105598 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
105599 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
105600 +fb_write_46924 fb_write 3 46924 NULL
105601 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
105602 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
105603 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
105604 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
105605 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
105606 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
105607 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
105608 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
105609 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
105610 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
105611 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
105612 +__map_single_47020 __map_single 3-4-7 47020 NULL
105613 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
105614 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
105615 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
105616 +fs_path_len_47060 fs_path_len 0 47060 NULL
105617 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
105618 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
105619 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
105620 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
105621 +mousedev_read_47123 mousedev_read 3 47123 NULL
105622 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
105623 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
105624 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
105625 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
105626 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
105627 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
105628 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
105629 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
105630 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
105631 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
105632 +l2headersize_47238 l2headersize 0 47238 NULL
105633 +options_write_47243 options_write 3 47243 NULL
105634 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
105635 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
105636 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
105637 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
105638 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
105639 +vsnprintf_47291 vsnprintf 0 47291 NULL
105640 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
105641 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
105642 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
105643 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
105644 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
105645 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
105646 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
105647 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
105648 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
105649 +nametbl_list_47391 nametbl_list 2 47391 NULL
105650 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
105651 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
105652 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
105653 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
105654 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
105655 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
105656 +vzalloc_47421 vzalloc 1 47421 NULL
105657 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
105658 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
105659 +__load_mapping_47460 __load_mapping 2 47460 NULL
105660 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
105661 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
105662 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
105663 +core_sys_select_47494 core_sys_select 1 47494 NULL
105664 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
105665 +unlink_simple_47506 unlink_simple 3 47506 NULL
105666 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
105667 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
105668 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
105669 +oz_events_read_47535 oz_events_read 3 47535 NULL
105670 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
105671 +read_ldt_47570 read_ldt 2 47570 NULL
105672 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
105673 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
105674 +pci_iomap_47575 pci_iomap 3 47575 NULL
105675 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
105676 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
105677 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
105678 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
105679 +uea_request_47613 uea_request 4 47613 NULL
105680 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
105681 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
105682 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
105683 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
105684 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
105685 +save_microcode_47717 save_microcode 3 47717 NULL
105686 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
105687 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
105688 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
105689 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
105690 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
105691 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
105692 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
105693 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
105694 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
105695 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
105696 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
105697 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
105698 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
105699 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
105700 +vhci_read_47878 vhci_read 3 47878 NULL
105701 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
105702 +load_mapping_47904 load_mapping 3 47904 NULL
105703 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
105704 +comedi_write_47926 comedi_write 3 47926 NULL
105705 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
105706 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
105707 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
105708 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
105709 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
105710 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
105711 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
105712 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
105713 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
105714 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
105715 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
105716 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
105717 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
105718 +disc_write_48070 disc_write 3 48070 NULL
105719 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
105720 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
105721 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
105722 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
105723 +set_discoverable_48141 set_discoverable 4 48141 NULL
105724 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
105725 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
105726 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
105727 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
105728 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
105729 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
105730 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
105731 +init_ipath_48187 init_ipath 1 48187 NULL
105732 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
105733 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
105734 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
105735 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
105736 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
105737 +read_file_recv_48232 read_file_recv 3 48232 NULL
105738 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
105739 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
105740 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
105741 +send_set_info_48288 send_set_info 7 48288 NULL
105742 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
105743 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
105744 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
105745 +hash_setkey_48310 hash_setkey 3 48310 NULL
105746 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
105747 +skb_add_data_48363 skb_add_data 3 48363 NULL
105748 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
105749 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
105750 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
105751 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
105752 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
105753 +print_filtered_48442 print_filtered 2-0 48442 NULL
105754 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
105755 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
105756 +send_control_msg_48498 send_control_msg 6 48498 NULL
105757 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
105758 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
105759 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
105760 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
105761 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
105762 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
105763 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
105764 +named_distribute_48544 named_distribute 4 48544 NULL
105765 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
105766 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
105767 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
105768 +mtd_read_48655 mtd_read 0 48655 NULL
105769 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
105770 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
105771 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
105772 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
105773 +altera_drscan_48698 altera_drscan 2 48698 NULL
105774 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
105775 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
105776 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
105777 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
105778 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
105779 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
105780 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
105781 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
105782 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
105783 +azx_get_position_48841 azx_get_position 0 48841 NULL
105784 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
105785 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
105786 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
105787 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
105788 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
105789 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
105790 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
105791 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
105792 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
105793 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
105794 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
105795 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
105796 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
105797 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
105798 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
105799 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
105800 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
105801 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
105802 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
105803 +transient_status_49027 transient_status 4 49027 NULL
105804 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
105805 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
105806 +ubi_read_49061 ubi_read 0 49061 NULL
105807 +scsi_register_49094 scsi_register 2 49094 NULL
105808 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
105809 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
105810 +check_exists_49119 check_exists 2 49119 NULL nohasharray
105811 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
105812 +pt_read_49136 pt_read 3 49136 NULL
105813 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
105814 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
105815 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
105816 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
105817 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
105818 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
105819 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
105820 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
105821 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
105822 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
105823 +resp_write_same_49217 resp_write_same 2 49217 NULL
105824 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
105825 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
105826 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
105827 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
105828 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
105829 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
105830 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
105831 +uio_read_49300 uio_read 3 49300 NULL
105832 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
105833 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
105834 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
105835 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
105836 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
105837 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
105838 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
105839 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
105840 +px_raw_event_49371 px_raw_event 4 49371 NULL
105841 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
105842 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
105843 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
105844 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
105845 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
105846 +md_domain_init_49432 md_domain_init 2 49432 NULL
105847 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
105848 +get_lru_size_49441 get_lru_size 0 49441 NULL
105849 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
105850 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
105851 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
105852 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
105853 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
105854 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
105855 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
105856 +smk_write_access_49561 smk_write_access 3 49561 NULL
105857 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
105858 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
105859 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
105860 +tap_write_49595 tap_write 3 49595 NULL
105861 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
105862 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
105863 +heap_init_49617 heap_init 2 49617 NULL
105864 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
105865 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
105866 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
105867 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
105868 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
105869 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
105870 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
105871 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
105872 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
105873 +check_frame_49741 check_frame 0 49741 NULL
105874 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
105875 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
105876 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
105877 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
105878 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
105879 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
105880 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
105881 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
105882 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
105883 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
105884 +add_uuid_49831 add_uuid 4 49831 NULL
105885 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
105886 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
105887 +twl4030_write_49846 twl4030_write 2 49846 NULL
105888 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
105889 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
105890 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
105891 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
105892 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
105893 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
105894 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
105895 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
105896 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
105897 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
105898 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
105899 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
105900 +__module_alloc_50004 __module_alloc 1 50004 NULL
105901 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
105902 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
105903 +isdn_read_50021 isdn_read 3 50021 NULL
105904 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
105905 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
105906 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
105907 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
105908 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
105909 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
105910 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
105911 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
105912 +read_file_slot_50111 read_file_slot 3 50111 NULL
105913 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
105914 +copy_items_50140 copy_items 6 50140 NULL
105915 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
105916 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
105917 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
105918 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
105919 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
105920 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
105921 +odev_update_50169 odev_update 2 50169 NULL
105922 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
105923 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
105924 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
105925 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
105926 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
105927 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
105928 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
105929 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
105930 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
105931 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
105932 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
105933 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
105934 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
105935 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
105936 +do_launder_page_50329 do_launder_page 0 50329 NULL
105937 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
105938 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
105939 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
105940 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
105941 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
105942 +tpm_read_50344 tpm_read 3 50344 NULL
105943 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
105944 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
105945 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
105946 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
105947 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
105948 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
105949 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
105950 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
105951 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
105952 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
105953 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
105954 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
105955 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
105956 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
105957 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
105958 +force_mapping_50464 force_mapping 2 50464 NULL
105959 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
105960 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
105961 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
105962 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
105963 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
105964 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
105965 +fat_readpages_50582 fat_readpages 4 50582 NULL
105966 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
105967 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
105968 +sge_rx_50594 sge_rx 3 50594 NULL
105969 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
105970 +__ffs_50625 __ffs 0 50625 NULL
105971 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
105972 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
105973 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
105974 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
105975 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
105976 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
105977 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
105978 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
105979 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
105980 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
105981 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
105982 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
105983 +skb_padto_50759 skb_padto 2 50759 NULL
105984 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
105985 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
105986 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
105987 +tpm_write_50798 tpm_write 3 50798 NULL
105988 +write_flush_50803 write_flush 3 50803 NULL
105989 +dvb_play_50814 dvb_play 3 50814 NULL
105990 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
105991 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
105992 +SetArea_50835 SetArea 4 50835 NULL nohasharray
105993 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
105994 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
105995 +self_check_write_50856 self_check_write 5 50856 NULL
105996 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
105997 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
105998 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
105999 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
106000 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
106001 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
106002 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
106003 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
106004 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
106005 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
106006 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
106007 +timeout_write_50991 timeout_write 3 50991 NULL
106008 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
106009 +proc_write_51003 proc_write 3 51003 NULL
106010 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
106011 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
106012 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
106013 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
106014 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
106015 +dump_midi_51040 dump_midi 3 51040 NULL
106016 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
106017 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
106018 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
106019 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
106020 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
106021 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
106022 +ti_recv_51110 ti_recv 3 51110 NULL
106023 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
106024 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
106025 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
106026 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
106027 +set_dirty_51144 set_dirty 3 51144 NULL
106028 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
106029 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
106030 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
106031 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
106032 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
106033 +tipc_send_51238 tipc_send 4 51238 NULL
106034 +drm_property_create_51239 drm_property_create 4 51239 NULL
106035 +st_read_51251 st_read 3 51251 NULL
106036 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
106037 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
106038 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
106039 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
106040 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
106041 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
106042 +get_cell_51316 get_cell 2 51316 NULL
106043 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
106044 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
106045 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
106046 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
106047 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
106048 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
106049 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
106050 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
106051 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
106052 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
106053 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
106054 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
106055 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
106056 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
106057 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
106058 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
106059 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
106060 +vaddr_51480 vaddr 0 51480 NULL
106061 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
106062 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
106063 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
106064 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
106065 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
106066 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
106067 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
106068 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
106069 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
106070 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
106071 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
106072 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
106073 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
106074 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
106075 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
106076 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
106077 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
106078 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
106079 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
106080 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
106081 +sel_write_access_51704 sel_write_access 3 51704 NULL
106082 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
106083 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
106084 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
106085 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
106086 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
106087 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
106088 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
106089 +if_write_51756 if_write 3 51756 NULL
106090 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
106091 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
106092 +to_ratio_51809 to_ratio 2-1 51809 NULL
106093 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
106094 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
106095 +ioread32_51847 ioread32 0 51847 NULL nohasharray
106096 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
106097 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
106098 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
106099 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
106100 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
106101 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
106102 +user_read_51881 user_read 3 51881 NULL
106103 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
106104 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
106105 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
106106 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
106107 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
106108 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
106109 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
106110 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
106111 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
106112 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
106113 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
106114 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
106115 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
106116 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
106117 +rdmalt_52022 rdmalt 0 52022 NULL
106118 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
106119 +override_release_52032 override_release 2 52032 NULL
106120 +end_port_52042 end_port 0 52042 NULL
106121 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
106122 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
106123 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
106124 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
106125 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
106126 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
106127 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
106128 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
106129 +retry_count_read_52129 retry_count_read 3 52129 NULL
106130 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
106131 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
106132 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
106133 +htable_size_52148 htable_size 0-1 52148 NULL
106134 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
106135 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
106136 +alix_present_52165 alix_present 1 52165 NULL
106137 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
106138 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
106139 +print_prefix_52176 print_prefix 0 52176 NULL
106140 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
106141 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
106142 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
106143 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
106144 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
106145 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
106146 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
106147 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
106148 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
106149 +atomic64_read_52300 atomic64_read 0 52300 NULL
106150 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
106151 +read_file_reset_52310 read_file_reset 3 52310 NULL
106152 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
106153 +hwflags_read_52318 hwflags_read 3 52318 NULL
106154 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
106155 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
106156 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
106157 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
106158 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
106159 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
106160 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
106161 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
106162 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
106163 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
106164 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
106165 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
106166 +delay_status_52431 delay_status 5 52431 NULL
106167 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
106168 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
106169 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
106170 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
106171 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
106172 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
106173 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
106174 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
106175 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
106176 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
106177 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
106178 +from_oblock_52546 from_oblock 0-1 52546 NULL
106179 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
106180 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
106181 +emit_code_52583 emit_code 0-3 52583 NULL
106182 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
106183 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
106184 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
106185 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
106186 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
106187 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
106188 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
106189 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
106190 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
106191 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
106192 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
106193 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
106194 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
106195 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
106196 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
106197 +twlreg_write_52880 twlreg_write 3 52880 NULL
106198 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
106199 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
106200 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
106201 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
106202 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
106203 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
106204 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
106205 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
106206 +send_packet_52960 send_packet 4 52960 NULL
106207 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
106208 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
106209 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
106210 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
106211 +num_node_state_52989 num_node_state 0 52989 NULL
106212 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
106213 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
106214 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
106215 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
106216 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
106217 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
106218 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
106219 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
106220 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
106221 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
106222 +verity_status_53120 verity_status 5 53120 NULL
106223 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
106224 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
106225 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
106226 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
106227 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
106228 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
106229 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
106230 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
106231 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
106232 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
106233 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
106234 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
106235 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
106236 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
106237 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
106238 +vm_mmap_53339 vm_mmap 0 53339 NULL
106239 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
106240 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
106241 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
106242 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
106243 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
106244 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
106245 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
106246 +n2_run_53459 n2_run 3 53459 NULL
106247 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
106248 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
106249 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
106250 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
106251 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
106252 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
106253 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
106254 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
106255 +check_acl_53512 check_acl 0 53512 NULL
106256 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
106257 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
106258 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
106259 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
106260 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
106261 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
106262 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
106263 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
106264 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
106265 +_preload_range_53676 _preload_range 2-3 53676 NULL
106266 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
106267 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
106268 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
106269 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
106270 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
106271 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
106272 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
106273 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
106274 +wdm_write_53735 wdm_write 3 53735 NULL
106275 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
106276 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
106277 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
106278 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
106279 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
106280 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
106281 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
106282 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
106283 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
106284 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
106285 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
106286 +pms_read_53873 pms_read 3 53873 NULL
106287 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
106288 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
106289 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
106290 +proc_file_read_53905 proc_file_read 3 53905 NULL
106291 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
106292 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
106293 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
106294 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
106295 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
106296 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
106297 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
106298 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
106299 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
106300 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
106301 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
106302 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
106303 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
106304 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
106305 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
106306 +_malloc_54077 _malloc 1 54077 NULL
106307 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
106308 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
106309 +create_xattr_54106 create_xattr 5 54106 NULL
106310 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
106311 +strn_len_54122 strn_len 0 54122 NULL
106312 +isku_receive_54130 isku_receive 4 54130 NULL
106313 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
106314 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
106315 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
106316 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
106317 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
106318 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
106319 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
106320 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
106321 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
106322 +reada_add_block_54247 reada_add_block 2 54247 NULL
106323 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
106324 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
106325 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
106326 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
106327 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
106328 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
106329 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
106330 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
106331 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
106332 +sprintf_54306 sprintf 0 54306 NULL
106333 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
106334 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
106335 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
106336 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
106337 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
106338 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
106339 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
106340 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
106341 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
106342 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
106343 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
106344 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
106345 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
106346 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
106347 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
106348 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
106349 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
106350 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
106351 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
106352 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
106353 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
106354 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
106355 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
106356 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
106357 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
106358 +viacam_read_54526 viacam_read 3 54526 NULL
106359 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
106360 +setsockopt_54539 setsockopt 5 54539 NULL
106361 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
106362 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
106363 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
106364 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
106365 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
106366 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
106367 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
106368 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
106369 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
106370 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
106371 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
106372 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
106373 +evm_read_key_54674 evm_read_key 3 54674 NULL
106374 +resource_string_54699 resource_string 0 54699 NULL
106375 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
106376 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
106377 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
106378 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
106379 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
106380 +kzalloc_54740 kzalloc 1 54740 NULL
106381 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
106382 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
106383 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
106384 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
106385 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
106386 +domain_init_54797 domain_init 2 54797 NULL
106387 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
106388 +get_dev_size_54807 get_dev_size 0 54807 NULL
106389 +nfsd_write_54809 nfsd_write 6 54809 NULL
106390 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
106391 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
106392 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
106393 +write_rio_54837 write_rio 3 54837 NULL
106394 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
106395 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
106396 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
106397 +printer_read_54851 printer_read 3 54851 NULL
106398 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
106399 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
106400 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
106401 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
106402 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
106403 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
106404 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
106405 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
106406 +add_port_54941 add_port 2 54941 NULL
106407 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
106408 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
106409 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
106410 +c4_add_card_54968 c4_add_card 3 54968 NULL
106411 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
106412 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
106413 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
106414 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
106415 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
106416 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
106417 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
106418 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
106419 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
106420 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
106421 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
106422 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
106423 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
106424 +corrupt_data_55120 corrupt_data 0 55120 NULL
106425 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
106426 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
106427 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
106428 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
106429 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
106430 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
106431 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
106432 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
106433 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
106434 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
106435 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
106436 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
106437 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
106438 +dump_command_55220 dump_command 1 55220 NULL
106439 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
106440 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
106441 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
106442 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
106443 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
106444 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
106445 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
106446 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
106447 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
106448 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
106449 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
106450 +do_shmat_55336 do_shmat 5 55336 NULL
106451 +vme_user_read_55338 vme_user_read 3 55338 NULL
106452 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
106453 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
106454 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
106455 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
106456 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
106457 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
106458 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
106459 +alloc_skb_55439 alloc_skb 1 55439 NULL
106460 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
106461 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
106462 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
106463 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
106464 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
106465 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
106466 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
106467 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
106468 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
106469 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
106470 +ea_get_55522 ea_get 0 55522 NULL
106471 +buffer_size_55534 buffer_size 0 55534 NULL
106472 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
106473 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
106474 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
106475 +add_partition_55588 add_partition 2 55588 NULL
106476 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
106477 +free_pages_55603 free_pages 1 55603 NULL
106478 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
106479 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
106480 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
106481 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
106482 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
106483 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
106484 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
106485 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
106486 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
106487 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
106488 +read_oldmem_55658 read_oldmem 3 55658 NULL
106489 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
106490 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
106491 +get_info_55681 get_info 3 55681 NULL
106492 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
106493 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
106494 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
106495 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
106496 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
106497 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
106498 +set_local_name_55757 set_local_name 4 55757 NULL
106499 +strlen_55778 strlen 0 55778 NULL
106500 +set_spte_55783 set_spte 5-4 55783 NULL
106501 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
106502 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
106503 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
106504 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
106505 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
106506 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
106507 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
106508 +hsc_write_55875 hsc_write 3 55875 NULL
106509 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
106510 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
106511 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
106512 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
106513 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
106514 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
106515 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
106516 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
106517 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
106518 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
106519 +__set_discard_56081 __set_discard 2 56081 NULL
106520 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
106521 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
106522 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
106523 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
106524 +map_addr_56144 map_addr 7 56144 NULL
106525 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
106526 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
106527 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
106528 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
106529 +skb_headroom_56200 skb_headroom 0 56200 NULL
106530 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
106531 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
106532 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
106533 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
106534 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
106535 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
106536 +fd_copyin_56247 fd_copyin 3 56247 NULL
106537 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
106538 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
106539 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
106540 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
106541 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
106542 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
106543 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
106544 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
106545 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
106546 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
106547 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
106548 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
106549 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
106550 +dev_read_56369 dev_read 3 56369 NULL
106551 +write_gssp_56404 write_gssp 3 56404 NULL
106552 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
106553 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
106554 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
106555 +store_msg_56417 store_msg 3 56417 NULL
106556 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
106557 +fl_create_56435 fl_create 5 56435 NULL
106558 +gnttab_map_56439 gnttab_map 2 56439 NULL
106559 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
106560 +set_connectable_56458 set_connectable 4 56458 NULL
106561 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
106562 +putused_user_56467 putused_user 3 56467 NULL
106563 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
106564 +global_rt_period_56476 global_rt_period 0 56476 NULL
106565 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
106566 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
106567 +init_map_ip_56508 init_map_ip 5 56508 NULL
106568 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
106569 +ip_options_get_56538 ip_options_get 4 56538 NULL
106570 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
106571 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
106572 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
106573 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
106574 +event_filter_write_56609 event_filter_write 3 56609 NULL
106575 +gather_array_56641 gather_array 3 56641 NULL
106576 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
106577 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
106578 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
106579 +build_map_info_56696 build_map_info 2 56696 NULL
106580 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
106581 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
106582 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
106583 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
106584 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
106585 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
106586 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
106587 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
106588 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
106589 +hash_lookup_56792 hash_lookup 2 56792 NULL
106590 +do_syslog_56807 do_syslog 3 56807 NULL
106591 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
106592 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
106593 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
106594 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
106595 +wb_lookup_56858 wb_lookup 2 56858 NULL
106596 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
106597 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
106598 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
106599 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
106600 +strcspn_56913 strcspn 0 56913 NULL
106601 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
106602 +check_header_56930 check_header 2 56930 NULL
106603 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
106604 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
106605 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
106606 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
106607 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
106608 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
106609 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
106610 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
106611 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
106612 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
106613 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
106614 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
106615 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
106616 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
106617 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
106618 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
106619 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
106620 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
106621 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
106622 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
106623 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
106624 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
106625 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
106626 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
106627 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
106628 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
106629 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
106630 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
106631 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
106632 +flush_space_57241 flush_space 3 57241 NULL
106633 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
106634 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
106635 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
106636 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
106637 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
106638 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
106639 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
106640 +fw_file_size_57307 fw_file_size 0 57307 NULL
106641 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
106642 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
106643 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
106644 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
106645 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
106646 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
106647 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
106648 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
106649 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
106650 +read_file_blob_57406 read_file_blob 3 57406 NULL
106651 +enclosure_register_57412 enclosure_register 3 57412 NULL
106652 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
106653 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
106654 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
106655 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
106656 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
106657 +ReadReg_57453 ReadReg 0 57453 NULL
106658 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
106659 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
106660 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
106661 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
106662 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
106663 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
106664 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
106665 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
106666 +skb_headlen_57501 skb_headlen 0 57501 NULL
106667 +copy_in_user_57502 copy_in_user 3 57502 NULL
106668 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
106669 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
106670 +init_tag_map_57515 init_tag_map 3 57515 NULL
106671 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
106672 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
106673 +inode_permission_57531 inode_permission 0 57531 NULL
106674 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
106675 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
106676 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
106677 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
106678 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
106679 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
106680 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
106681 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
106682 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
106683 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
106684 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
106685 +mem_read_57631 mem_read 3 57631 NULL
106686 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
106687 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
106688 +r3964_write_57662 r3964_write 4 57662 NULL
106689 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
106690 +__lgwrite_57669 __lgwrite 4 57669 NULL
106691 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
106692 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
106693 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
106694 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
106695 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
106696 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
106697 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
106698 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
106699 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
106700 +ld2_57794 ld2 0 57794 NULL
106701 +ivtv_read_57796 ivtv_read 3 57796 NULL
106702 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
106703 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
106704 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
106705 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
106706 +copy_to_user_57835 copy_to_user 3 57835 NULL
106707 +flash_read_57843 flash_read 3 57843 NULL
106708 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
106709 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
106710 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
106711 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
106712 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
106713 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
106714 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
106715 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
106716 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
106717 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
106718 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
106719 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
106720 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
106721 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
106722 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
106723 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
106724 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
106725 +mce_async_out_58056 mce_async_out 3 58056 NULL
106726 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
106727 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
106728 +cm4040_write_58079 cm4040_write 3 58079 NULL
106729 +udi_log_event_58105 udi_log_event 3 58105 NULL
106730 +savemem_58129 savemem 3 58129 NULL
106731 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
106732 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
106733 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
106734 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
106735 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
106736 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
106737 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
106738 +read_file_debug_58256 read_file_debug 3 58256 NULL
106739 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
106740 +profile_load_58267 profile_load 3 58267 NULL
106741 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
106742 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
106743 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
106744 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
106745 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
106746 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
106747 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
106748 +next_pidmap_58347 next_pidmap 2 58347 NULL
106749 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
106750 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
106751 +save_hint_58359 save_hint 2 58359 NULL
106752 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
106753 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
106754 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
106755 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
106756 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
106757 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
106758 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
106759 +capabilities_read_58457 capabilities_read 3 58457 NULL
106760 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
106761 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
106762 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
106763 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
106764 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
106765 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
106766 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
106767 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
106768 +__clear_discard_58546 __clear_discard 2 58546 NULL
106769 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
106770 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
106771 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
106772 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
106773 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
106774 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
106775 +xip_file_read_58592 xip_file_read 3 58592 NULL
106776 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
106777 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
106778 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
106779 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
106780 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
106781 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
106782 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
106783 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
106784 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
106785 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
106786 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
106787 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
106788 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
106789 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
106790 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
106791 +acpi_map_58725 acpi_map 1-2 58725 NULL
106792 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
106793 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
106794 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
106795 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
106796 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
106797 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
106798 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
106799 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
106800 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
106801 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
106802 +ep_read_58813 ep_read 3 58813 NULL
106803 +command_write_58841 command_write 3 58841 NULL
106804 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
106805 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
106806 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
106807 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
106808 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
106809 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
106810 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
106811 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
106812 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
106813 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
106814 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
106815 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
106816 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
106817 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
106818 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
106819 +ep_write_59008 ep_write 3 59008 NULL
106820 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
106821 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
106822 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
106823 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
106824 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
106825 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
106826 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
106827 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
106828 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
106829 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
106830 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
106831 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
106832 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
106833 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
106834 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
106835 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
106836 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
106837 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
106838 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
106839 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
106840 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
106841 +dt3155_read_59226 dt3155_read 3 59226 NULL
106842 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
106843 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
106844 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
106845 +nla_len_59258 nla_len 0 59258 NULL
106846 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
106847 +fd_copyout_59323 fd_copyout 3 59323 NULL
106848 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
106849 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
106850 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
106851 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
106852 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
106853 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
106854 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
106855 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
106856 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
106857 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
106858 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
106859 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
106860 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
106861 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
106862 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
106863 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
106864 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
106865 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
106866 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
106867 +tunables_write_59563 tunables_write 3 59563 NULL
106868 +memdup_user_59590 memdup_user 2 59590 NULL
106869 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
106870 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
106871 +mtrr_write_59622 mtrr_write 3 59622 NULL
106872 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
106873 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
106874 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
106875 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
106876 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
106877 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
106878 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
106879 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
106880 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
106881 +sriov_enable_59689 sriov_enable 2 59689 NULL
106882 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
106883 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
106884 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
106885 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
106886 +strnlen_59746 strnlen 0 59746 NULL
106887 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
106888 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
106889 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
106890 +venus_remove_59781 venus_remove 4 59781 NULL
106891 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
106892 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
106893 +ipw_write_59807 ipw_write 3 59807 NULL
106894 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
106895 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
106896 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
106897 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
106898 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
106899 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
106900 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
106901 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
106902 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
106903 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
106904 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
106905 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
106906 +lookup_node_59953 lookup_node 2 59953 NULL
106907 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
106908 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
106909 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
106910 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
106911 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
106912 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
106913 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
106914 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
106915 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
106916 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
106917 +register_device_60015 register_device 2-3 60015 NULL
106918 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
106919 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
106920 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
106921 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
106922 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
106923 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
106924 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
106925 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
106926 +compat_writev_60063 compat_writev 3 60063 NULL
106927 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
106928 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
106929 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
106930 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
106931 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
106932 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
106933 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
106934 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
106935 +init_state_60165 init_state 2 60165 NULL
106936 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
106937 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
106938 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
106939 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
106940 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
106941 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
106942 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
106943 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
106944 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
106945 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
106946 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
106947 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
106948 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
106949 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
106950 +printer_write_60276 printer_write 3 60276 NULL
106951 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
106952 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
106953 +getDataLength_60301 getDataLength 0 60301 NULL
106954 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
106955 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
106956 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
106957 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
106958 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
106959 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
106960 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
106961 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
106962 +driver_names_read_60399 driver_names_read 3 60399 NULL
106963 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
106964 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
106965 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
106966 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
106967 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
106968 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
106969 +rx_data_60442 rx_data 4 60442 NULL nohasharray
106970 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
106971 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
106972 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
106973 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
106974 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
106975 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
106976 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
106977 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
106978 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
106979 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
106980 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
106981 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
106982 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
106983 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
106984 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
106985 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
106986 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
106987 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
106988 +init_data_container_60709 init_data_container 1 60709 NULL
106989 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
106990 +raid_status_60755 raid_status 5 60755 NULL
106991 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
106992 +opticon_write_60775 opticon_write 4 60775 NULL
106993 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
106994 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
106995 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
106996 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
106997 +generic_writepages_60871 generic_writepages 0 60871 NULL
106998 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
106999 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
107000 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
107001 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
107002 +sys_mlock_60932 sys_mlock 1 60932 NULL
107003 +pti_char_write_60960 pti_char_write 3 60960 NULL
107004 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
107005 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
107006 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
107007 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
107008 +symtab_init_61050 symtab_init 2 61050 NULL
107009 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
107010 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
107011 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
107012 +get_derived_key_61100 get_derived_key 4 61100 NULL
107013 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
107014 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
107015 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
107016 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
107017 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
107018 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
107019 +__vmalloc_61168 __vmalloc 1 61168 NULL
107020 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
107021 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
107022 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
107023 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
107024 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
107025 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
107026 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
107027 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
107028 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
107029 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
107030 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
107031 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
107032 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
107033 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
107034 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
107035 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
107036 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
107037 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
107038 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
107039 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
107040 +change_xattr_61390 change_xattr 5 61390 NULL
107041 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
107042 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
107043 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
107044 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
107045 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
107046 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
107047 +erst_errno_61526 erst_errno 0 61526 NULL
107048 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
107049 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
107050 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
107051 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
107052 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
107053 +seq_open_private_61589 seq_open_private 3 61589 NULL
107054 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
107055 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
107056 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
107057 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
107058 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
107059 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
107060 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
107061 +resize_stripes_61650 resize_stripes 2 61650 NULL
107062 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
107063 +insert_one_name_61668 insert_one_name 7 61668 NULL
107064 +lock_loop_61681 lock_loop 1 61681 NULL
107065 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
107066 +filter_read_61692 filter_read 3 61692 NULL
107067 +iov_length_61716 iov_length 0 61716 NULL
107068 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
107069 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
107070 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
107071 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
107072 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
107073 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
107074 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
107075 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
107076 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
107077 +get_fw_name_61874 get_fw_name 3 61874 NULL
107078 +free_init_pages_61875 free_init_pages 2 61875 NULL
107079 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
107080 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
107081 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
107082 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
107083 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
107084 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
107085 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
107086 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
107087 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
107088 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
107089 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
107090 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
107091 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
107092 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
107093 +cow_file_range_61979 cow_file_range 3 61979 NULL
107094 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
107095 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
107096 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
107097 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
107098 +SYSC_select_62024 SYSC_select 1 62024 NULL
107099 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
107100 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
107101 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
107102 +do_pselect_62061 do_pselect 1 62061 NULL
107103 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
107104 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
107105 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
107106 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
107107 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
107108 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
107109 +ql_status_62135 ql_status 5 62135 NULL
107110 +video_usercopy_62151 video_usercopy 2 62151 NULL
107111 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
107112 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
107113 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
107114 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
107115 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
107116 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
107117 +allocate_partition_62245 allocate_partition 4 62245 NULL
107118 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
107119 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
107120 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
107121 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
107122 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
107123 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
107124 +subseq_list_62332 subseq_list 3-0 62332 NULL
107125 +flash_write_62354 flash_write 3 62354 NULL
107126 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
107127 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
107128 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
107129 +altera_irscan_62396 altera_irscan 2 62396 NULL
107130 +set_ssp_62411 set_ssp 4 62411 NULL
107131 +unmap_single_62423 unmap_single 2 62423 NULL
107132 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
107133 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
107134 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
107135 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
107136 +remove_mapping_62491 remove_mapping 2 62491 NULL
107137 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
107138 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
107139 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
107140 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
107141 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
107142 +debugfs_read_62535 debugfs_read 3 62535 NULL
107143 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
107144 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
107145 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
107146 +get_subdir_62581 get_subdir 3 62581 NULL
107147 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
107148 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
107149 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
107150 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
107151 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
107152 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
107153 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
107154 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
107155 +write_62671 write 3 62671 NULL
107156 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
107157 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
107158 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
107159 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
107160 +rdm_62719 rdm 0 62719 NULL
107161 +key_replays_read_62746 key_replays_read 3 62746 NULL
107162 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
107163 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
107164 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
107165 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
107166 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
107167 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
107168 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
107169 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
107170 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
107171 +set_swbp_62853 set_swbp 3 62853 NULL
107172 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
107173 +aoechr_write_62883 aoechr_write 3 62883 NULL
107174 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
107175 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
107176 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
107177 +getdqbuf_62908 getdqbuf 1 62908 NULL
107178 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
107179 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
107180 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
107181 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
107182 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
107183 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
107184 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
107185 +unlink1_63059 unlink1 3 63059 NULL
107186 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
107187 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
107188 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
107189 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
107190 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
107191 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
107192 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
107193 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
107194 +vme_master_read_63221 vme_master_read 0 63221 NULL
107195 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
107196 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
107197 +ptp_read_63251 ptp_read 4 63251 NULL
107198 +raid5_resize_63306 raid5_resize 2 63306 NULL
107199 +proc_info_read_63344 proc_info_read 3 63344 NULL
107200 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
107201 +idmouse_read_63374 idmouse_read 3 63374 NULL
107202 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
107203 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
107204 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
107205 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
107206 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
107207 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
107208 +kone_send_63435 kone_send 4 63435 NULL
107209 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
107210 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
107211 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
107212 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
107213 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
107214 +read_kcore_63488 read_kcore 3 63488 NULL
107215 +save_hint_63497 save_hint 2 63497 NULL
107216 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
107217 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
107218 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
107219 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
107220 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
107221 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
107222 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
107223 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
107224 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
107225 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
107226 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
107227 +module_alloc_63630 module_alloc 1 63630 NULL
107228 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
107229 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
107230 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
107231 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
107232 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
107233 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
107234 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
107235 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
107236 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
107237 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
107238 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
107239 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
107240 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
107241 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
107242 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
107243 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
107244 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
107245 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
107246 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
107247 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
107248 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
107249 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
107250 +prepare_copy_63826 prepare_copy 2 63826 NULL
107251 +sel_write_load_63830 sel_write_load 3 63830 NULL
107252 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
107253 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
107254 +divas_write_63901 divas_write 3 63901 NULL
107255 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
107256 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
107257 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
107258 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
107259 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
107260 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
107261 +__team_options_register_63941 __team_options_register 3 63941 NULL
107262 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
107263 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
107264 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
107265 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
107266 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
107267 +kmemdup_64015 kmemdup 2 64015 NULL
107268 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
107269 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
107270 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
107271 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
107272 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
107273 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
107274 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
107275 +get_u8_64076 get_u8 0 64076 NULL
107276 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
107277 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
107278 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
107279 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
107280 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
107281 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
107282 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
107283 +init_bch_64130 init_bch 1-2 64130 NULL
107284 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
107285 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
107286 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
107287 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
107288 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
107289 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
107290 +read_pulse_64227 read_pulse 0-3 64227 NULL
107291 +header_len_64232 header_len 0 64232 NULL
107292 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
107293 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
107294 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
107295 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
107296 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
107297 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
107298 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
107299 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
107300 +ffz_64324 ffz 0 64324 NULL
107301 +map_region_64328 map_region 1 64328 NULL
107302 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
107303 +ts_write_64336 ts_write 3 64336 NULL
107304 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
107305 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
107306 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
107307 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
107308 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
107309 +ilo_write_64378 ilo_write 3 64378 NULL
107310 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
107311 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
107312 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
107313 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
107314 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
107315 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
107316 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
107317 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
107318 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
107319 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
107320 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
107321 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
107322 +cap_capable_64462 cap_capable 0 64462 NULL
107323 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
107324 +single_open_size_64483 single_open_size 4 64483 NULL
107325 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
107326 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
107327 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
107328 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
107329 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
107330 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
107331 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
107332 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
107333 +SyS_bind_64544 SyS_bind 3 64544 NULL
107334 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
107335 +__spi_sync_64561 __spi_sync 0 64561 NULL
107336 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
107337 +fanotify_write_64623 fanotify_write 3 64623 NULL
107338 +to_dblock_64655 to_dblock 0-1 64655 NULL
107339 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
107340 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
107341 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
107342 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
107343 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
107344 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
107345 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
107346 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
107347 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
107348 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
107349 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
107350 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
107351 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
107352 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
107353 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
107354 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
107355 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
107356 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
107357 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
107358 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
107359 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
107360 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
107361 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
107362 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
107363 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
107364 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
107365 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
107366 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
107367 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
107368 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
107369 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
107370 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
107371 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
107372 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
107373 +pskb_pull_65005 pskb_pull 2 65005 NULL
107374 +unifi_write_65012 unifi_write 3 65012 NULL
107375 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
107376 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
107377 +insert_dent_65034 insert_dent 7 65034 NULL
107378 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
107379 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
107380 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
107381 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
107382 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
107383 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
107384 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
107385 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
107386 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
107387 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
107388 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
107389 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
107390 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
107391 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
107392 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
107393 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
107394 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
107395 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
107396 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
107397 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
107398 +get_var_len_65304 get_var_len 0 65304 NULL
107399 +unpack_array_65318 unpack_array 0 65318 NULL
107400 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
107401 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
107402 +init_list_set_65351 init_list_set 2-3 65351 NULL
107403 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
107404 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
107405 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
107406 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
107407 +strchr_65372 strchr 0 65372 NULL nohasharray
107408 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
107409 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
107410 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
107411 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
107412 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
107413 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
107414 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
107415 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
107416 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
107417 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
107418 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
107419 +alloc_dr_65495 alloc_dr 2 65495 NULL
107420 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
107421 new file mode 100644
107422 index 0000000..03d0c84
107423 --- /dev/null
107424 +++ b/tools/gcc/size_overflow_plugin.c
107425 @@ -0,0 +1,2113 @@
107426 +/*
107427 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
107428 + * Licensed under the GPL v2, or (at your option) v3
107429 + *
107430 + * Homepage:
107431 + * http://www.grsecurity.net/~ephox/overflow_plugin/
107432 + *
107433 + * Documentation:
107434 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
107435 + *
107436 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
107437 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
107438 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
107439 + *
107440 + * Usage:
107441 + * $ gcc -I`gcc -print-file-name=plugin`/include/c-family -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -ggdb -Wall -W -o size_overflow_plugin.so size_overflow_plugin.c
107442 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
107443 + */
107444 +
107445 +#include "gcc-plugin.h"
107446 +#include "config.h"
107447 +#include "system.h"
107448 +#include "coretypes.h"
107449 +#include "tree.h"
107450 +#include "tree-pass.h"
107451 +#include "intl.h"
107452 +#include "plugin-version.h"
107453 +#include "tm.h"
107454 +#include "toplev.h"
107455 +#include "function.h"
107456 +#include "tree-flow.h"
107457 +#include "plugin.h"
107458 +#include "gimple.h"
107459 +#include "diagnostic.h"
107460 +#include "cfgloop.h"
107461 +
107462 +#if BUILDING_GCC_VERSION >= 4008
107463 +#define TODO_dump_func 0
107464 +#endif
107465 +
107466 +struct size_overflow_hash {
107467 + const struct size_overflow_hash * const next;
107468 + const char * const name;
107469 + const unsigned int param;
107470 +};
107471 +
107472 +#include "size_overflow_hash.h"
107473 +
107474 +enum mark {
107475 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
107476 +};
107477 +
107478 +enum err_code_conditions {
107479 + CAST_ONLY, FROM_CONST
107480 +};
107481 +
107482 +static unsigned int call_count = 0;
107483 +
107484 +#define __unused __attribute__((__unused__))
107485 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
107486 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
107487 +#define BEFORE_STMT true
107488 +#define AFTER_STMT false
107489 +#define CREATE_NEW_VAR NULL_TREE
107490 +#define CODES_LIMIT 32
107491 +#define MAX_PARAM 31
107492 +#define MY_STMT GF_PLF_1
107493 +#define NO_CAST_CHECK GF_PLF_2
107494 +#define FROM_ARG true
107495 +#define FROM_RET false
107496 +
107497 +#if BUILDING_GCC_VERSION == 4005
107498 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
107499 +#endif
107500 +
107501 +int plugin_is_GPL_compatible;
107502 +void debug_gimple_stmt(gimple gs);
107503 +
107504 +static tree expand(struct pointer_set_t *visited, tree lhs);
107505 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
107506 +static tree report_size_overflow_decl;
107507 +static const_tree const_char_ptr_type_node;
107508 +static unsigned int handle_function(void);
107509 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
107510 +static tree get_size_overflow_type(gimple stmt, const_tree node);
107511 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
107512 +static void print_missing_msg(tree func, unsigned int argnum);
107513 +
107514 +static struct plugin_info size_overflow_plugin_info = {
107515 + .version = "20130822beta",
107516 + .help = "no-size-overflow\tturn off size overflow checking\n",
107517 +};
107518 +
107519 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
107520 +{
107521 + unsigned int arg_count;
107522 + enum tree_code code = TREE_CODE(*node);
107523 +
107524 + switch (code) {
107525 + case FUNCTION_DECL:
107526 + arg_count = type_num_arguments(TREE_TYPE(*node));
107527 + break;
107528 + case FUNCTION_TYPE:
107529 + case METHOD_TYPE:
107530 + arg_count = type_num_arguments(*node);
107531 + break;
107532 + default:
107533 + *no_add_attrs = true;
107534 + error("%s: %qE attribute only applies to functions", __func__, name);
107535 + return NULL_TREE;
107536 + }
107537 +
107538 + for (; args; args = TREE_CHAIN(args)) {
107539 + tree position = TREE_VALUE(args);
107540 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
107541 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
107542 + *no_add_attrs = true;
107543 + }
107544 + }
107545 + return NULL_TREE;
107546 +}
107547 +
107548 +static const char* get_asm_name(tree node)
107549 +{
107550 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
107551 +}
107552 +
107553 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
107554 +{
107555 + unsigned int arg_count, arg_num;
107556 + enum tree_code code = TREE_CODE(*node);
107557 +
107558 + switch (code) {
107559 + case FUNCTION_DECL:
107560 + arg_count = type_num_arguments(TREE_TYPE(*node));
107561 + break;
107562 + case FUNCTION_TYPE:
107563 + case METHOD_TYPE:
107564 + arg_count = type_num_arguments(*node);
107565 + break;
107566 + case FIELD_DECL:
107567 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
107568 + if (arg_num != 0) {
107569 + *no_add_attrs = true;
107570 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
107571 + }
107572 + return NULL_TREE;
107573 + default:
107574 + *no_add_attrs = true;
107575 + error("%qE attribute only applies to functions", name);
107576 + return NULL_TREE;
107577 + }
107578 +
107579 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
107580 + return NULL_TREE;
107581 +
107582 + for (; args; args = TREE_CHAIN(args)) {
107583 + tree position = TREE_VALUE(args);
107584 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
107585 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
107586 + *no_add_attrs = true;
107587 + }
107588 + }
107589 + return NULL_TREE;
107590 +}
107591 +
107592 +static struct attribute_spec size_overflow_attr = {
107593 + .name = "size_overflow",
107594 + .min_length = 1,
107595 + .max_length = -1,
107596 + .decl_required = true,
107597 + .type_required = false,
107598 + .function_type_required = false,
107599 + .handler = handle_size_overflow_attribute,
107600 +#if BUILDING_GCC_VERSION >= 4007
107601 + .affects_type_identity = false
107602 +#endif
107603 +};
107604 +
107605 +static struct attribute_spec intentional_overflow_attr = {
107606 + .name = "intentional_overflow",
107607 + .min_length = 1,
107608 + .max_length = -1,
107609 + .decl_required = true,
107610 + .type_required = false,
107611 + .function_type_required = false,
107612 + .handler = handle_intentional_overflow_attribute,
107613 +#if BUILDING_GCC_VERSION >= 4007
107614 + .affects_type_identity = false
107615 +#endif
107616 +};
107617 +
107618 +static void register_attributes(void __unused *event_data, void __unused *data)
107619 +{
107620 + register_attribute(&size_overflow_attr);
107621 + register_attribute(&intentional_overflow_attr);
107622 +}
107623 +
107624 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
107625 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
107626 +{
107627 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
107628 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
107629 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
107630 +
107631 + unsigned int m = 0x57559429;
107632 + unsigned int n = 0x5052acdb;
107633 + const unsigned int *key4 = (const unsigned int *)key;
107634 + unsigned int h = len;
107635 + unsigned int k = len + seed + n;
107636 + unsigned long long p;
107637 +
107638 + while (len >= 8) {
107639 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
107640 + len -= 8;
107641 + }
107642 + if (len >= 4) {
107643 + cwmixb(key4[0]) key4 += 1;
107644 + len -= 4;
107645 + }
107646 + if (len)
107647 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
107648 + cwmixb(h ^ (k + n));
107649 + return k ^ h;
107650 +
107651 +#undef cwfold
107652 +#undef cwmixa
107653 +#undef cwmixb
107654 +}
107655 +
107656 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
107657 +{
107658 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
107659 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
107660 + return fn ^ codes;
107661 +}
107662 +
107663 +static inline tree get_original_function_decl(tree fndecl)
107664 +{
107665 + if (DECL_ABSTRACT_ORIGIN(fndecl))
107666 + return DECL_ABSTRACT_ORIGIN(fndecl);
107667 + return fndecl;
107668 +}
107669 +
107670 +static inline gimple get_def_stmt(const_tree node)
107671 +{
107672 + gcc_assert(node != NULL_TREE);
107673 + if (TREE_CODE(node) != SSA_NAME)
107674 + return NULL;
107675 + return SSA_NAME_DEF_STMT(node);
107676 +}
107677 +
107678 +static unsigned char get_tree_code(const_tree type)
107679 +{
107680 + switch (TREE_CODE(type)) {
107681 + case ARRAY_TYPE:
107682 + return 0;
107683 + case BOOLEAN_TYPE:
107684 + return 1;
107685 + case ENUMERAL_TYPE:
107686 + return 2;
107687 + case FUNCTION_TYPE:
107688 + return 3;
107689 + case INTEGER_TYPE:
107690 + return 4;
107691 + case POINTER_TYPE:
107692 + return 5;
107693 + case RECORD_TYPE:
107694 + return 6;
107695 + case UNION_TYPE:
107696 + return 7;
107697 + case VOID_TYPE:
107698 + return 8;
107699 + case REAL_TYPE:
107700 + return 9;
107701 + case VECTOR_TYPE:
107702 + return 10;
107703 + case REFERENCE_TYPE:
107704 + return 11;
107705 + case OFFSET_TYPE:
107706 + return 12;
107707 + case COMPLEX_TYPE:
107708 + return 13;
107709 + default:
107710 + debug_tree((tree)type);
107711 + gcc_unreachable();
107712 + }
107713 +}
107714 +
107715 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
107716 +{
107717 + gcc_assert(type != NULL_TREE);
107718 +
107719 + while (type && len < CODES_LIMIT) {
107720 + tree_codes[len] = get_tree_code(type);
107721 + len++;
107722 + type = TREE_TYPE(type);
107723 + }
107724 + return len;
107725 +}
107726 +
107727 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
107728 +{
107729 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
107730 + enum tree_code code = TREE_CODE(type);
107731 + size_t len = 0;
107732 +
107733 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
107734 +
107735 + arg = TYPE_ARG_TYPES(type);
107736 + // skip builtins __builtin_constant_p
107737 + if (!arg && DECL_BUILT_IN(fndecl))
107738 + return 0;
107739 +
107740 + if (TREE_CODE_CLASS(code) == tcc_type)
107741 + result = type;
107742 + else
107743 + result = DECL_RESULT(fndecl);
107744 +
107745 + gcc_assert(result != NULL_TREE);
107746 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
107747 +
107748 + if (arg == NULL_TREE) {
107749 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
107750 + arg_field = DECL_ARGUMENT_FLD(fndecl);
107751 + if (arg_field == NULL_TREE)
107752 + return 0;
107753 + arg = TREE_TYPE(arg_field);
107754 + len = add_type_codes(arg, tree_codes, len);
107755 + gcc_assert(len != 0);
107756 + return len;
107757 + }
107758 +
107759 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
107760 + while (arg && len < CODES_LIMIT) {
107761 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
107762 + arg = TREE_CHAIN(arg);
107763 + }
107764 +
107765 + gcc_assert(len != 0);
107766 + return len;
107767 +}
107768 +
107769 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
107770 +{
107771 + unsigned int hash;
107772 + const struct size_overflow_hash *entry;
107773 + unsigned char tree_codes[CODES_LIMIT];
107774 + size_t len;
107775 + const char *func_name;
107776 +
107777 + fndecl = get_original_function_decl(fndecl);
107778 + len = get_function_decl(fndecl, tree_codes);
107779 + if (len == 0)
107780 + return NULL;
107781 +
107782 + func_name = get_asm_name(fndecl);
107783 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
107784 +
107785 + entry = size_overflow_hash[hash];
107786 + while (entry) {
107787 + if (!strcmp(entry->name, func_name))
107788 + return entry;
107789 + entry = entry->next;
107790 + }
107791 +
107792 + return NULL;
107793 +}
107794 +
107795 +static bool is_bool(const_tree node)
107796 +{
107797 + const_tree type;
107798 +
107799 + if (node == NULL_TREE)
107800 + return false;
107801 +
107802 + type = TREE_TYPE(node);
107803 + if (!INTEGRAL_TYPE_P(type))
107804 + return false;
107805 + if (TREE_CODE(type) == BOOLEAN_TYPE)
107806 + return true;
107807 + if (TYPE_PRECISION(type) == 1)
107808 + return true;
107809 + return false;
107810 +}
107811 +
107812 +static bool skip_types(const_tree var)
107813 +{
107814 + tree type;
107815 +
107816 + if (is_gimple_constant(var))
107817 + return true;
107818 +
107819 + switch (TREE_CODE(var)) {
107820 + case ADDR_EXPR:
107821 +#if BUILDING_GCC_VERSION >= 4006
107822 + case MEM_REF:
107823 +#endif
107824 + case ARRAY_REF:
107825 + case BIT_FIELD_REF:
107826 + case INDIRECT_REF:
107827 + case TARGET_MEM_REF:
107828 + return true;
107829 + case PARM_DECL:
107830 + case VAR_DECL:
107831 + case COMPONENT_REF:
107832 + return false;
107833 + default:
107834 + break;
107835 + }
107836 +
107837 + gcc_assert(TREE_CODE(var) == SSA_NAME);
107838 +
107839 + type = TREE_TYPE(var);
107840 + switch (TREE_CODE(type)) {
107841 + case INTEGER_TYPE:
107842 + case ENUMERAL_TYPE:
107843 + return false;
107844 + case BOOLEAN_TYPE:
107845 + return is_bool(var);
107846 + default:
107847 + break;
107848 + }
107849 +
107850 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
107851 +
107852 + type = TREE_TYPE(type);
107853 + gcc_assert(type != NULL_TREE);
107854 + switch (TREE_CODE(type)) {
107855 + case RECORD_TYPE:
107856 + case POINTER_TYPE:
107857 + case ARRAY_TYPE:
107858 + return true;
107859 + case VOID_TYPE:
107860 + case INTEGER_TYPE:
107861 + case UNION_TYPE:
107862 + return false;
107863 + default:
107864 + break;
107865 + }
107866 +
107867 + debug_tree((tree)var);
107868 + gcc_unreachable();
107869 +}
107870 +
107871 +static unsigned int find_arg_number(const_tree arg, tree func)
107872 +{
107873 + tree var;
107874 + unsigned int argnum = 1;
107875 +
107876 + if (TREE_CODE(arg) == SSA_NAME)
107877 + arg = SSA_NAME_VAR(arg);
107878 +
107879 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
107880 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
107881 + continue;
107882 + if (!skip_types(var))
107883 + return argnum;
107884 + }
107885 +
107886 + return 0;
107887 +}
107888 +
107889 +static tree create_new_var(tree type)
107890 +{
107891 + tree new_var = create_tmp_var(type, "cicus");
107892 +
107893 +#if BUILDING_GCC_VERSION <= 4007
107894 + add_referenced_var(new_var);
107895 +#endif
107896 + return new_var;
107897 +}
107898 +
107899 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
107900 +{
107901 + gimple assign;
107902 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
107903 + tree type = TREE_TYPE(rhs1);
107904 + tree lhs = create_new_var(type);
107905 +
107906 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
107907 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
107908 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
107909 +
107910 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
107911 + update_stmt(assign);
107912 + gimple_set_plf(assign, MY_STMT, true);
107913 + return assign;
107914 +}
107915 +
107916 +static tree cast_a_tree(tree type, tree var)
107917 +{
107918 + gcc_assert(type != NULL_TREE);
107919 + gcc_assert(var != NULL_TREE);
107920 + gcc_assert(fold_convertible_p(type, var));
107921 +
107922 + return fold_convert(type, var);
107923 +}
107924 +
107925 +static tree get_lhs(const_gimple stmt)
107926 +{
107927 + switch (gimple_code(stmt)) {
107928 + case GIMPLE_ASSIGN:
107929 + return gimple_get_lhs(stmt);
107930 + case GIMPLE_PHI:
107931 + return gimple_phi_result(stmt);
107932 + case GIMPLE_CALL:
107933 + return gimple_call_lhs(stmt);
107934 + default:
107935 + return NULL_TREE;
107936 + }
107937 +}
107938 +
107939 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
107940 +{
107941 + const_gimple def_stmt = get_def_stmt(rhs);
107942 +
107943 + if (force)
107944 + return false;
107945 +
107946 + if (is_gimple_constant(rhs))
107947 + return false;
107948 +
107949 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
107950 + return false;
107951 +
107952 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
107953 + return false;
107954 +
107955 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
107956 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
107957 + return false;
107958 +
107959 + return true;
107960 +}
107961 +
107962 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
107963 +{
107964 + gimple assign, def_stmt;
107965 +
107966 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
107967 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
107968 + gcc_unreachable();
107969 +
107970 + def_stmt = get_def_stmt(rhs);
107971 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
107972 + return def_stmt;
107973 +
107974 + if (lhs == CREATE_NEW_VAR)
107975 + lhs = create_new_var(dst_type);
107976 +
107977 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
107978 +
107979 + if (!gsi_end_p(*gsi)) {
107980 + location_t loc = gimple_location(gsi_stmt(*gsi));
107981 + gimple_set_location(assign, loc);
107982 + }
107983 +
107984 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
107985 +
107986 + if (before)
107987 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
107988 + else
107989 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
107990 + update_stmt(assign);
107991 + gimple_set_plf(assign, MY_STMT, true);
107992 +
107993 + return assign;
107994 +}
107995 +
107996 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
107997 +{
107998 + gimple_stmt_iterator gsi;
107999 + tree lhs;
108000 + const_gimple new_stmt;
108001 +
108002 + if (rhs == NULL_TREE)
108003 + return NULL_TREE;
108004 +
108005 + gsi = gsi_for_stmt(stmt);
108006 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
108007 +
108008 + lhs = get_lhs(new_stmt);
108009 + gcc_assert(lhs != NULL_TREE);
108010 + return lhs;
108011 +}
108012 +
108013 +static tree cast_to_TI_type(gimple stmt, tree node)
108014 +{
108015 + gimple_stmt_iterator gsi;
108016 + gimple cast_stmt;
108017 + tree type = TREE_TYPE(node);
108018 +
108019 + if (types_compatible_p(type, intTI_type_node))
108020 + return node;
108021 +
108022 + gsi = gsi_for_stmt(stmt);
108023 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108024 + return gimple_get_lhs(cast_stmt);
108025 +}
108026 +
108027 +static void check_function_hash(const_gimple stmt)
108028 +{
108029 + tree func;
108030 + const struct size_overflow_hash *hash;
108031 +
108032 + if (gimple_code(stmt) != GIMPLE_CALL)
108033 + return;
108034 +
108035 + func = gimple_call_fndecl(stmt);
108036 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
108037 + if (func == NULL_TREE)
108038 + return;
108039 +
108040 + hash = get_function_hash(func);
108041 + if (!hash)
108042 + print_missing_msg(func, 0);
108043 +}
108044 +
108045 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
108046 +{
108047 + tree lhs, new_lhs;
108048 + gimple_stmt_iterator gsi;
108049 +
108050 + if (rhs1 == NULL_TREE) {
108051 + debug_gimple_stmt(oldstmt);
108052 + error("%s: rhs1 is NULL_TREE", __func__);
108053 + gcc_unreachable();
108054 + }
108055 +
108056 + switch (gimple_code(oldstmt)) {
108057 + case GIMPLE_ASM:
108058 + lhs = rhs1;
108059 + break;
108060 + case GIMPLE_CALL:
108061 + lhs = gimple_call_lhs(oldstmt);
108062 + break;
108063 + case GIMPLE_ASSIGN:
108064 + lhs = gimple_get_lhs(oldstmt);
108065 + break;
108066 + default:
108067 + debug_gimple_stmt(oldstmt);
108068 + gcc_unreachable();
108069 + }
108070 +
108071 + gsi = gsi_for_stmt(oldstmt);
108072 + pointer_set_insert(visited, oldstmt);
108073 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
108074 + basic_block next_bb, cur_bb;
108075 + const_edge e;
108076 +
108077 + gcc_assert(before == false);
108078 + gcc_assert(stmt_can_throw_internal(oldstmt));
108079 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
108080 + gcc_assert(!gsi_end_p(gsi));
108081 +
108082 + cur_bb = gimple_bb(oldstmt);
108083 + next_bb = cur_bb->next_bb;
108084 + e = find_edge(cur_bb, next_bb);
108085 + gcc_assert(e != NULL);
108086 + gcc_assert(e->flags & EDGE_FALLTHRU);
108087 +
108088 + gsi = gsi_after_labels(next_bb);
108089 + gcc_assert(!gsi_end_p(gsi));
108090 +
108091 + before = true;
108092 + oldstmt = gsi_stmt(gsi);
108093 + }
108094 +
108095 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
108096 + return new_lhs;
108097 +}
108098 +
108099 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
108100 +{
108101 + gimple stmt;
108102 + gimple_stmt_iterator gsi;
108103 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
108104 +
108105 + if (gimple_plf(oldstmt, MY_STMT))
108106 + return lhs;
108107 +
108108 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
108109 + rhs1 = gimple_assign_rhs1(oldstmt);
108110 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
108111 + }
108112 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
108113 + rhs2 = gimple_assign_rhs2(oldstmt);
108114 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
108115 + }
108116 +
108117 + stmt = gimple_copy(oldstmt);
108118 + gimple_set_location(stmt, gimple_location(oldstmt));
108119 + gimple_set_plf(stmt, MY_STMT, true);
108120 +
108121 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
108122 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
108123 +
108124 + size_overflow_type = get_size_overflow_type(oldstmt, node);
108125 +
108126 + new_var = create_new_var(size_overflow_type);
108127 + new_var = make_ssa_name(new_var, stmt);
108128 + gimple_set_lhs(stmt, new_var);
108129 +
108130 + if (rhs1 != NULL_TREE)
108131 + gimple_assign_set_rhs1(stmt, rhs1);
108132 +
108133 + if (rhs2 != NULL_TREE)
108134 + gimple_assign_set_rhs2(stmt, rhs2);
108135 +#if BUILDING_GCC_VERSION >= 4007
108136 + if (rhs3 != NULL_TREE)
108137 + gimple_assign_set_rhs3(stmt, rhs3);
108138 +#endif
108139 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
108140 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
108141 +
108142 + gsi = gsi_for_stmt(oldstmt);
108143 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
108144 + update_stmt(stmt);
108145 + pointer_set_insert(visited, oldstmt);
108146 + return gimple_get_lhs(stmt);
108147 +}
108148 +
108149 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
108150 +{
108151 + basic_block first_bb;
108152 + gimple assign;
108153 + gimple_stmt_iterator gsi;
108154 +
108155 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
108156 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
108157 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
108158 +
108159 + gsi = gsi_start_bb(first_bb);
108160 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
108161 + return gimple_get_lhs(assign);
108162 +}
108163 +
108164 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
108165 +{
108166 + gimple_stmt_iterator gsi;
108167 + const_gimple assign;
108168 + gimple def_stmt = get_def_stmt(new_arg);
108169 +
108170 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
108171 + gsi = gsi_after_labels(gimple_bb(def_stmt));
108172 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
108173 + } else {
108174 + gsi = gsi_for_stmt(def_stmt);
108175 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
108176 + }
108177 +
108178 + return gimple_get_lhs(assign);
108179 +}
108180 +
108181 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
108182 +{
108183 + basic_block bb;
108184 + gimple_stmt_iterator gsi;
108185 + const_gimple assign, def_stmt;
108186 +
108187 + def_stmt = get_def_stmt(arg);
108188 + bb = gimple_bb(def_stmt);
108189 + gcc_assert(bb->index != 0);
108190 + gsi = gsi_after_labels(bb);
108191 +
108192 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
108193 + return gimple_get_lhs(assign);
108194 +}
108195 +
108196 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
108197 +{
108198 + tree size_overflow_type;
108199 + const_gimple def_stmt = get_def_stmt(arg);
108200 +
108201 + if (phi_ssa_name != NULL_TREE)
108202 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
108203 +
108204 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
108205 +
108206 + if (new_arg != NULL_TREE) {
108207 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
108208 + return use_phi_ssa_name(phi_ssa_name, new_arg);
108209 + }
108210 +
108211 + switch(gimple_code(def_stmt)) {
108212 + case GIMPLE_PHI:
108213 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
108214 + case GIMPLE_NOP:
108215 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
108216 + default:
108217 + debug_gimple_stmt((gimple)def_stmt);
108218 + gcc_unreachable();
108219 + }
108220 +}
108221 +
108222 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
108223 +{
108224 + basic_block bb;
108225 + gimple phi;
108226 + gimple_seq seq;
108227 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
108228 +
108229 + bb = gsi_bb(gsi);
108230 +
108231 + phi = create_phi_node(result, bb);
108232 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
108233 + seq = phi_nodes(bb);
108234 + gsi = gsi_last(seq);
108235 + gsi_remove(&gsi, false);
108236 +
108237 + gsi = gsi_for_stmt(oldstmt);
108238 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
108239 + gimple_set_bb(phi, bb);
108240 + gimple_set_plf(phi, MY_STMT, true);
108241 + return phi;
108242 +}
108243 +
108244 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
108245 +{
108246 + gimple new_phi = NULL;
108247 + gimple oldstmt = get_def_stmt(orig_result);
108248 + tree phi_ssa_name = NULL_TREE;
108249 + unsigned int i;
108250 +
108251 + pointer_set_insert(visited, oldstmt);
108252 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
108253 + tree arg, new_arg;
108254 +
108255 + arg = gimple_phi_arg_def(oldstmt, i);
108256 +
108257 + new_arg = expand(visited, arg);
108258 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
108259 + if (i == 0) {
108260 + phi_ssa_name = new_arg;
108261 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
108262 + }
108263 +
108264 + gcc_assert(new_phi != NULL);
108265 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
108266 + }
108267 +
108268 + gcc_assert(new_phi != NULL);
108269 + update_stmt(new_phi);
108270 + return gimple_phi_result(new_phi);
108271 +}
108272 +
108273 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
108274 +{
108275 + const_gimple assign;
108276 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108277 + tree origtype = TREE_TYPE(orig_rhs);
108278 +
108279 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
108280 +
108281 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108282 + return gimple_get_lhs(assign);
108283 +}
108284 +
108285 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
108286 +{
108287 + const_tree rhs1, lhs, rhs1_type, lhs_type;
108288 + enum machine_mode lhs_mode, rhs_mode;
108289 + gimple def_stmt = get_def_stmt(no_const_rhs);
108290 +
108291 + if (!gimple_assign_cast_p(def_stmt))
108292 + return false;
108293 +
108294 + rhs1 = gimple_assign_rhs1(def_stmt);
108295 + lhs = gimple_get_lhs(def_stmt);
108296 + rhs1_type = TREE_TYPE(rhs1);
108297 + lhs_type = TREE_TYPE(lhs);
108298 + rhs_mode = TYPE_MODE(rhs1_type);
108299 + lhs_mode = TYPE_MODE(lhs_type);
108300 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
108301 + return false;
108302 +
108303 + return true;
108304 +}
108305 +
108306 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
108307 +{
108308 + tree rhs1 = gimple_assign_rhs1(stmt);
108309 + tree lhs = gimple_get_lhs(stmt);
108310 + const_tree rhs1_type = TREE_TYPE(rhs1);
108311 + const_tree lhs_type = TREE_TYPE(lhs);
108312 +
108313 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
108314 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108315 +
108316 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
108317 +}
108318 +
108319 +static bool no_uses(tree node)
108320 +{
108321 + imm_use_iterator imm_iter;
108322 + use_operand_p use_p;
108323 +
108324 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
108325 + const_gimple use_stmt = USE_STMT(use_p);
108326 + if (use_stmt == NULL)
108327 + return true;
108328 + if (is_gimple_debug(use_stmt))
108329 + continue;
108330 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
108331 + continue;
108332 + return false;
108333 + }
108334 + return true;
108335 +}
108336 +
108337 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
108338 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
108339 +{
108340 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
108341 + gimple def_stmt = get_def_stmt(lhs);
108342 +
108343 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
108344 + return false;
108345 +
108346 + rhs1 = gimple_assign_rhs1(def_stmt);
108347 + rhs_type = TREE_TYPE(rhs1);
108348 + lhs_type = TREE_TYPE(lhs);
108349 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
108350 + return false;
108351 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
108352 + return false;
108353 +
108354 + def_stmt = get_def_stmt(rhs1);
108355 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
108356 + return false;
108357 +
108358 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
108359 + return false;
108360 +
108361 + rhs1 = gimple_assign_rhs1(def_stmt);
108362 + rhs2 = gimple_assign_rhs2(def_stmt);
108363 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
108364 + return false;
108365 +
108366 + if (is_gimple_constant(rhs2))
108367 + not_const_rhs = rhs1;
108368 + else
108369 + not_const_rhs = rhs2;
108370 +
108371 + return no_uses(not_const_rhs);
108372 +}
108373 +
108374 +static bool skip_lhs_cast_check(const_gimple stmt)
108375 +{
108376 + const_tree rhs = gimple_assign_rhs1(stmt);
108377 + const_gimple def_stmt = get_def_stmt(rhs);
108378 +
108379 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
108380 + if (gimple_code(def_stmt) == GIMPLE_ASM)
108381 + return true;
108382 +
108383 + if (is_const_plus_unsigned_signed_truncation(rhs))
108384 + return true;
108385 +
108386 + return false;
108387 +}
108388 +
108389 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
108390 +{
108391 + bool cast_lhs, cast_rhs;
108392 + tree lhs = gimple_get_lhs(stmt);
108393 + tree rhs = gimple_assign_rhs1(stmt);
108394 + const_tree lhs_type = TREE_TYPE(lhs);
108395 + const_tree rhs_type = TREE_TYPE(rhs);
108396 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
108397 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
108398 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
108399 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
108400 +
108401 + static bool check_lhs[3][4] = {
108402 + // ss su us uu
108403 + { false, true, true, false }, // lhs > rhs
108404 + { false, false, false, false }, // lhs = rhs
108405 + { true, true, true, true }, // lhs < rhs
108406 + };
108407 +
108408 + static bool check_rhs[3][4] = {
108409 + // ss su us uu
108410 + { true, false, true, true }, // lhs > rhs
108411 + { true, false, true, true }, // lhs = rhs
108412 + { true, false, true, true }, // lhs < rhs
108413 + };
108414 +
108415 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
108416 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
108417 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108418 +
108419 + if (lhs_size > rhs_size) {
108420 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108421 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108422 + } else if (lhs_size == rhs_size) {
108423 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108424 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108425 + } else {
108426 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108427 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
108428 + }
108429 +
108430 + if (!cast_lhs && !cast_rhs)
108431 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108432 +
108433 + if (cast_lhs && !skip_lhs_cast_check(stmt))
108434 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
108435 +
108436 + if (cast_rhs)
108437 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
108438 +
108439 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108440 +}
108441 +
108442 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
108443 +{
108444 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
108445 +
108446 + if (gimple_plf(stmt, MY_STMT))
108447 + return lhs;
108448 +
108449 + rhs1 = gimple_assign_rhs1(stmt);
108450 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
108451 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108452 +
108453 + new_rhs1 = expand(visited, rhs1);
108454 +
108455 + if (new_rhs1 == NULL_TREE)
108456 + return create_cast_assign(visited, stmt);
108457 +
108458 + if (gimple_plf(stmt, NO_CAST_CHECK))
108459 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108460 +
108461 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
108462 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
108463 +
108464 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
108465 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
108466 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108467 + }
108468 +
108469 + if (!gimple_assign_cast_p(stmt))
108470 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
108471 +
108472 + return create_cast_overflow_check(visited, new_rhs1, stmt);
108473 +}
108474 +
108475 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
108476 +{
108477 + tree rhs1, lhs = gimple_get_lhs(stmt);
108478 + gimple def_stmt = get_def_stmt(lhs);
108479 +
108480 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
108481 + rhs1 = gimple_assign_rhs1(def_stmt);
108482 +
108483 + if (is_gimple_constant(rhs1))
108484 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
108485 +
108486 + switch (TREE_CODE(rhs1)) {
108487 + case SSA_NAME:
108488 + return handle_unary_rhs(visited, def_stmt);
108489 + case ARRAY_REF:
108490 + case BIT_FIELD_REF:
108491 + case ADDR_EXPR:
108492 + case COMPONENT_REF:
108493 + case INDIRECT_REF:
108494 +#if BUILDING_GCC_VERSION >= 4006
108495 + case MEM_REF:
108496 +#endif
108497 + case TARGET_MEM_REF:
108498 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
108499 + case PARM_DECL:
108500 + case VAR_DECL:
108501 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108502 +
108503 + default:
108504 + debug_gimple_stmt(def_stmt);
108505 + debug_tree(rhs1);
108506 + gcc_unreachable();
108507 + }
108508 +}
108509 +
108510 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
108511 +{
108512 + gimple cond_stmt;
108513 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
108514 +
108515 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
108516 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
108517 + update_stmt(cond_stmt);
108518 +}
108519 +
108520 +static tree create_string_param(tree string)
108521 +{
108522 + tree i_type, a_type;
108523 + const int length = TREE_STRING_LENGTH(string);
108524 +
108525 + gcc_assert(length > 0);
108526 +
108527 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
108528 + a_type = build_array_type(char_type_node, i_type);
108529 +
108530 + TREE_TYPE(string) = a_type;
108531 + TREE_CONSTANT(string) = 1;
108532 + TREE_READONLY(string) = 1;
108533 +
108534 + return build1(ADDR_EXPR, ptr_type_node, string);
108535 +}
108536 +
108537 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
108538 +{
108539 + gimple func_stmt;
108540 + const_gimple def_stmt;
108541 + const_tree loc_line;
108542 + tree loc_file, ssa_name, current_func;
108543 + expanded_location xloc;
108544 + char *ssa_name_buf;
108545 + int len;
108546 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
108547 +
108548 + def_stmt = get_def_stmt(arg);
108549 + xloc = expand_location(gimple_location(def_stmt));
108550 +
108551 + if (!gimple_has_location(def_stmt)) {
108552 + xloc = expand_location(gimple_location(stmt));
108553 + if (!gimple_has_location(stmt))
108554 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
108555 + }
108556 +
108557 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
108558 +
108559 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
108560 + loc_file = create_string_param(loc_file);
108561 +
108562 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
108563 + current_func = create_string_param(current_func);
108564 +
108565 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
108566 + call_count++;
108567 + len = asprintf(&ssa_name_buf, "%s_%u %s, count: %u\n", NAME(SSA_NAME_VAR(arg)), SSA_NAME_VERSION(arg), min ? "min" : "max", call_count);
108568 + gcc_assert(len > 0);
108569 + ssa_name = build_string(len + 1, ssa_name_buf);
108570 + free(ssa_name_buf);
108571 + ssa_name = create_string_param(ssa_name);
108572 +
108573 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
108574 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
108575 +
108576 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
108577 +}
108578 +
108579 +static void __unused print_the_code_insertions(const_gimple stmt)
108580 +{
108581 + location_t loc = gimple_location(stmt);
108582 +
108583 + inform(loc, "Integer size_overflow check applied here.");
108584 +}
108585 +
108586 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
108587 +{
108588 + basic_block cond_bb, join_bb, bb_true;
108589 + edge e;
108590 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108591 +
108592 + cond_bb = gimple_bb(stmt);
108593 + if (before)
108594 + gsi_prev(&gsi);
108595 + if (gsi_end_p(gsi))
108596 + e = split_block_after_labels(cond_bb);
108597 + else
108598 + e = split_block(cond_bb, gsi_stmt(gsi));
108599 + cond_bb = e->src;
108600 + join_bb = e->dest;
108601 + e->flags = EDGE_FALSE_VALUE;
108602 + e->probability = REG_BR_PROB_BASE;
108603 +
108604 + bb_true = create_empty_bb(cond_bb);
108605 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
108606 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
108607 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
108608 +
108609 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
108610 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
108611 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
108612 +
108613 + if (current_loops != NULL) {
108614 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
108615 + add_bb_to_loop(bb_true, cond_bb->loop_father);
108616 + }
108617 +
108618 + insert_cond(cond_bb, arg, cond_code, type_value);
108619 + insert_cond_result(bb_true, stmt, arg, min);
108620 +
108621 +// print_the_code_insertions(stmt);
108622 +}
108623 +
108624 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
108625 +{
108626 + const_tree rhs_type = TREE_TYPE(rhs);
108627 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
108628 +
108629 + gcc_assert(rhs_type != NULL_TREE);
108630 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
108631 + return;
108632 +
108633 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
108634 +
108635 + if (is_const_plus_unsigned_signed_truncation(rhs))
108636 + return;
108637 +
108638 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
108639 + // typemax (-1) < typemin (0)
108640 + if (TREE_OVERFLOW(type_max))
108641 + return;
108642 +
108643 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
108644 +
108645 + cast_rhs_type = TREE_TYPE(cast_rhs);
108646 + type_max_type = TREE_TYPE(type_max);
108647 + type_min_type = TREE_TYPE(type_min);
108648 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
108649 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
108650 +
108651 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
108652 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
108653 +}
108654 +
108655 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
108656 +{
108657 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
108658 + return false;
108659 + if (!is_gimple_constant(rhs))
108660 + return false;
108661 + return true;
108662 +}
108663 +
108664 +static tree get_def_stmt_rhs(const_tree var)
108665 +{
108666 + tree rhs1, def_stmt_rhs1;
108667 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
108668 +
108669 + def_stmt = get_def_stmt(var);
108670 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
108671 +
108672 + rhs1 = gimple_assign_rhs1(def_stmt);
108673 + rhs1_def_stmt = get_def_stmt(rhs1);
108674 + if (!gimple_assign_cast_p(rhs1_def_stmt))
108675 + return rhs1;
108676 +
108677 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
108678 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
108679 +
108680 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
108681 + case GIMPLE_CALL:
108682 + case GIMPLE_NOP:
108683 + case GIMPLE_ASM:
108684 + case GIMPLE_PHI:
108685 + return def_stmt_rhs1;
108686 + case GIMPLE_ASSIGN:
108687 + return rhs1;
108688 + default:
108689 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
108690 + gcc_unreachable();
108691 + }
108692 +}
108693 +
108694 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
108695 +{
108696 + tree new_rhs, orig_rhs;
108697 + void (*gimple_assign_set_rhs)(gimple, tree);
108698 + tree rhs1 = gimple_assign_rhs1(stmt);
108699 + tree rhs2 = gimple_assign_rhs2(stmt);
108700 + tree lhs = gimple_get_lhs(stmt);
108701 +
108702 + if (!check_overflow)
108703 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108704 +
108705 + if (change_rhs == NULL_TREE)
108706 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108707 +
108708 + if (new_rhs2 == NULL_TREE) {
108709 + orig_rhs = rhs1;
108710 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
108711 + } else {
108712 + orig_rhs = rhs2;
108713 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
108714 + }
108715 +
108716 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
108717 +
108718 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
108719 + gimple_assign_set_rhs(stmt, new_rhs);
108720 + update_stmt(stmt);
108721 +
108722 + return create_assign(visited, stmt, lhs, AFTER_STMT);
108723 +}
108724 +
108725 +static bool is_subtraction_special(const_gimple stmt)
108726 +{
108727 + gimple rhs1_def_stmt, rhs2_def_stmt;
108728 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
108729 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
108730 + const_tree rhs1 = gimple_assign_rhs1(stmt);
108731 + const_tree rhs2 = gimple_assign_rhs2(stmt);
108732 +
108733 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
108734 + return false;
108735 +
108736 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
108737 +
108738 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
108739 + return false;
108740 +
108741 + rhs1_def_stmt = get_def_stmt(rhs1);
108742 + rhs2_def_stmt = get_def_stmt(rhs2);
108743 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
108744 + return false;
108745 +
108746 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
108747 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
108748 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
108749 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
108750 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
108751 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
108752 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
108753 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
108754 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
108755 + return false;
108756 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
108757 + return false;
108758 +
108759 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
108760 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
108761 + return true;
108762 +}
108763 +
108764 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
108765 +{
108766 + tree new_rhs1, new_rhs2;
108767 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
108768 + gimple assign, stmt = get_def_stmt(lhs);
108769 + tree rhs1 = gimple_assign_rhs1(stmt);
108770 + tree rhs2 = gimple_assign_rhs2(stmt);
108771 +
108772 + if (!is_subtraction_special(stmt))
108773 + return NULL_TREE;
108774 +
108775 + new_rhs1 = expand(visited, rhs1);
108776 + new_rhs2 = expand(visited, rhs2);
108777 +
108778 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
108779 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
108780 +
108781 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
108782 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
108783 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
108784 + }
108785 +
108786 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
108787 + new_lhs = gimple_get_lhs(assign);
108788 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
108789 +
108790 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
108791 +}
108792 +
108793 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
108794 +{
108795 + const_gimple def_stmt;
108796 +
108797 + if (TREE_CODE(rhs) != SSA_NAME)
108798 + return false;
108799 +
108800 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
108801 + return false;
108802 +
108803 + def_stmt = get_def_stmt(rhs);
108804 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
108805 + return false;
108806 +
108807 + return true;
108808 +}
108809 +
108810 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
108811 +{
108812 + tree rhs1, rhs2, new_lhs;
108813 + gimple def_stmt = get_def_stmt(lhs);
108814 + tree new_rhs1 = NULL_TREE;
108815 + tree new_rhs2 = NULL_TREE;
108816 +
108817 + rhs1 = gimple_assign_rhs1(def_stmt);
108818 + rhs2 = gimple_assign_rhs2(def_stmt);
108819 +
108820 + /* no DImode/TImode division in the 32/64 bit kernel */
108821 + switch (gimple_assign_rhs_code(def_stmt)) {
108822 + case RDIV_EXPR:
108823 + case TRUNC_DIV_EXPR:
108824 + case CEIL_DIV_EXPR:
108825 + case FLOOR_DIV_EXPR:
108826 + case ROUND_DIV_EXPR:
108827 + case TRUNC_MOD_EXPR:
108828 + case CEIL_MOD_EXPR:
108829 + case FLOOR_MOD_EXPR:
108830 + case ROUND_MOD_EXPR:
108831 + case EXACT_DIV_EXPR:
108832 + case POINTER_PLUS_EXPR:
108833 + case BIT_AND_EXPR:
108834 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
108835 + default:
108836 + break;
108837 + }
108838 +
108839 + new_lhs = handle_integer_truncation(visited, lhs);
108840 + if (new_lhs != NULL_TREE)
108841 + return new_lhs;
108842 +
108843 + if (TREE_CODE(rhs1) == SSA_NAME)
108844 + new_rhs1 = expand(visited, rhs1);
108845 + if (TREE_CODE(rhs2) == SSA_NAME)
108846 + new_rhs2 = expand(visited, rhs2);
108847 +
108848 + if (is_a_neg_overflow(def_stmt, rhs2))
108849 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
108850 + if (is_a_neg_overflow(def_stmt, rhs1))
108851 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
108852 +
108853 +
108854 + if (is_a_constant_overflow(def_stmt, rhs2))
108855 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
108856 + if (is_a_constant_overflow(def_stmt, rhs1))
108857 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
108858 +
108859 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
108860 +}
108861 +
108862 +#if BUILDING_GCC_VERSION >= 4007
108863 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
108864 +{
108865 + if (is_gimple_constant(rhs))
108866 + return cast_a_tree(size_overflow_type, rhs);
108867 + if (TREE_CODE(rhs) != SSA_NAME)
108868 + return NULL_TREE;
108869 + return expand(visited, rhs);
108870 +}
108871 +
108872 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
108873 +{
108874 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
108875 + gimple def_stmt = get_def_stmt(lhs);
108876 +
108877 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
108878 +
108879 + rhs1 = gimple_assign_rhs1(def_stmt);
108880 + rhs2 = gimple_assign_rhs2(def_stmt);
108881 + rhs3 = gimple_assign_rhs3(def_stmt);
108882 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
108883 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
108884 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
108885 +
108886 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
108887 +}
108888 +#endif
108889 +
108890 +static tree get_size_overflow_type(gimple stmt, const_tree node)
108891 +{
108892 + const_tree type;
108893 + tree new_type;
108894 +
108895 + gcc_assert(node != NULL_TREE);
108896 +
108897 + type = TREE_TYPE(node);
108898 +
108899 + if (gimple_plf(stmt, MY_STMT))
108900 + return TREE_TYPE(node);
108901 +
108902 + switch (TYPE_MODE(type)) {
108903 + case QImode:
108904 + new_type = intHI_type_node;
108905 + break;
108906 + case HImode:
108907 + new_type = intSI_type_node;
108908 + break;
108909 + case SImode:
108910 + new_type = intDI_type_node;
108911 + break;
108912 + case DImode:
108913 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
108914 + new_type = intDI_type_node;
108915 + else
108916 + new_type = intTI_type_node;
108917 + break;
108918 + default:
108919 + debug_tree((tree)node);
108920 + error("%s: unsupported gcc configuration.", __func__);
108921 + gcc_unreachable();
108922 + }
108923 +
108924 + if (TYPE_QUALS(type) != 0)
108925 + return build_qualified_type(new_type, TYPE_QUALS(type));
108926 + return new_type;
108927 +}
108928 +
108929 +static tree expand_visited(gimple def_stmt)
108930 +{
108931 + const_gimple next_stmt;
108932 + gimple_stmt_iterator gsi;
108933 + enum gimple_code code = gimple_code(def_stmt);
108934 +
108935 + if (code == GIMPLE_ASM)
108936 + return NULL_TREE;
108937 +
108938 + gsi = gsi_for_stmt(def_stmt);
108939 + gsi_next(&gsi);
108940 +
108941 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
108942 + return NULL_TREE;
108943 + gcc_assert(!gsi_end_p(gsi));
108944 + next_stmt = gsi_stmt(gsi);
108945 +
108946 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
108947 + return NULL_TREE;
108948 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
108949 +
108950 + return get_lhs(next_stmt);
108951 +}
108952 +
108953 +static tree expand(struct pointer_set_t *visited, tree lhs)
108954 +{
108955 + gimple def_stmt;
108956 +
108957 + if (skip_types(lhs))
108958 + return NULL_TREE;
108959 +
108960 + def_stmt = get_def_stmt(lhs);
108961 +
108962 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
108963 + return NULL_TREE;
108964 +
108965 + if (gimple_plf(def_stmt, MY_STMT))
108966 + return lhs;
108967 +
108968 + if (pointer_set_contains(visited, def_stmt))
108969 + return expand_visited(def_stmt);
108970 +
108971 + switch (gimple_code(def_stmt)) {
108972 + case GIMPLE_PHI:
108973 + return handle_phi(visited, lhs);
108974 + case GIMPLE_CALL:
108975 + case GIMPLE_ASM:
108976 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
108977 + case GIMPLE_ASSIGN:
108978 + switch (gimple_num_ops(def_stmt)) {
108979 + case 2:
108980 + return handle_unary_ops(visited, def_stmt);
108981 + case 3:
108982 + return handle_binary_ops(visited, lhs);
108983 +#if BUILDING_GCC_VERSION >= 4007
108984 + case 4:
108985 + return handle_ternary_ops(visited, lhs);
108986 +#endif
108987 + }
108988 + default:
108989 + debug_gimple_stmt(def_stmt);
108990 + error("%s: unknown gimple code", __func__);
108991 + gcc_unreachable();
108992 + }
108993 +}
108994 +
108995 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
108996 +{
108997 + const_gimple assign;
108998 + tree orig_type = TREE_TYPE(orig_node);
108999 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109000 +
109001 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109002 + return gimple_get_lhs(assign);
109003 +}
109004 +
109005 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
109006 +{
109007 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
109008 + update_stmt(stmt);
109009 +}
109010 +
109011 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
109012 +{
109013 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
109014 + update_stmt(stmt);
109015 +}
109016 +
109017 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
109018 +{
109019 + tree arg;
109020 + const_tree origarg;
109021 +
109022 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
109023 + return true;
109024 +
109025 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
109026 + while (origarg && *argnum) {
109027 + (*argnum)--;
109028 + origarg = TREE_CHAIN(origarg);
109029 + }
109030 +
109031 + gcc_assert(*argnum == 0);
109032 +
109033 + gcc_assert(origarg != NULL_TREE);
109034 + *argnum = 0;
109035 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
109036 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
109037 + return true;
109038 + return false;
109039 +}
109040 +
109041 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
109042 +{
109043 + gimple phi = get_def_stmt(result);
109044 + unsigned int i, n = gimple_phi_num_args(phi);
109045 +
109046 + if (!phi)
109047 + return MARK_NO;
109048 +
109049 + pointer_set_insert(visited, phi);
109050 + for (i = 0; i < n; i++) {
109051 + enum mark marked;
109052 + const_tree arg = gimple_phi_arg_def(phi, i);
109053 + marked = pre_expand(visited, search_err_code, arg);
109054 + if (marked != MARK_NO)
109055 + return marked;
109056 + }
109057 + return MARK_NO;
109058 +}
109059 +
109060 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109061 +{
109062 + gimple def_stmt = get_def_stmt(lhs);
109063 + const_tree rhs;
109064 +
109065 + if (!def_stmt)
109066 + return MARK_NO;
109067 +
109068 + rhs = gimple_assign_rhs1(def_stmt);
109069 +
109070 + def_stmt = get_def_stmt(rhs);
109071 + if (is_gimple_constant(rhs))
109072 + search_err_code[FROM_CONST] = true;
109073 +
109074 + return pre_expand(visited, search_err_code, rhs);
109075 +}
109076 +
109077 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109078 +{
109079 + gimple def_stmt = get_def_stmt(lhs);
109080 + const_tree rhs1, rhs2;
109081 + enum mark marked;
109082 +
109083 + if (!def_stmt)
109084 + return MARK_NO;
109085 +
109086 + search_err_code[CAST_ONLY] = false;
109087 +
109088 + rhs1 = gimple_assign_rhs1(def_stmt);
109089 + rhs2 = gimple_assign_rhs2(def_stmt);
109090 + marked = pre_expand(visited, search_err_code, rhs1);
109091 + if (marked != MARK_NO)
109092 + return marked;
109093 + return pre_expand(visited, search_err_code, rhs2);
109094 +}
109095 +
109096 +static const_tree search_field_decl(const_tree comp_ref)
109097 +{
109098 + const_tree field = NULL_TREE;
109099 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
109100 +
109101 + for (i = 0; i < len; i++) {
109102 + field = TREE_OPERAND(comp_ref, i);
109103 + if (TREE_CODE(field) == FIELD_DECL)
109104 + break;
109105 + }
109106 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
109107 + return field;
109108 +}
109109 +
109110 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
109111 +{
109112 + const_tree attr, p;
109113 +
109114 + // mm/filemap.c D.35286_51 = D.35283_46 (file_10(D), mapping_11, pos_1, D.35273_50, D.35285_49, page.14_48, fsdata.15_47);
109115 + if (fndecl == NULL_TREE)
109116 + return MARK_NO;
109117 +
109118 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
109119 + if (!attr || !TREE_VALUE(attr))
109120 + return MARK_NO;
109121 +
109122 + p = TREE_VALUE(attr);
109123 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
109124 + return MARK_TURN_OFF;
109125 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
109126 + return MARK_NOT_INTENTIONAL;
109127 + if (argnum == 0) {
109128 + gcc_assert(current_function_decl == fndecl);
109129 + return MARK_NO;
109130 + }
109131 +
109132 + do {
109133 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
109134 + return MARK_YES;
109135 + p = TREE_CHAIN(p);
109136 + } while (p);
109137 +
109138 + return MARK_NO;
109139 +}
109140 +
109141 +static void print_missing_msg(tree func, unsigned int argnum)
109142 +{
109143 + unsigned int new_hash;
109144 + size_t len;
109145 + unsigned char tree_codes[CODES_LIMIT];
109146 + location_t loc;
109147 + const char *curfunc;
109148 +
109149 + func = get_original_function_decl(func);
109150 + loc = DECL_SOURCE_LOCATION(func);
109151 + curfunc = get_asm_name(func);
109152 +
109153 + len = get_function_decl(func, tree_codes);
109154 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
109155 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
109156 +}
109157 +
109158 +static unsigned int search_missing_attribute(const_tree arg)
109159 +{
109160 + unsigned int argnum;
109161 + const struct size_overflow_hash *hash;
109162 + const_tree type = TREE_TYPE(arg);
109163 + tree func = get_original_function_decl(current_function_decl);
109164 +
109165 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
109166 +
109167 + if (TREE_CODE(type) == POINTER_TYPE)
109168 + return 0;
109169 +
109170 + argnum = find_arg_number(arg, func);
109171 + if (argnum == 0)
109172 + return 0;
109173 +
109174 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
109175 + return argnum;
109176 +
109177 + hash = get_function_hash(func);
109178 + if (!hash || !(hash->param & (1U << argnum))) {
109179 + print_missing_msg(func, argnum);
109180 + return 0;
109181 + }
109182 + return argnum;
109183 +}
109184 +
109185 +static enum mark is_already_marked(const_tree lhs)
109186 +{
109187 + unsigned int argnum;
109188 + const_tree fndecl;
109189 +
109190 + argnum = search_missing_attribute(lhs);
109191 + fndecl = get_original_function_decl(current_function_decl);
109192 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
109193 + return MARK_YES;
109194 + return MARK_NO;
109195 +}
109196 +
109197 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109198 +{
109199 + const_gimple def_stmt;
109200 +
109201 + if (skip_types(lhs))
109202 + return MARK_NO;
109203 +
109204 + if (TREE_CODE(lhs) == PARM_DECL)
109205 + return is_already_marked(lhs);
109206 +
109207 + if (TREE_CODE(lhs) == COMPONENT_REF) {
109208 + const_tree field, attr;
109209 +
109210 + field = search_field_decl(lhs);
109211 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
109212 + if (!attr || !TREE_VALUE(attr))
109213 + return MARK_NO;
109214 + return MARK_YES;
109215 + }
109216 +
109217 + def_stmt = get_def_stmt(lhs);
109218 +
109219 + if (!def_stmt)
109220 + return MARK_NO;
109221 +
109222 + if (pointer_set_contains(visited, def_stmt))
109223 + return MARK_NO;
109224 +
109225 + switch (gimple_code(def_stmt)) {
109226 + case GIMPLE_NOP:
109227 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
109228 + return is_already_marked(lhs);
109229 + return MARK_NO;
109230 + case GIMPLE_PHI:
109231 + return walk_phi(visited, search_err_code, lhs);
109232 + case GIMPLE_CALL:
109233 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
109234 + return MARK_TURN_OFF;
109235 + check_function_hash(def_stmt);
109236 + return MARK_NO;
109237 + case GIMPLE_ASM:
109238 + search_err_code[CAST_ONLY] = false;
109239 + return MARK_NO;
109240 + case GIMPLE_ASSIGN:
109241 + switch (gimple_num_ops(def_stmt)) {
109242 + case 2:
109243 + return walk_unary_ops(visited, search_err_code, lhs);
109244 + case 3:
109245 + return walk_binary_ops(visited, search_err_code, lhs);
109246 + }
109247 + default:
109248 + debug_gimple_stmt((gimple)def_stmt);
109249 + error("%s: unknown gimple code", __func__);
109250 + gcc_unreachable();
109251 + }
109252 +}
109253 +
109254 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
109255 +static bool skip_asm(const_tree arg)
109256 +{
109257 + gimple def_stmt = get_def_stmt(arg);
109258 +
109259 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
109260 + return false;
109261 +
109262 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
109263 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
109264 +}
109265 +
109266 +/*
109267 +0</MARK_YES: no dup, search attributes (so, int)
109268 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
109269 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
109270 +*/
109271 +
109272 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
109273 +{
109274 + struct pointer_set_t *visited;
109275 + enum mark is_marked, is_found;
109276 + location_t loc;
109277 + bool search_err_code[2] = {true, false};
109278 +
109279 + is_marked = mark_status(current_function_decl, 0);
109280 + if (is_marked == MARK_TURN_OFF)
109281 + return true;
109282 +
109283 + is_marked = mark_status(fndecl, argnum + 1);
109284 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
109285 + return true;
109286 +
109287 + visited = pointer_set_create();
109288 + is_found = pre_expand(visited, search_err_code, arg);
109289 + pointer_set_destroy(visited);
109290 +
109291 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
109292 + return true;
109293 +
109294 + if (where == FROM_ARG && skip_asm(arg))
109295 + return true;
109296 +
109297 + if (is_found == MARK_TURN_OFF)
109298 + return true;
109299 +
109300 + if ((is_found == MARK_YES && is_marked == MARK_YES))
109301 + return true;
109302 +
109303 + if (is_found == MARK_YES) {
109304 + loc = DECL_SOURCE_LOCATION(fndecl);
109305 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
109306 + return true;
109307 + }
109308 + return false;
109309 +}
109310 +
109311 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
109312 +{
109313 + struct pointer_set_t *visited;
109314 + tree arg, new_arg;
109315 + bool match;
109316 +
109317 + if (argnum == 0)
109318 + return;
109319 +
109320 + argnum--;
109321 +
109322 + match = get_function_arg(&argnum, fndecl);
109323 + if (!match)
109324 + return;
109325 + gcc_assert(gimple_call_num_args(stmt) > argnum);
109326 + arg = gimple_call_arg(stmt, argnum);
109327 + if (arg == NULL_TREE)
109328 + return;
109329 +
109330 + if (skip_types(arg))
109331 + return;
109332 +
109333 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
109334 + return;
109335 +
109336 + visited = pointer_set_create();
109337 + new_arg = expand(visited, arg);
109338 + pointer_set_destroy(visited);
109339 +
109340 + if (new_arg == NULL_TREE)
109341 + return;
109342 +
109343 + change_function_arg(stmt, arg, argnum, new_arg);
109344 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
109345 +}
109346 +
109347 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
109348 +{
109349 + tree p = TREE_VALUE(attr);
109350 + do {
109351 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
109352 + p = TREE_CHAIN(p);
109353 + } while (p);
109354 +}
109355 +
109356 +static void handle_function_by_hash(gimple stmt, tree fndecl)
109357 +{
109358 + unsigned int num;
109359 + const struct size_overflow_hash *hash;
109360 +
109361 + hash = get_function_hash(fndecl);
109362 + if (!hash)
109363 + return;
109364 +
109365 + for (num = 0; num <= MAX_PARAM; num++)
109366 + if (hash->param & (1U << num))
109367 + handle_function_arg(stmt, fndecl, num);
109368 +}
109369 +
109370 +static bool check_return_value(void)
109371 +{
109372 + const struct size_overflow_hash *hash;
109373 +
109374 + hash = get_function_hash(current_function_decl);
109375 + if (!hash || !(hash->param & 1U << 0))
109376 + return false;
109377 +
109378 + return true;
109379 +}
109380 +
109381 +static void handle_return_value(gimple ret_stmt)
109382 +{
109383 + struct pointer_set_t *visited;
109384 + tree ret, new_ret;
109385 +
109386 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
109387 + return;
109388 +
109389 + ret = gimple_return_retval(ret_stmt);
109390 +
109391 + if (skip_types(ret))
109392 + return;
109393 +
109394 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
109395 + return;
109396 +
109397 + visited = pointer_set_create();
109398 + new_ret = expand(visited, ret);
109399 + pointer_set_destroy(visited);
109400 +
109401 + change_function_return(ret_stmt, ret, new_ret);
109402 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
109403 +}
109404 +
109405 +static void set_plf_false(void)
109406 +{
109407 + basic_block bb;
109408 +
109409 + FOR_ALL_BB(bb) {
109410 + gimple_stmt_iterator si;
109411 +
109412 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
109413 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
109414 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
109415 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
109416 + }
109417 +}
109418 +
109419 +static unsigned int handle_function(void)
109420 +{
109421 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
109422 + bool check_ret;
109423 +
109424 + set_plf_false();
109425 +
109426 + check_ret = check_return_value();
109427 +
109428 + do {
109429 + gimple_stmt_iterator gsi;
109430 + next = bb->next_bb;
109431 +
109432 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
109433 + tree fndecl, attr;
109434 + gimple stmt = gsi_stmt(gsi);
109435 +
109436 + if (check_ret)
109437 + handle_return_value(stmt);
109438 +
109439 + if (!(is_gimple_call(stmt)))
109440 + continue;
109441 + fndecl = gimple_call_fndecl(stmt);
109442 + if (fndecl == NULL_TREE)
109443 + continue;
109444 + if (gimple_call_num_args(stmt) == 0)
109445 + continue;
109446 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
109447 + if (!attr || !TREE_VALUE(attr))
109448 + handle_function_by_hash(stmt, fndecl);
109449 + else
109450 + handle_function_by_attribute(stmt, attr, fndecl);
109451 + gsi = gsi_for_stmt(stmt);
109452 + next = gimple_bb(stmt)->next_bb;
109453 + }
109454 + bb = next;
109455 + } while (bb);
109456 + return 0;
109457 +}
109458 +
109459 +static struct gimple_opt_pass size_overflow_pass = {
109460 + .pass = {
109461 + .type = GIMPLE_PASS,
109462 + .name = "size_overflow",
109463 +#if BUILDING_GCC_VERSION >= 4008
109464 + .optinfo_flags = OPTGROUP_NONE,
109465 +#endif
109466 + .gate = NULL,
109467 + .execute = handle_function,
109468 + .sub = NULL,
109469 + .next = NULL,
109470 + .static_pass_number = 0,
109471 + .tv_id = TV_NONE,
109472 + .properties_required = PROP_cfg,
109473 + .properties_provided = 0,
109474 + .properties_destroyed = 0,
109475 + .todo_flags_start = 0,
109476 + .todo_flags_finish = TODO_dump_func | TODO_verify_ssa | TODO_verify_stmts | TODO_remove_unused_locals | TODO_update_ssa_no_phi | TODO_cleanup_cfg | TODO_ggc_collect | TODO_verify_flow
109477 + }
109478 +};
109479 +
109480 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
109481 +{
109482 + tree fntype;
109483 +
109484 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
109485 +
109486 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
109487 + fntype = build_function_type_list(void_type_node,
109488 + const_char_ptr_type_node,
109489 + unsigned_type_node,
109490 + const_char_ptr_type_node,
109491 + const_char_ptr_type_node,
109492 + NULL_TREE);
109493 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
109494 +
109495 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
109496 + TREE_PUBLIC(report_size_overflow_decl) = 1;
109497 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
109498 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
109499 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
109500 +}
109501 +
109502 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
109503 +{
109504 + int i;
109505 + const char * const plugin_name = plugin_info->base_name;
109506 + const int argc = plugin_info->argc;
109507 + const struct plugin_argument * const argv = plugin_info->argv;
109508 + bool enable = true;
109509 +
109510 + struct register_pass_info size_overflow_pass_info = {
109511 + .pass = &size_overflow_pass.pass,
109512 + .reference_pass_name = "ssa",
109513 + .ref_pass_instance_number = 1,
109514 + .pos_op = PASS_POS_INSERT_AFTER
109515 + };
109516 +
109517 + if (!plugin_default_version_check(version, &gcc_version)) {
109518 + error(G_("incompatible gcc/plugin versions"));
109519 + return 1;
109520 + }
109521 +
109522 + for (i = 0; i < argc; ++i) {
109523 + if (!strcmp(argv[i].key, "no-size-overflow")) {
109524 + enable = false;
109525 + continue;
109526 + }
109527 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
109528 + }
109529 +
109530 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
109531 + if (enable) {
109532 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
109533 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
109534 + }
109535 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
109536 +
109537 + return 0;
109538 +}
109539 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
109540 new file mode 100644
109541 index 0000000..ac2901e
109542 --- /dev/null
109543 +++ b/tools/gcc/stackleak_plugin.c
109544 @@ -0,0 +1,327 @@
109545 +/*
109546 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
109547 + * Licensed under the GPL v2
109548 + *
109549 + * Note: the choice of the license means that the compilation process is
109550 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
109551 + * but for the kernel it doesn't matter since it doesn't link against
109552 + * any of the gcc libraries
109553 + *
109554 + * gcc plugin to help implement various PaX features
109555 + *
109556 + * - track lowest stack pointer
109557 + *
109558 + * TODO:
109559 + * - initialize all local variables
109560 + *
109561 + * BUGS:
109562 + * - none known
109563 + */
109564 +#include "gcc-plugin.h"
109565 +#include "config.h"
109566 +#include "system.h"
109567 +#include "coretypes.h"
109568 +#include "tree.h"
109569 +#include "tree-pass.h"
109570 +#include "flags.h"
109571 +#include "intl.h"
109572 +#include "toplev.h"
109573 +#include "plugin.h"
109574 +//#include "expr.h" where are you...
109575 +#include "diagnostic.h"
109576 +#include "plugin-version.h"
109577 +#include "tm.h"
109578 +#include "function.h"
109579 +#include "basic-block.h"
109580 +#include "gimple.h"
109581 +#include "rtl.h"
109582 +#include "emit-rtl.h"
109583 +
109584 +#if BUILDING_GCC_VERSION >= 4008
109585 +#define TODO_dump_func 0
109586 +#endif
109587 +
109588 +extern void print_gimple_stmt(FILE *, gimple, int, int);
109589 +
109590 +int plugin_is_GPL_compatible;
109591 +
109592 +static int track_frame_size = -1;
109593 +static const char track_function[] = "pax_track_stack";
109594 +static const char check_function[] = "pax_check_alloca";
109595 +static bool init_locals;
109596 +
109597 +static struct plugin_info stackleak_plugin_info = {
109598 + .version = "201302112000",
109599 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
109600 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
109601 +};
109602 +
109603 +static bool gate_stackleak_track_stack(void);
109604 +static unsigned int execute_stackleak_tree_instrument(void);
109605 +static unsigned int execute_stackleak_final(void);
109606 +
109607 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
109608 + .pass = {
109609 + .type = GIMPLE_PASS,
109610 + .name = "stackleak_tree_instrument",
109611 +#if BUILDING_GCC_VERSION >= 4008
109612 + .optinfo_flags = OPTGROUP_NONE,
109613 +#endif
109614 + .gate = gate_stackleak_track_stack,
109615 + .execute = execute_stackleak_tree_instrument,
109616 + .sub = NULL,
109617 + .next = NULL,
109618 + .static_pass_number = 0,
109619 + .tv_id = TV_NONE,
109620 + .properties_required = PROP_gimple_leh | PROP_cfg,
109621 + .properties_provided = 0,
109622 + .properties_destroyed = 0,
109623 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
109624 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
109625 + }
109626 +};
109627 +
109628 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
109629 + .pass = {
109630 + .type = RTL_PASS,
109631 + .name = "stackleak_final",
109632 +#if BUILDING_GCC_VERSION >= 4008
109633 + .optinfo_flags = OPTGROUP_NONE,
109634 +#endif
109635 + .gate = gate_stackleak_track_stack,
109636 + .execute = execute_stackleak_final,
109637 + .sub = NULL,
109638 + .next = NULL,
109639 + .static_pass_number = 0,
109640 + .tv_id = TV_NONE,
109641 + .properties_required = 0,
109642 + .properties_provided = 0,
109643 + .properties_destroyed = 0,
109644 + .todo_flags_start = 0,
109645 + .todo_flags_finish = TODO_dump_func
109646 + }
109647 +};
109648 +
109649 +static bool gate_stackleak_track_stack(void)
109650 +{
109651 + return track_frame_size >= 0;
109652 +}
109653 +
109654 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
109655 +{
109656 + gimple check_alloca;
109657 + tree fntype, fndecl, alloca_size;
109658 +
109659 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
109660 + fndecl = build_fn_decl(check_function, fntype);
109661 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
109662 +
109663 + // insert call to void pax_check_alloca(unsigned long size)
109664 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
109665 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
109666 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
109667 +}
109668 +
109669 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
109670 +{
109671 + gimple track_stack;
109672 + tree fntype, fndecl;
109673 +
109674 + fntype = build_function_type_list(void_type_node, NULL_TREE);
109675 + fndecl = build_fn_decl(track_function, fntype);
109676 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
109677 +
109678 + // insert call to void pax_track_stack(void)
109679 + track_stack = gimple_build_call(fndecl, 0);
109680 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
109681 +}
109682 +
109683 +#if BUILDING_GCC_VERSION == 4005
109684 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
109685 +{
109686 + tree fndecl;
109687 +
109688 + if (!is_gimple_call(stmt))
109689 + return false;
109690 + fndecl = gimple_call_fndecl(stmt);
109691 + if (!fndecl)
109692 + return false;
109693 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
109694 + return false;
109695 +// print_node(stderr, "pax", fndecl, 4);
109696 + return DECL_FUNCTION_CODE(fndecl) == code;
109697 +}
109698 +#endif
109699 +
109700 +static bool is_alloca(gimple stmt)
109701 +{
109702 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
109703 + return true;
109704 +
109705 +#if BUILDING_GCC_VERSION >= 4007
109706 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
109707 + return true;
109708 +#endif
109709 +
109710 + return false;
109711 +}
109712 +
109713 +static unsigned int execute_stackleak_tree_instrument(void)
109714 +{
109715 + basic_block bb, entry_bb;
109716 + bool prologue_instrumented = false, is_leaf = true;
109717 +
109718 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
109719 +
109720 + // 1. loop through BBs and GIMPLE statements
109721 + FOR_EACH_BB(bb) {
109722 + gimple_stmt_iterator gsi;
109723 +
109724 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
109725 + gimple stmt;
109726 +
109727 + stmt = gsi_stmt(gsi);
109728 +
109729 + if (is_gimple_call(stmt))
109730 + is_leaf = false;
109731 +
109732 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
109733 + if (!is_alloca(stmt))
109734 + continue;
109735 +
109736 + // 2. insert stack overflow check before each __builtin_alloca call
109737 + stackleak_check_alloca(&gsi);
109738 +
109739 + // 3. insert track call after each __builtin_alloca call
109740 + stackleak_add_instrumentation(&gsi);
109741 + if (bb == entry_bb)
109742 + prologue_instrumented = true;
109743 + }
109744 + }
109745 +
109746 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
109747 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
109748 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
109749 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
109750 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
109751 + return 0;
109752 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
109753 + return 0;
109754 +
109755 + // 4. insert track call at the beginning
109756 + if (!prologue_instrumented) {
109757 + gimple_stmt_iterator gsi;
109758 +
109759 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
109760 + if (dom_info_available_p(CDI_DOMINATORS))
109761 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
109762 + gsi = gsi_start_bb(bb);
109763 + stackleak_add_instrumentation(&gsi);
109764 + }
109765 +
109766 + return 0;
109767 +}
109768 +
109769 +static unsigned int execute_stackleak_final(void)
109770 +{
109771 + rtx insn, next;
109772 +
109773 + if (cfun->calls_alloca)
109774 + return 0;
109775 +
109776 + // keep calls only if function frame is big enough
109777 + if (get_frame_size() >= track_frame_size)
109778 + return 0;
109779 +
109780 + // 1. find pax_track_stack calls
109781 + for (insn = get_insns(); insn; insn = next) {
109782 + // rtl match: (call_insn 8 7 9 3 (call (mem (symbol_ref ("pax_track_stack") [flags 0x41] <function_decl 0xb7470e80 pax_track_stack>) [0 S1 A8]) (4)) -1 (nil) (nil))
109783 + rtx body;
109784 +
109785 + next = NEXT_INSN(insn);
109786 + if (!CALL_P(insn))
109787 + continue;
109788 + body = PATTERN(insn);
109789 + if (GET_CODE(body) != CALL)
109790 + continue;
109791 + body = XEXP(body, 0);
109792 + if (GET_CODE(body) != MEM)
109793 + continue;
109794 + body = XEXP(body, 0);
109795 + if (GET_CODE(body) != SYMBOL_REF)
109796 + continue;
109797 + if (strcmp(XSTR(body, 0), track_function))
109798 + continue;
109799 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
109800 + // 2. delete call
109801 + delete_insn_and_edges(insn);
109802 +#if BUILDING_GCC_VERSION >= 4007
109803 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
109804 + insn = next;
109805 + next = NEXT_INSN(insn);
109806 + delete_insn_and_edges(insn);
109807 + }
109808 +#endif
109809 + }
109810 +
109811 +// print_simple_rtl(stderr, get_insns());
109812 +// print_rtl(stderr, get_insns());
109813 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
109814 +
109815 + return 0;
109816 +}
109817 +
109818 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
109819 +{
109820 + const char * const plugin_name = plugin_info->base_name;
109821 + const int argc = plugin_info->argc;
109822 + const struct plugin_argument * const argv = plugin_info->argv;
109823 + int i;
109824 + struct register_pass_info stackleak_tree_instrument_pass_info = {
109825 + .pass = &stackleak_tree_instrument_pass.pass,
109826 +// .reference_pass_name = "tree_profile",
109827 + .reference_pass_name = "optimized",
109828 + .ref_pass_instance_number = 1,
109829 + .pos_op = PASS_POS_INSERT_BEFORE
109830 + };
109831 + struct register_pass_info stackleak_final_pass_info = {
109832 + .pass = &stackleak_final_rtl_opt_pass.pass,
109833 + .reference_pass_name = "final",
109834 + .ref_pass_instance_number = 1,
109835 + .pos_op = PASS_POS_INSERT_BEFORE
109836 + };
109837 +
109838 + if (!plugin_default_version_check(version, &gcc_version)) {
109839 + error(G_("incompatible gcc/plugin versions"));
109840 + return 1;
109841 + }
109842 +
109843 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
109844 +
109845 + for (i = 0; i < argc; ++i) {
109846 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
109847 + if (!argv[i].value) {
109848 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
109849 + continue;
109850 + }
109851 + track_frame_size = atoi(argv[i].value);
109852 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
109853 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
109854 + continue;
109855 + }
109856 + if (!strcmp(argv[i].key, "initialize-locals")) {
109857 + if (argv[i].value) {
109858 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
109859 + continue;
109860 + }
109861 + init_locals = true;
109862 + continue;
109863 + }
109864 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
109865 + }
109866 +
109867 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
109868 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
109869 +
109870 + return 0;
109871 +}
109872 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
109873 new file mode 100644
109874 index 0000000..4fae911
109875 --- /dev/null
109876 +++ b/tools/gcc/structleak_plugin.c
109877 @@ -0,0 +1,277 @@
109878 +/*
109879 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
109880 + * Licensed under the GPL v2
109881 + *
109882 + * Note: the choice of the license means that the compilation process is
109883 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
109884 + * but for the kernel it doesn't matter since it doesn't link against
109885 + * any of the gcc libraries
109886 + *
109887 + * gcc plugin to forcibly initialize certain local variables that could
109888 + * otherwise leak kernel stack to userland if they aren't properly initialized
109889 + * by later code
109890 + *
109891 + * Homepage: http://pax.grsecurity.net/
109892 + *
109893 + * Usage:
109894 + * $ # for 4.5/4.6/C based 4.7
109895 + * $ gcc -I`gcc -print-file-name=plugin`/include -I`gcc -print-file-name=plugin`/include/c-family -fPIC -shared -O2 -o structleak_plugin.so structleak_plugin.c
109896 + * $ # for C++ based 4.7/4.8+
109897 + * $ g++ -I`g++ -print-file-name=plugin`/include -I`g++ -print-file-name=plugin`/include/c-family -fPIC -shared -O2 -o structleak_plugin.so structleak_plugin.c
109898 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
109899 + *
109900 + * TODO: eliminate redundant initializers
109901 + * increase type coverage
109902 + */
109903 +
109904 +#include "gcc-plugin.h"
109905 +#include "config.h"
109906 +#include "system.h"
109907 +#include "coretypes.h"
109908 +#include "tree.h"
109909 +#include "tree-pass.h"
109910 +#include "intl.h"
109911 +#include "plugin-version.h"
109912 +#include "tm.h"
109913 +#include "toplev.h"
109914 +#include "function.h"
109915 +#include "tree-flow.h"
109916 +#include "plugin.h"
109917 +#include "gimple.h"
109918 +#include "diagnostic.h"
109919 +#include "cfgloop.h"
109920 +#include "langhooks.h"
109921 +
109922 +#if BUILDING_GCC_VERSION >= 4008
109923 +#define TODO_dump_func 0
109924 +#endif
109925 +
109926 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
109927 +
109928 +// unused type flag in all versions 4.5-4.8
109929 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
109930 +
109931 +int plugin_is_GPL_compatible;
109932 +void debug_gimple_stmt(gimple gs);
109933 +
109934 +static struct plugin_info structleak_plugin_info = {
109935 + .version = "201304082245",
109936 + .help = "disable\tdo not activate plugin\n",
109937 +};
109938 +
109939 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
109940 +{
109941 + *no_add_attrs = true;
109942 +
109943 + // check for types? for now accept everything linux has to offer
109944 + if (TREE_CODE(*node) != FIELD_DECL)
109945 + return NULL_TREE;
109946 +
109947 + *no_add_attrs = false;
109948 + return NULL_TREE;
109949 +}
109950 +
109951 +static struct attribute_spec user_attr = {
109952 + .name = "user",
109953 + .min_length = 0,
109954 + .max_length = 0,
109955 + .decl_required = false,
109956 + .type_required = false,
109957 + .function_type_required = false,
109958 + .handler = handle_user_attribute,
109959 +#if BUILDING_GCC_VERSION >= 4007
109960 + .affects_type_identity = true
109961 +#endif
109962 +};
109963 +
109964 +static void register_attributes(void *event_data, void *data)
109965 +{
109966 + register_attribute(&user_attr);
109967 +// register_attribute(&force_attr);
109968 +}
109969 +
109970 +static tree get_field_type(tree field)
109971 +{
109972 + return strip_array_types(TREE_TYPE(field));
109973 +}
109974 +
109975 +static bool is_userspace_type(tree type)
109976 +{
109977 + tree field;
109978 +
109979 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
109980 + tree fieldtype = get_field_type(field);
109981 + enum tree_code code = TREE_CODE(fieldtype);
109982 +
109983 + if (code == RECORD_TYPE || code == UNION_TYPE)
109984 + if (is_userspace_type(fieldtype))
109985 + return true;
109986 +
109987 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
109988 + return true;
109989 + }
109990 + return false;
109991 +}
109992 +
109993 +static void finish_type(void *event_data, void *data)
109994 +{
109995 + tree type = (tree)event_data;
109996 +
109997 + if (TYPE_USERSPACE(type))
109998 + return;
109999 +
110000 + if (is_userspace_type(type))
110001 + TYPE_USERSPACE(type) = 1;
110002 +}
110003 +
110004 +static void initialize(tree var)
110005 +{
110006 + basic_block bb;
110007 + gimple_stmt_iterator gsi;
110008 + tree initializer;
110009 + gimple init_stmt;
110010 +
110011 + // this is the original entry bb before the forced split
110012 + // TODO: check further BBs in case more splits occured before us
110013 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
110014 +
110015 + // first check if the variable is already initialized, warn otherwise
110016 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110017 + gimple stmt = gsi_stmt(gsi);
110018 + tree rhs1;
110019 +
110020 + // we're looking for an assignment of a single rhs...
110021 + if (!gimple_assign_single_p(stmt))
110022 + continue;
110023 + rhs1 = gimple_assign_rhs1(stmt);
110024 +#if BUILDING_GCC_VERSION >= 4007
110025 + // ... of a non-clobbering expression...
110026 + if (TREE_CLOBBER_P(rhs1))
110027 + continue;
110028 +#endif
110029 + // ... to our variable...
110030 + if (gimple_get_lhs(stmt) != var)
110031 + continue;
110032 + // if it's an initializer then we're good
110033 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
110034 + return;
110035 + }
110036 +
110037 + // these aren't the 0days you're looking for
110038 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
110039 +
110040 + // build the initializer expression
110041 + initializer = build_constructor(TREE_TYPE(var), NULL);
110042 +
110043 + // build the initializer stmt
110044 + init_stmt = gimple_build_assign(var, initializer);
110045 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
110046 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
110047 + update_stmt(init_stmt);
110048 +}
110049 +
110050 +static unsigned int handle_function(void)
110051 +{
110052 + basic_block bb;
110053 + unsigned int ret = 0;
110054 + tree var;
110055 +
110056 +#if BUILDING_GCC_VERSION == 4005
110057 + tree vars;
110058 +#else
110059 + unsigned int i;
110060 +#endif
110061 +
110062 + // split the first bb where we can put the forced initializers
110063 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110064 + if (dom_info_available_p(CDI_DOMINATORS))
110065 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110066 +
110067 + // enumarate all local variables and forcibly initialize our targets
110068 +#if BUILDING_GCC_VERSION == 4005
110069 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
110070 + var = TREE_VALUE(vars);
110071 +#else
110072 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
110073 +#endif
110074 + tree type = TREE_TYPE(var);
110075 +
110076 + gcc_assert(DECL_P(var));
110077 + if (!auto_var_in_fn_p(var, current_function_decl))
110078 + continue;
110079 +
110080 + // only care about structure types
110081 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
110082 + continue;
110083 +
110084 + // if the type is of interest, examine the variable
110085 + if (TYPE_USERSPACE(type))
110086 + initialize(var);
110087 + }
110088 +
110089 + return ret;
110090 +}
110091 +
110092 +static struct gimple_opt_pass structleak_pass = {
110093 + .pass = {
110094 + .type = GIMPLE_PASS,
110095 + .name = "structleak",
110096 +#if BUILDING_GCC_VERSION >= 4008
110097 + .optinfo_flags = OPTGROUP_NONE,
110098 +#endif
110099 + .gate = NULL,
110100 + .execute = handle_function,
110101 + .sub = NULL,
110102 + .next = NULL,
110103 + .static_pass_number = 0,
110104 + .tv_id = TV_NONE,
110105 + .properties_required = PROP_cfg,
110106 + .properties_provided = 0,
110107 + .properties_destroyed = 0,
110108 + .todo_flags_start = 0,
110109 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa | TODO_ggc_collect | TODO_verify_flow
110110 + }
110111 +};
110112 +
110113 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110114 +{
110115 + int i;
110116 + const char * const plugin_name = plugin_info->base_name;
110117 + const int argc = plugin_info->argc;
110118 + const struct plugin_argument * const argv = plugin_info->argv;
110119 + bool enable = true;
110120 +
110121 + struct register_pass_info structleak_pass_info = {
110122 + .pass = &structleak_pass.pass,
110123 + .reference_pass_name = "ssa",
110124 + .ref_pass_instance_number = 1,
110125 + .pos_op = PASS_POS_INSERT_AFTER
110126 + };
110127 +
110128 + if (!plugin_default_version_check(version, &gcc_version)) {
110129 + error(G_("incompatible gcc/plugin versions"));
110130 + return 1;
110131 + }
110132 +
110133 + if (strcmp(lang_hooks.name, "GNU C")) {
110134 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
110135 + enable = false;
110136 + }
110137 +
110138 + for (i = 0; i < argc; ++i) {
110139 + if (!strcmp(argv[i].key, "disable")) {
110140 + enable = false;
110141 + continue;
110142 + }
110143 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110144 + }
110145 +
110146 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
110147 + if (enable) {
110148 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
110149 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
110150 + }
110151 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
110152 +
110153 + return 0;
110154 +}
110155 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
110156 index 280dd82..077b427 100644
110157 --- a/tools/lib/lk/Makefile
110158 +++ b/tools/lib/lk/Makefile
110159 @@ -28,7 +28,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
110160
110161 LIBFILE = liblk.a
110162
110163 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
110164 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
110165 EXTLIBS = -lelf -lpthread -lrt -lm
110166 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
110167 ALL_LDFLAGS = $(LDFLAGS)
110168 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
110169 index 6789d78..4afd019e 100644
110170 --- a/tools/perf/util/include/asm/alternative-asm.h
110171 +++ b/tools/perf/util/include/asm/alternative-asm.h
110172 @@ -5,4 +5,7 @@
110173
110174 #define altinstruction_entry #
110175
110176 + .macro pax_force_retaddr rip=0, reload=0
110177 + .endm
110178 +
110179 #endif
110180 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
110181 index 96b919d..c49bb74 100644
110182 --- a/tools/perf/util/include/linux/compiler.h
110183 +++ b/tools/perf/util/include/linux/compiler.h
110184 @@ -18,4 +18,12 @@
110185 #define __force
110186 #endif
110187
110188 +#ifndef __size_overflow
110189 +# define __size_overflow(...)
110190 +#endif
110191 +
110192 +#ifndef __intentional_overflow
110193 +# define __intentional_overflow(...)
110194 +#endif
110195 +
110196 #endif
110197 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
110198 index 1580dd4..5627b5b 100644
110199 --- a/virt/kvm/kvm_main.c
110200 +++ b/virt/kvm/kvm_main.c
110201 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
110202
110203 static cpumask_var_t cpus_hardware_enabled;
110204 static int kvm_usage_count = 0;
110205 -static atomic_t hardware_enable_failed;
110206 +static atomic_unchecked_t hardware_enable_failed;
110207
110208 struct kmem_cache *kvm_vcpu_cache;
110209 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
110210
110211 -static __read_mostly struct preempt_ops kvm_preempt_ops;
110212 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
110213 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
110214 +static struct preempt_ops kvm_preempt_ops = {
110215 + .sched_in = kvm_sched_in,
110216 + .sched_out = kvm_sched_out,
110217 +};
110218
110219 struct dentry *kvm_debugfs_dir;
110220
110221 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
110222 /* We can read the guest memory with __xxx_user() later on. */
110223 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
110224 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
110225 - !access_ok(VERIFY_WRITE,
110226 + !__access_ok(VERIFY_WRITE,
110227 (void __user *)(unsigned long)mem->userspace_addr,
110228 mem->memory_size)))
110229 goto out;
110230 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
110231 return 0;
110232 }
110233
110234 -static struct file_operations kvm_vcpu_fops = {
110235 +static file_operations_no_const kvm_vcpu_fops __read_only = {
110236 .release = kvm_vcpu_release,
110237 .unlocked_ioctl = kvm_vcpu_ioctl,
110238 #ifdef CONFIG_COMPAT
110239 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
110240 return 0;
110241 }
110242
110243 -static struct file_operations kvm_vm_fops = {
110244 +static file_operations_no_const kvm_vm_fops __read_only = {
110245 .release = kvm_vm_release,
110246 .unlocked_ioctl = kvm_vm_ioctl,
110247 #ifdef CONFIG_COMPAT
110248 @@ -2662,7 +2667,7 @@ out:
110249 return r;
110250 }
110251
110252 -static struct file_operations kvm_chardev_ops = {
110253 +static file_operations_no_const kvm_chardev_ops __read_only = {
110254 .unlocked_ioctl = kvm_dev_ioctl,
110255 .compat_ioctl = kvm_dev_ioctl,
110256 .llseek = noop_llseek,
110257 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
110258
110259 if (r) {
110260 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
110261 - atomic_inc(&hardware_enable_failed);
110262 + atomic_inc_unchecked(&hardware_enable_failed);
110263 printk(KERN_INFO "kvm: enabling virtualization on "
110264 "CPU%d failed\n", cpu);
110265 }
110266 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
110267
110268 kvm_usage_count++;
110269 if (kvm_usage_count == 1) {
110270 - atomic_set(&hardware_enable_failed, 0);
110271 + atomic_set_unchecked(&hardware_enable_failed, 0);
110272 on_each_cpu(hardware_enable_nolock, NULL, 1);
110273
110274 - if (atomic_read(&hardware_enable_failed)) {
110275 + if (atomic_read_unchecked(&hardware_enable_failed)) {
110276 hardware_disable_all_nolock();
110277 r = -EBUSY;
110278 }
110279 @@ -3100,7 +3105,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
110280 kvm_arch_vcpu_put(vcpu);
110281 }
110282
110283 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110284 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110285 struct module *module)
110286 {
110287 int r;
110288 @@ -3147,7 +3152,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110289 if (!vcpu_align)
110290 vcpu_align = __alignof__(struct kvm_vcpu);
110291 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
110292 - 0, NULL);
110293 + SLAB_USERCOPY, NULL);
110294 if (!kvm_vcpu_cache) {
110295 r = -ENOMEM;
110296 goto out_free_3;
110297 @@ -3157,9 +3162,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110298 if (r)
110299 goto out_free;
110300
110301 + pax_open_kernel();
110302 kvm_chardev_ops.owner = module;
110303 kvm_vm_fops.owner = module;
110304 kvm_vcpu_fops.owner = module;
110305 + pax_close_kernel();
110306
110307 r = misc_register(&kvm_dev);
110308 if (r) {
110309 @@ -3169,9 +3176,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
110310
110311 register_syscore_ops(&kvm_syscore_ops);
110312
110313 - kvm_preempt_ops.sched_in = kvm_sched_in;
110314 - kvm_preempt_ops.sched_out = kvm_sched_out;
110315 -
110316 r = kvm_init_debug();
110317 if (r) {
110318 printk(KERN_ERR "kvm: create debugfs files failed\n");